9 Replies Latest reply on Feb 10, 2011 8:40 AM by Gustavo Walker

    @EJB Injection

    Jens Mander Newbie

      Hi,

       

      I deployed a EJB-Project with the following structure:

       

      src/MyBeanRemote.class

      src/MyBeanLocal.class

      src/MyBean.class

       

      and

       

      @Stateless
      @Remote(MyBeanRemote.class)
      @Local(MyBeanLocal.class)
      public class MyBean implements MyBeanRemote, MyBeanLocal {
      
          @PersistenceContext
          EntityManager em;
      
          /**
           * Default constructor.
           */
          public MyBean() {
          }
      ....
      

       

      Now I'd like to inject this Bean in another deployed WEBSERVICE. I tried this one:

       

       

      @SOAPBinding(style = Style.RPC)
      @WebService(serviceName = "MyService", portName = "MyServicePort", wsdlLocation = "/WEB-INF/wsdl/MyService.wsdl")
      public class MyServiceImpl implements MyService {
      
          @EJB
          MyBean bean;
      ...
      }
      

       

      Unfortunately I receive the following Exception when I try to invoke a method of the webservice:

       

      Caused by: org.jboss.wsf.common.injection.InjectionException: Cannot inject field annotated with @EJB annotation: de.hd.bean.MyBean de.hd.services.MyServiceImpl.psr

       

      Is there a general problem with injections and webservices?

       

      EDIT: Let me say that a simple JNDI-Lookup like that:

       

       

      Context ctx = new InitialContext();
              MyBeanRemote psr = (MyBeanRemote) ctx
                      .lookup("MyBean/remote");
      

       

      works fine, so it drives me crazy. I thought that the EJB-Annotation nearly the same. Am I wrong?

        • 1. Re: @EJB Injection
          Daniel Cullender Newbie

          could you try @EJB(mappedName="MyBean/remote") whereby you explicitly use the JNDI name ...

          • 2. Re: @EJB Injection
            Daniel Cullender Newbie

            also, could you please make sure debugging is enabled and publish a more comprehensive stack trace with the debug messages. Thanks

            • 3. Re: @EJB Injection
              Richard Opalka Master

              Which JBossWS and JBossAS are you using?

              • 4. Re: @EJB Injection
                Jens Mander Newbie

                Good morning,

                 

                first of all thanks for your replies. I'am using JBossAS 5.1 and JBossWS-CXF-3.2.2.GA and I tried using the annotation @EJB(mappedName="MyBean/remote") like Daniel suggested. The deployment works fine, but when I try to use a service-method the following exception occur:

                 

                 

                08:26:45,500 ERROR [InjectionException] Cannot inject field annotated with @EJB annotation: de.hd.bean.MyBean de.hd.myservice.MyServiceImpl.psr
                org.jboss.ejb3.common.resolvers.spi.UnresolvableReferenceException: Could not resolve reference [EJB Reference: beanInterface 'de.hd.bean.MyBean', beanName '', mappedName 'MyBean/remote'] for DeploymentUnit AbstractVFSDeploymentContext@18839050{vfszip:/C:/Entwicklung/jboss-5.1.0.GA/server/default/deploy/MyService.war/}
                    at org.jboss.ejb3.common.resolvers.plugins.FirstMatchEjbReferenceResolver.resolveEjb(FirstMatchEjbReferenceResolver.java:73)
                    at org.jboss.webservices.integration.injection.EJBBeanReferenceResolver.resolveField(EJBBeanReferenceResolver.java:88)
                    at org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver.resolve(AbstractReferenceResolver.java:80)
                    at org.jboss.wsf.common.injection.InjectionHelper.injectEJBAnnotatedAccessibleObjects(InjectionHelper.java:361)
                    at org.jboss.wsf.common.injection.InjectionHelper.injectResources(InjectionHelper.java:111)
                    at org.jboss.wsf.common.invocation.InvocationHandlerJAXWS.onEndpointInstantiated(InvocationHandlerJAXWS.java:75)
                    at org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE.getTargetBean(AbstractInvocationHandlerJSE.java:81)
                    at org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:119)
                    at org.jboss.wsf.stack.cxf.AbstractInvoker._invokeInternal(AbstractInvoker.java:154)
                    at org.jboss.wsf.stack.cxf.AbstractInvoker.invoke(AbstractInvoker.java:104)
                    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
                    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
                    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
                    at java.util.concurrent.FutureTask.run(Unknown Source)
                    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
                    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
                    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
                    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109)
                    at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98)
                    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:394)
                    at org.jboss.wsf.stack.cxf.ServletControllerExt.invoke(ServletControllerExt.java:175)
                    at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:61)
                    at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:194)
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
                    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                    at java.lang.Thread.run(Unknown Source)
                08:26:45,500 ERROR [InvocationHandlerJAXWS] Method invocation failed with exception: Cannot create endpoint instance: 
                java.lang.IllegalStateException: Cannot create endpoint instance: 
                    at org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE.getTargetBean(AbstractInvocationHandlerJSE.java:85)
                    at org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:119)
                    at org.jboss.wsf.stack.cxf.AbstractInvoker._invokeInternal(AbstractInvoker.java:154)
                    at org.jboss.wsf.stack.cxf.AbstractInvoker.invoke(AbstractInvoker.java:104)
                    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
                    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
                    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
                    at java.util.concurrent.FutureTask.run(Unknown Source)
                    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
                    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
                    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
                    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109)
                    at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98)
                    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:394)
                    at org.jboss.wsf.stack.cxf.ServletControllerExt.invoke(ServletControllerExt.java:175)
                    at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:61)
                    at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:194)
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
                    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                    at java.lang.Thread.run(Unknown Source)
                Caused by: org.jboss.wsf.common.injection.InjectionException: Cannot inject field annotated with @EJB annotation: de.hd.bean.MyBean de.hd.produktservice.MyServiceImpl.psr
                    at org.jboss.wsf.common.injection.InjectionException.rethrow(InjectionException.java:106)
                    at org.jboss.wsf.common.injection.InjectionHelper.injectEJBAnnotatedAccessibleObjects(InjectionHelper.java:367)
                    at org.jboss.wsf.common.injection.InjectionHelper.injectResources(InjectionHelper.java:111)
                    at org.jboss.wsf.common.invocation.InvocationHandlerJAXWS.onEndpointInstantiated(InvocationHandlerJAXWS.java:75)
                    at org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE.getTargetBean(AbstractInvocationHandlerJSE.java:81)
                    ... 41 more
                Caused by: org.jboss.ejb3.common.resolvers.spi.UnresolvableReferenceException: Could not resolve reference [EJB Reference: beanInterface 'de.hd.bean.MyBean', beanName '', mappedName 'MyBean/remote'] for DeploymentUnit AbstractVFSDeploymentContext@18839050{vfszip:/C:/Entwicklung/jboss-5.1.0.GA/server/default/deploy/MyService.war/}
                    at org.jboss.ejb3.common.resolvers.plugins.FirstMatchEjbReferenceResolver.resolveEjb(FirstMatchEjbReferenceResolver.java:73)
                    at org.jboss.webservices.integration.injection.EJBBeanReferenceResolver.resolveField(EJBBeanReferenceResolver.java:88)
                    at org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver.resolve(AbstractReferenceResolver.java:80)
                    at org.jboss.wsf.common.injection.InjectionHelper.injectEJBAnnotatedAccessibleObjects(InjectionHelper.java:361)
                    ... 44 more
                08:26:45,531 WARNING [PhaseInterceptorChain] Application has thrown exception, unwinding now
                org.apache.cxf.interceptor.Fault: Cannot create endpoint instance: 
                    at org.jboss.wsf.stack.cxf.AbstractInvoker.createFault(AbstractInvoker.java:209)
                    at org.jboss.wsf.stack.cxf.AbstractInvoker._invokeInternal(AbstractInvoker.java:180)
                    at org.jboss.wsf.stack.cxf.AbstractInvoker.invoke(AbstractInvoker.java:104)
                    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
                    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
                    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
                    at java.util.concurrent.FutureTask.run(Unknown Source)
                    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
                    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
                    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
                    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109)
                    at org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98)
                    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:394)
                    at org.jboss.wsf.stack.cxf.ServletControllerExt.invoke(ServletControllerExt.java:175)
                    at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:61)
                    at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:194)
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
                    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
                    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                    at java.lang.Thread.run(Unknown Source)
                Caused by: java.lang.IllegalStateException: Cannot create endpoint instance: 
                    at org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE.getTargetBean(AbstractInvocationHandlerJSE.java:85)
                    at org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:119)
                    at org.jboss.wsf.stack.cxf.AbstractInvoker._invokeInternal(AbstractInvoker.java:154)
                    ... 39 more
                Caused by: org.jboss.wsf.common.injection.InjectionException: Cannot inject field annotated with @EJB annotation: de.hd.bean.MyBean de.hd.produktservice.MyServiceImpl.psr
                    at org.jboss.wsf.common.injection.InjectionException.rethrow(InjectionException.java:106)
                    at org.jboss.wsf.common.injection.InjectionHelper.injectEJBAnnotatedAccessibleObjects(InjectionHelper.java:367)
                    at org.jboss.wsf.common.injection.InjectionHelper.injectResources(InjectionHelper.java:111)
                    at org.jboss.wsf.common.invocation.InvocationHandlerJAXWS.onEndpointInstantiated(InvocationHandlerJAXWS.java:75)
                    at org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE.getTargetBean(AbstractInvocationHandlerJSE.java:81)
                    ... 41 more
                Caused by: org.jboss.ejb3.common.resolvers.spi.UnresolvableReferenceException: Could not resolve reference [EJB Reference: beanInterface 'de.hd.bean.MyBean', beanName '', mappedName 'MyBean/remote'] for DeploymentUnit AbstractVFSDeploymentContext@18839050{vfszip:/C:/Entwicklung/jboss-5.1.0.GA/server/default/deploy/MyService.war/}
                    at org.jboss.ejb3.common.resolvers.plugins.FirstMatchEjbReferenceResolver.resolveEjb(FirstMatchEjbReferenceResolver.java:73)
                    at org.jboss.webservices.integration.injection.EJBBeanReferenceResolver.resolveField(EJBBeanReferenceResolver.java:88)
                    at org.jboss.wsf.common.injection.resolvers.AbstractReferenceResolver.resolve(AbstractReferenceResolver.java:80)
                    at org.jboss.wsf.common.injection.InjectionHelper.injectEJBAnnotatedAccessibleObjects(InjectionHelper.java:361)
                    ... 44 more
                
                

                 

                 

                Hopefully that brings a bit more lights into the darkness

                Thanks a lot.

                 

                Jens

                • 5. Re: @EJB Injection
                  Richard Opalka Master

                  @EJB injection isn't supported for CXF and Metro integrations.

                  For more info see https://jira.jboss.org/jira/browse/JBWS-2596

                  • 6. Re: @EJB Injection
                    Jens Mander Newbie

                    Hi,

                     

                    thanks a lot. So are there any workarounds? I tried to use the natives but that doesn't solve the problem. I receive exactly the same exceptions like before

                    Does that mean I can't use injections in my webservices if I am using the JbossAS?

                    • 7. Re: @EJB Injection
                      Richard Opalka Master

                      Please, create new issue here

                      https://jira.jboss.org/jira/browse/JBWS

                      and provide simple test case to reproduce your problem.

                      I'll have a look

                      • 8. Re: @EJB Injection
                        Jens Mander Newbie

                        Hi,

                         

                        I created the issue https://jira.jboss.org/jira/browse/JBWS-3026

                        Thanks a lot again.

                         

                        Jens

                        • 9. Re: @EJB Injection
                          Gustavo Walker Newbie

                          Hi,

                           

                          I had the same problem, but I found problem and now work's fine.

                          My problem was in the web.xml and sun-web.xml, these files were configured to run on java 5 and java 6 does not.

                           

                          Code wrong web.xml (Note version 2.5)

                          <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                          xmlns="http://java.sun.com/xml/ns/javaee" 
                          xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
                          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                          http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
                          

                           

                          Code correct web.xml (Note version 3.0)

                          <web-app version="3.0" 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 
                          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
                          

                           

                          Code wrong sun-web.xml (Note again version 2.5)

                          <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" 
                          "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
                          

                           

                          Code correct sun-web.xml

                          <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 3.0//EN" 
                          "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
                          

                           

                          Eclipse with jboss 5 generate this files to servlet's 2.5 on deploy the server don't process @EJB annotation.

                          To use @EJB annotation your server compatibilit with servlet 3.0. On jboss 6 it's work's fine (I don't run in jboss 5).

                           

                           

                          Sorry my english.