Seam 2.2 injection problem in RestEasy Service
kbalabuch.kbalabuch.wp.pl Jul 5, 2011 5:33 AMHi,
I have a problem with seam injection while using it in REST exposed class.
REST works fine - itself.
Injection works great in other components, but when component is configured to be a REST service injection returns null.
I believe it's configuration issue, but have no idea how to make it working... could anyone help me please.
below are my settings:
0) I use Seam 2.2.0.GA and jBoss 5.1.0.GA but i did try it already on Seam 2.2.2.Final and jBoss6.0.Final and behavior is the same.
1)I use EAR deployment and have attached RESTEasy jars:
deployed-jars-ear.list:
#WEbservices jaxrs-api-2.2.0.GA.jar resteasy-jaxrs-2.2.0.GA.jar resteasy-atom-provider-2.2.0.GA.jar resteasy-jaxb-provider-2.2.0.GA.jar resteasy-jettison-provider-2.2.0.GA.jar scannotation-1.0.3.jar slf4j-api.jar
deployed-jars-war.list:
#RestEasy jboss-seam-resteasy-2.2.0.GA.jar
2)web.xml:
<listener> <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> </listener> <servlet> <servlet-name>Resteasy</servlet-name> <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>com.myApp.webservice.MobileApplication</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>Resteasy</servlet-name> <url-pattern>/mobile/*</url-pattern> </servlet-mapping> <context-param> <param-name>resteasy.servlet.mapping.prefix</param-name> <param-value>mobile</param-value> </context-param>
3)com.myApp.webservice.MobileApplication:
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.core.Application;
public class MobileApplication extends Application{
private Set<Object> singletons = new HashSet();
private Set<Class<?>> empty = new HashSet();
public MobileApplication() {
// ADD YOUR RESTFUL RESOURCES HERE
this.singletons.add(new HelloWorld());
this.singletons.add(new TestWS());
this.singletons.add(new DivingLogRest());//DivingLog/{id}
}
public Set<Class<?>> getClasses()
{
return this.empty;
}
public Set<Object> getSingletons()
{
return this.singletons;
}
}
4) and service class itself:
@Name("divingLogRest")
@Path("divingLog")
@Scope(ScopeType.STATELESS)
public class DivingLogRest {
@In(create=true)
DivingLogHome divingLogHome;
@GET
@Path("{id}")
//@Produces({"application/xml"})
@Produces("text/plain")
public String getDivingLog(@PathParam("id") int id) {
//Logger Log log doesn't inject neither
System.out.println("getDivingLog called. id="+id);
System.out.println("divingLogHome:"+divingLogHome);
divingLogHome.setDivingLogId(id);
System.out.println("divingLogHome:"+divingLogHome);
divingLogHome.wire();
return divingLogHome.getInstance().getDescription();
}
the return on the console is
11:00:52,433 INFO [ServletContainerDispatcher] Deploying javax.ws.rs.core.Application: class com.myApp.webservice.MobileApplication 11:00:52,433 INFO [ServletContainerDispatcher] Adding singleton resource com.myApp.webservice.DivingLogRest from Application javax.ws.rs.core.Application 11:00:52,433 INFO [ServletContainerDispatcher] Adding singleton resource com.myApp.webservice.TestWS from Application javax.ws.rs.core.Application 11:00:52,448 INFO [ServletContainerDispatcher] Adding singleton resource com.myApp.webservice.HelloWorld from Application javax.ws.rs.core.Application 11:01:25,286 INFO [STDOUT] getDivingLog called. id=1 11:01:25,286 INFO [STDOUT] divingLogHome:null
Any suggestions will be appreciated! I'm stacked for a log time with this isue...