ejb - injected singleton into stateless bean is null -
i have singleton ejb i'm trying inject stateless bean, that's ws endpoint (jersey).
the injected singleton null.
the project packed war, deployed wildfly 9.
i have beans.xml placed in web-inf.
the web-app version in web.xml 3.0:
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <context-param> <param-name>resteasy.scan</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>resteasy.scan.providers</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>resteasy.scan.resources</param-name> <param-value>false</param-value> </context-param> </web-app> session bean:
@localbean @stateless @path(userrestservice.resource_path) public class userrestservice { public static final string resource_path = "user"; @ejb private singletonejb singleton; ... @get @path("/test") public response test() { if(singleton==null) { system.out.println("singleton null"); } return response.ok().build(); } singleton:
@startup @localbean @singleton public class singletonejb { public singletonejb() { system.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>> constructor"); } in wildfly log can see jndi names both beans:
16:57:30,176 info [org.jboss.as.ejb3.deployment.processors.ejbjndibindingsdeploymentunitprocessor] (msc service thread1-4) jndi bindings session bean named userrestservice in deployment unit deployment "rest.war" follows: java:global/rest/userrestservice!com.test.rest.userrestservice java:app/rest/userrestservice!com.test.rest.userrestservice java:module/userrestservice!com.test.rest.userrestservice java:global/rest/userrestservice java:app/rest/userrestservice java:module/userrestservice 16:57:30,176 info org.jboss.as.ejb3.deployment.processors.ejbjndibindingsdeploymentunitprocessor](msc service thread 1-4) jndi bindings session bean named singletonejb in deployment unit deployment "rest.war" follows: java:global/rest/singletonejb!com.test.rest.singletons.singletonejb java:app/rest/singletonejb!com.test.rest.singletons.singletonejb java:module/singletonejb!com.test.rest.singletons.singletonejb java:global/rest/singletonejb java:app/rest/singletonejb java:module/singletonejb and can see constructor singleton run. singleton not implement interfaces annotated @localbean
i've read countless posts over, have looked @ this example yet haven't figured out...
le: added eclipse importable simplified demo here
Comments
Post a Comment