This post has moved to the karyon-users Google Group.
https://groups.google.com/forum/#!topic/karyon-users/RM2IIVGNKXI
Question
I'm playing with Karyon and I've hitting a problem where Jersey and not Governator is trying to instantiate my rest resource classes. I'm trying to do a more robust than the hello world example where I can specify my own Guice modules for injection.
If I use the @InjectParam annotation Jersey finds it and says I missing a mapping for the constructor. If I only use the @Inject annotation then Jersey, not Guice, complains that I can't inject the constructor.
I found this thread, https://java.net/projects/jersey/lists/users/archive/2011-01/message/102, that exactly describes the problem I'm having but using another aspect of Jersey. I'm not sure what the equivalent problem class in Karyon is. Has anyone else had this problem when creating their own modules?
Begining of the Rest Resource
@Path("/")
public class CrudRoot {
private final CrudService service;
@Inject
public CrudRoot(CrudService service) {
super();
this.service = service;
My module
protected void configure() {
bind(CrudService.class).to(InMemCrudService.class);
}
web.xml
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee ">
<servlet>
<servlet-name>KaryonCrud</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.example.karyon.server</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>KaryonCrud</servlet-name>
<url-pattern>/rest/v1/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.example.karyon.server.CrudServletContextListener</listener-class>
</listener>
</web-app>
La solution
This post has moved to the karyon-users Google Group.
https://groups.google.com/forum/#!topic/karyon-users/RM2IIVGNKXI
Autres conseils
There are a few points here: