REST service not registering with Apache using Spring and Maven

I have a Maven project with the dependencies listed below:

enter image description here

wink.version = 1.1.3-incubation and spring.version = 3.0.5.RELEASE

Spring application context 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> 

The rest of the 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 see no exceptions or problems, a "restexample" bean is created, but ... I get 404 when I try to call the REST service.

I think ExampleRest is not registered with Apache Wink.

Any idea?

UPDATE 02/14 : Running into the logs, I noticed that ExampleRest is not registering Apache Wink. Perhaps the problem is declaring beans, or maybe the dependencies I'm using. I also set up another project without Spring, and it works there. I really need Spring to use its IoD for daos and services.

+6
source share
1 answer

in your web.xml, you specify a file called wink-core-context.xml. The path to this file seems to be wrong. It should be:

META-INF / server / wink-core-context.xml

See source

Not sure why you are not seeing FileNotFoundException here.

+2
source

All Articles