13 Replies Latest reply on Mar 27, 2006 6:18 AM by hi_feroz

    @EJB isn't working RC4

    lsalves

      I'm using EJB3 RC4.

      The container throws a naming exception when it try to inject RedeFacade EJB, saying that RedeFacadeBean was not bound.

      PS: this code worked with RC3.

      My session façade class:

      @Stateless
      public class AplicacaoFacadeBean implements AplicacaoFacade {
      
       @EJB RedeFacade redeFacade;


      RedeFacade interface:
      public interface RedeFacade {


      RedeFacadeBean class:
      @Stateless
      public class RedeFacadeBean implements RedeFacade {


      Exception:
      javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: RedeFacadeBean not bound]
       at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1052)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
       at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:69)




        • 1. Re: @EJB isn't working RC4
          ejb3workshop

          Have a look at the JMX console. The JNDI allows you to list your deployed components and their JNDI names. The default names have changed. Could you please post your client code as well as the complete stack trace.

          Alex
          ejb3workshop.com

          • 2. Re: @EJB isn't working RC4
            lsalves

            My cliente is a JSF managed bean. The lookup is working; I debug the code and see AplicacaoFacade instance. The exception throws when I call autenticarUsuario method.

            At JMX-Console I see the service "ear=jenius.ear,jar=jenius.jar,name=RedeFacadeBean,service=EJB3". It means that RedeFacadeBean EJB was deployed, doesn't it?

            Client:

            public String autenticar() throws Exception {
             InitialContext context = new InitialContext();
             AplicacaoFacade facade = (AplicacaoFacade) context.lookup( "jenius/AplicacaoFacadeBean/local" );
            
             try {
             // THROWS !!!
             Usuario usuario = facade.autenticarUsuario( login, senha );



            Stack trace:
            12:53:11,015 INFO [STDOUT] javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: RedeFacadeBean not bound]
            12:53:11,031 INFO [STDOUT] at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1052)
            12:53:11,031 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
            12:53:11,031 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
            12:53:11,031 INFO [STDOUT] at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:69)
            12:53:11,031 INFO [STDOUT] at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:61)
            12:53:11,125 INFO [STDOUT] at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:88)
            12:53:11,125 INFO [STDOUT] at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:48)
            12:53:11,125 INFO [STDOUT] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:51)
            12:53:11,125 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
            12:53:11,125 INFO [STDOUT] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
            12:53:11,125 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
            12:53:11,125 INFO [STDOUT] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
            12:53:11,125 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
            12:53:11,125 INFO [STDOUT] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
            12:53:11,125 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
            12:53:11,125 INFO [STDOUT] at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:178)
            12:53:11,125 INFO [STDOUT] at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:74)
            12:53:11,125 INFO [STDOUT] at $Proxy86.autenticarUsuario(Unknown Source)
            12:53:11,125 INFO [STDOUT] at br.com.b2brasil.jenius.web.aplicacao.bean.AplicacaoBean.autenticar(AplicacaoBean.java:94)
            12:53:11,125 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            12:53:11,140 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            12:53:11,140 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            12:53:11,140 INFO [STDOUT] at java.lang.reflect.Method.invoke(Unknown Source)
            12:53:11,140 INFO [STDOUT] at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
            12:53:11,140 INFO [STDOUT] at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
            12:53:11,140 INFO [STDOUT] at javax.faces.component.UICommand.broadcast(UICommand.java:106)
            12:53:11,140 INFO [STDOUT] at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
            12:53:11,140 INFO [STDOUT] at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
            12:53:11,140 INFO [STDOUT] at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
            12:53:11,140 INFO [STDOUT] at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
            12:53:11,140 INFO [STDOUT] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            12:53:11,140 INFO [STDOUT] at br.com.b2brasil.jenius.web.ExcecaoFilter.doFilter(ExcecaoFilter.java:35)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            12:53:11,140 INFO [STDOUT] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            12:53:11,140 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
            12:53:11,140 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
            12:53:11,140 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            12:53:11,140 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            12:53:11,140 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
            12:53:11,140 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
            12:53:11,140 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            12:53:11,140 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
            12:53:11,140 INFO [STDOUT] at java.lang.Thread.run(Unknown Source)
            12:53:11,140 INFO [STDOUT] Caused by: javax.naming.NameNotFoundException: RedeFacadeBean not bound
            12:53:11,140 INFO [STDOUT] at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
            12:53:11,140 INFO [STDOUT] at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
            12:53:11,140 INFO [STDOUT] at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
            12:53:11,140 INFO [STDOUT] at org.jnp.server.NamingServer.lookup(NamingServer.java:252)
            12:53:11,140 INFO [STDOUT] at org.jnp.server.NamingServer.lookup(NamingServer.java:255)
            12:53:11,140 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
            12:53:11,140 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
            12:53:11,140 INFO [STDOUT] at javax.naming.InitialContext.lookup(Unknown Source)
            12:53:11,140 INFO [STDOUT] at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1046)
            12:53:11,140 INFO [STDOUT] ... 52 more
            12:53:11,140 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
            javax.naming.NameNotFoundException: RedeFacadeBean not bound
             at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
             at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
             at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
             at org.jnp.server.NamingServer.lookup(NamingServer.java:252)
             at org.jnp.server.NamingServer.lookup(NamingServer.java:255)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
             at javax.naming.InitialContext.lookup(Unknown Source)
             at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1046)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
             at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
             at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:69)
             at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:61)
             at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:88)
             at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:48)
             at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:51)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
             at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:178)
             at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:74)
             at $Proxy86.autenticarUsuario(Unknown Source)
             at br.com.b2brasil.jenius.web.aplicacao.bean.AplicacaoBean.autenticar(AplicacaoBean.java:94)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
             at java.lang.reflect.Method.invoke(Unknown Source)
             at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
             at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
             at javax.faces.component.UICommand.broadcast(UICommand.java:106)
             at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
             at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
             at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
             at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at br.com.b2brasil.jenius.web.ExcecaoFilter.doFilter(ExcecaoFilter.java:35)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
             at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
             at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
             at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
             at java.lang.Thread.run(Unknown Source)



            • 3. Re: @EJB isn't working RC4
              ejb3workshop

              Have a look at the JMX Console. The service=JNDIView allows you to list the contence of the entire JNDI tree by invoking the java.lang.String list(). From there you should be able to see what name is used by the EJB.

              • 4. Re: @EJB isn't working RC4
                lsalves

                RedeFacadeBean isn't there...

                I saw the follow message at jboss inicialization log:

                --- MBeans waiting for other MBeans ---
                ObjectName: persistence.units:ear=jenius.ear.ear,jar=jenius.jar.jar,unitName=JeniusEntityManager
                 State: NOTYETINSTALLED
                 I Depend On:
                 jboss.jca:name=JeniusDS,service=DataSourceBinding
                 Depends On Me: jboss.j2ee:service=EJB3,ear=jenius.ear,jar=jenius.jar,name=RedeFacadeBean
                
                ObjectName: jboss.j2ee:service=EJB3,ear=jenius.ear,jar=jenius.jar,name=RedeFacadeBean
                 State: NOTYETINSTALLED
                 I Depend On:
                 persistence.units:ear=jenius.ear.ear,jar=jenius.jar.jar,unitName=JeniusEntityManager


                For me, it's saying that JeniusDS isn't deployed. But it is. I see it at JMX-Console and JNDIView.list(). And the state of this service is Started.

                • 5. Re: @EJB isn't working RC4
                  bill.burke

                  Can you look in

                  http://localhost:8080/jmx-console

                  and search for all mbeans with JeniusDS and tell me what the strings are?

                  Also, how do you deploy your application? Can you spec it out for me?

                  • 6. Re: @EJB isn't working RC4
                    lsalves

                    Mbeans with JeniusDS:

                    jboss.jca
                    # name=JeniusDS,service=ConnectionFactoryBinding
                    # name=JeniusDS,service=ManagedConnectionFactory
                    # name=JeniusDS,service=ManagedConnectionPool
                    # name=JeniusDS,service=TxCM

                    PS: I'm using a -ds.xml file to config the datasource and it was working with EJB RC3.

                    Deploy:

                    - I have a EAR (jenius.ear).
                    - Inside EAR there is one WAR (jenius.war) and one JAR (jenius.jar).
                    - Inside JAR there are Session beans and Entity beans. I also put persistence.xml in META-INF.

                    Follow application.xml:

                    <application xmlns="http://java.sun.com/xml/ns/j2ee"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
                     version="1.4">
                    
                     <display-name>B2Brasil - Jenius</display-name>
                    
                     <!-- Modulos Persistencia -->
                     <module>
                     <ejb>jenius.jar</ejb>
                     </module>
                    
                     <!-- Modulos Web -->
                     <module>
                     <web>
                     <web-uri>jenius.war</web-uri>
                     <context-root>/jenius</context-root>
                     </web>
                     </module>
                    
                    </application>


                    Follow persistence.xml:
                    <persistence>
                     <persistence-unit name="JeniusEntityManager">
                     <jta-data-source>java:/JeniusDS</jta-data-source>
                    
                     <properties>
                     <property name="hibernate.dialect" value="org.hibernate.dialect.FirebirdDialect" />
                     <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
                     </properties>
                     </persistence-unit>
                    </persistence>


                    • 7. Re: @EJB isn't working RC4
                      bill.burke

                      can you post your ds.xml file? Without the passwords of course!

                      • 8. Re: @EJB isn't working RC4
                        lsalves

                         

                        <connection-factories>
                        
                         <tx-connection-factory>
                         <adapter-display-name>Firebird Database Connector</adapter-display-name>
                         <rar-name>firebirdsql.rar</rar-name>
                         <connection-definition>javax.sql.DataSource</connection-definition>
                        
                         <jndi-name>JeniusDS</jndi-name>
                         <user-name>sysdba</user-name>
                         <password>masterkey</password>
                         <xa-transaction/>
                         <max-pool-size>20</max-pool-size>
                         <min-pool-size>3</min-pool-size>
                         <track-connection-by-tx>true</track-connection-by-tx>
                        
                         <config-property name="Database" type="java.lang.String">
                         localhost/3050:C:/workspace/projetos/bancodados/jenius.gdb
                         </config-property>
                         <config-property name="Encoding" type="java.lang.String">
                         ISO8859_1
                         </config-property>
                         </tx-connection-factory>
                        
                         <no-tx-connection-factory>
                         <adapter-display-name>Firebird Database Connector</adapter-display-name>
                         <rar-name>firebirdsql.rar</rar-name>
                         <connection-definition>javax.sql.DataSource</connection-definition>
                        
                         <jndi-name>JeniusNoTxDS</jndi-name>
                         <user-name>sysdba</user-name>
                         <password>masterkey</password>
                         <max-pool-size>20</max-pool-size>
                         <min-pool-size>0</min-pool-size>
                        
                         <config-property name="Database" type="java.lang.String">
                         localhost/3050:C:/workspace/projetos/bancodados/jenius.gdb
                         </config-property>
                         <config-property name="Encoding" type="java.lang.String">
                         ISO8859_1
                         </config-property>
                         </no-tx-connection-factory>
                        
                        </connection-factories>


                        • 9. Re: @EJB isn't working RC4
                          bill.burke

                          Ok, I'm gonna have to put out a patch for you. THe code assumes that you are using local-tx-datasource or xa-datasource.

                          • 10. Re: @EJB isn't working RC4
                            lsalves

                            Thanks.

                            How do I get the patch?

                            • 11. Re: @EJB isn't working RC4
                              bill.burke

                              I will put it on sourceforge.

                              • 12. Re: @EJB isn't working RC4
                                bill.burke

                                I'm gonna put a new release sometime tomorrow, Thursday. I fixed the problem (I think) and provided work around if I didn't.

                                • 13. Re: @EJB isn't working RC4
                                  hi_feroz

                                  hi,
                                  i have the same problem, where can i find the fix?

                                  tx.