I have a Maven project with the dependencies listed below:
wink.version = 1.1.3-incubating and spring.version = 3.0.5.RELEASE
Application Context in Spring includes:
<bean class="org.apache.wink.spring.Registrar">
<property name="classes">
<set value-type="java.lang.Class">
</set>
</property>
<property name="instances">
<set>
<ref local="restexample" />
</set>
</property>
</bean>
<bean id="restexample" class="com.example.rest.ExampleRest"></bean>
web.xml includes:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:META-INF/wink/wink-core-context.xml
classpath:applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>restServlet</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>restServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Rest Java Class includes:
@Path("/ex")
public class ExampleRest {
@GET
@Produces(MediaType.APPLICATION_JSON)
public String example() throws IOException {
return "{ 'id':'test' }";
}
}
Looking at the logs I don't see any exception or problem, the 'restexample' bean is being created but... I get a 404 when I try to call the REST service.
I think ExampleRest is not being registered by Apache Wink.
Any idea ?
UPDATE 02/14: Loking at the logs, I noticed that ExampleRest is not being registered by Apache Wink. Maybe, the problem is within the beans declaration or maybe the dependencies that I'm using. I also set-up another project without spring and it works there. I really need Spring to use his IoD for daos and services.
in your web.xml, you point to a file called wink-core-context.xml. The path to this file seems wrong. It should be:
META-INF/server/wink-core-context.xml
Not sure why you don't see the FileNotFoundException here.