-
1. Re: Inject EJB problem in web service method !!
boby Sep 26, 2006 9:28 AM (in response to boby)I forgot to specify that I use jboss-4.0.4.GA with jbossws by default.
And my code :@Stateless @SecurityDomain("Protected-Web-Services") @Interceptors( { LoggerInterceptor.class, ConnectionInterceptor.class }) @RemoteBinding(jndiBinding = "TestSession") @WebService(name = "Test") public class TestSessionBean implements TestSession { private static Logger logger = Logger.getLogger(TestSessionBean.class.getSimpleName()); @EJB ResourcesDAOSession resourcesDAOSession; @RolesAllowed("ws_resources") @WebMethod public Resource echo(int idResource) { logger.info("DAO : " + this.resourcesDAOSession); Resource resource = this.resourcesDAOSession.getResource(idResource); logger.info("resource : " + resource); return resource; }
-
2. Re: Inject EJB problem in web service method !!
c_eric_ray Sep 28, 2006 3:51 PM (in response to boby)if you are using a java client point it to the TestSessionBean?wsdl and it should work. this way you get the bean isntantiated in the EJB container. if you don't reference the web service as a bean then you loose the EJB context and thus you loose the EJB supported injection.
Same thing happens if you are injecting a @Resource or @PersistenceContext. it's the container that understands the annotations. so if the object is created in the wrong container the annotations are ignored.
i don't understand the details of how this works, but i do know that the container is very important and i'm sure the jboss web service container doesn't undestand @EJB, but the EJB container does. -
3. Re: Inject EJB problem in web service method !!
boby Sep 29, 2006 5:24 AM (in response to boby)Thanks for the answer.
It is that I thought. The containers are different. There are the web container and the EJB container, because when I use an EJB client, the @EJB works, whereas with a web service client does not work.
I have the same problem when I want to use the security annotation with web service annotation. The context is not propagated, whereas with Axis Web service works.
I use HTTP Basic authentification, then a file descriptor jboss-web.xml for the propagation context. However I would like use the jbossws to simplify the development and to avoid a layer Axis web service (1.4) supplementary.
It is the most important problem. I read in the Wiki :
http://labs.jboss.com/portal/jbossws/user-guide/en/html/secure-ejb.html
but it does not treat with annotation EJB3.
So anyone knows how to resolve this problem, it will be great !!!
Regards -
4. Re: Inject EJB problem in web service method !!
boby Sep 29, 2006 8:40 AM (in response to boby)I installed the last version of jbossws and now that works.
I have the annotation authentification with the context propagation.@WebService(name = "EndpointInterface") @SOAPBinding(style = SOAPBinding.Style.RPC) @PortComponent(authMethod = "BASIC", transportGuarantee = "NONE") @Stateless @SecurityDomain("Protected-Web-Services") @Interceptors( { LoggerInterceptor.class, ConnectionInterceptor.class }) @RemoteBinding(jndiBinding = "TestSession") public class TestSessionBean implements TestSession { code }