Reputation: 63
We're using JavaConfig, and I'm trying to set up a separate application context to get around some issues in Jersey 1.7 (namely, the way it includes all Spring beans annotated with @Controller in all paths).
I've set the SpringServlet I want to use the separate application context up like so:
<servlet>
<servlet-name>My Servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.mycompany.admin</param-value>
</init-param>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.mycompany.AdminWebConfig</param-value>
</init-param>
</servlet>
However, Spring keeps giving me the following error when I try to hit one of the services; it's trying to treat my class name as a file path:
[2015-08-07 11:52:20,081] [ERROR] [] [request=] [user=] [ip=] [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/my-app].
[My REST Service]] [Allocate exception for servlet My REST Service] java.io.FileNotFoundException: Could not open ServletContext resource [/com.mycompany.AdminWebConfig]
Any thoughts? I thought setting contextClass to org.springframework.web.context.support.AnnotationConfigWebApplicationContext would make it recognize that as a class name, but it doesn't seem to be doing that...
Upvotes: 0
Views: 536
Reputation: 279890
Spring's DispatcherServlet
has support for AnnotationConfigWebApplicationContext
. But you're not using the DispatcherServlet
, you're using some Jersey SpringServlet
.
It explicitly creates an XmlWebApplicationContext
.
Upvotes: 1