Question

Following on from How do I inject a Spring bean into Apache Wink?

I'm now using wink-spring-support and I thought I had things set up correctly.

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>

META-INF/wink/wink-core-context.xml contains:

<bean class="org.apache.wink.spring.Registrar">
    <property name="instances">
        <set>
            <ref bean="myservice" />
        </set>
    </property>
</bean>

<bean id="myservice" class="mystuff.ServiceImpl"/>

There's a @Autowired annotation in mystuff.ServiceImpl that injects other Spring stuff, and mystuff.ServiceImpl implements a JAX-RS annotated interface and itself includes a JAX-RS @Path("/services") annotation.

I can see Spring loading up this stuff just fine, including the myservice bean. However when I request my resources, I get a 404 not found. As Wink starts, I can see a couple of log entries that might indicate the problem:

applicationConfigLocation property was not defined

Using application classes null named in init-param applicationConfigLocation

Have I missed something somewhere? Any advice?

Was it helpful?

Solution

The problem was my misunderstanding the docs.

There is a Spring configuration META-INF/server/wink-core-context.xml provided with wink-spring-support. This registers the BeanPostProcessors that actually do the setup and must be referenced from contextConfigLocation.

I thought that I put my configuration in there, which explains why the application didn't get registered with Wink on startup.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top