13 Replies Latest reply on Feb 21, 2006 11:59 AM by cococ

    RC4, MBean/EJB dependencies

    klaus_erber

      Hello,

      I have a problem since RC4 with the use of EJBs (SLSBs) in MBeans.

      Example (working code in RC3):

      @Service (objectName="pistats:service=PIStatsManager")
      @Management(PIStatsManager.class)
      public class PIStatsManagerMBean implements PIStatsManager
      {
      ...
       @EJB AggregateServiceLocal aggregateService;
      ...
      }
      


      In RC4 I get a NamingException at deploy time.

      Wenn I add the following line to consider the dependency:

      @Depends("jboss.j2ee:ear=pistats.ear,jar=pistats.ejb3,name=AggregateService,service=EJB3")
      @EJB AggregateServiceLocal aggregateService;
      


      I get following (only wenn I restart JBoss):

      --- MBeans waiting for other MBeans ---
      ObjectName: jboss.j2ee:service=EJB3,ear=pistats.ear,jar=pistats.jar,name=PIStatsManagerMBean
       State: NOTYETINSTALLED
       I Depend On:
       jboss.j2ee:ear=pistats.ear,jar=pistats.ejb3,name=AggregateService,service=EJB3
      
      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss.j2ee:ear=pistats.ear,jar=pistats.ejb3,name=AggregateService,service=EJB3
       State: NOTYETINSTALLED
       Depends On Me:
       jboss.j2ee:service=EJB3,ear=pistats.ear,jar=pistats.jar,name=PIStatsManagerMBean
      


      After a hot deploy I get no message, but the MBean deployment don't work (I can't see it in the jmx-console)

      BTW the EJB is useable via JNDI-Lookup, when everything is deployed. But I want to use it in the create()-method of the MBean. This demands a correct deployment order.

      Can anybody help me? Is it a Bug?

      Klaus

        • 1. Re: RC4, MBean/EJB dependencies
          amwilliams

          I'm having the same problem. I've got a hunch this may be related to the JNDI lookup changes in RC4 and RC5, but I haven't had any luck. Any ideas?

          • 2. Re: RC4, MBean/EJB dependencies
            bill.burke

            You don't want to add the depends tag to the field if you are already specifying the @EJB injection. Add it to the class or within jboss.xml.

            Can you show me the error message *without* the @Depends tag added? "I got a NamingException" doesn't help me much.

            Thanks and apologies for your problems.

            • 3. Re: RC4, MBean/EJB dependencies
              amwilliams

              Here's what I've got going right now. For me, the error only seems to occur in the MBeans. Other parts of the app work fine when doing JNDI lookups with the new naming scheme.

              For what its worth, my app still is an EAR with a .EAR and .PAR archive inside it. Haven't made that change yet.

              I'll be glad to post some more code or test something if anyone has any ideas.

              @Service(objectName="chief:service=InvoiceFileService")
              @Management(InvoiceFileService.class)
              public class InvoiceFileServiceMBean implements InvoiceFileService {
              


              Here's most of exception at deploy time.
              2006-02-09 16:39:43,172 INFO [org.jboss.ejb3.JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=chief.ear,jar=business.ejb3,name=InvoiceFileServiceMBean with dependencies:
              
              2006-02-09 16:39:43,172 DEBUG [org.jboss.system.ServiceController] Creating service jboss.j2ee:service=EJB3,ear=chief.ear,jar=business.ejb3,name=InvoiceFileServiceMBean
              
              2006-02-09 16:39:43,172 DEBUG [org.jboss.system.ServiceController] adding depends in ServiceController.register: []
              
              2006-02-09 16:39:43,172 DEBUG [org.jboss.ejb3.ServiceDelegateWrapper] Creating jboss.j2ee:service=EJB3,ear=chief.ear,jar=business.ejb3,name=InvoiceFileServiceMBean
              
              2006-02-09 16:39:43,172 DEBUG [org.jboss.ejb3.ServiceDelegateWrapper] Created jboss.j2ee:service=EJB3,ear=chief.ear,jar=business.ejb3,name=InvoiceFileServiceMBean
              
              2006-02-09 16:39:43,172 DEBUG [org.jboss.system.ServiceController] Creating dependent components for: jboss.j2ee:service=EJB3,ear=chief.ear,jar=business.ejb3,name=InvoiceFileServiceMBean dependents are: []
              
              2006-02-09 16:39:43,172 DEBUG [org.jboss.system.ServiceController] starting service jboss.j2ee:service=EJB3,ear=chief.ear,jar=business.ejb3,name=InvoiceFileServiceMBean
              
              2006-02-09 16:39:43,172 DEBUG [org.jboss.ejb3.ServiceDelegateWrapper] Starting jboss.j2ee:service=EJB3,ear=chief.ear,jar=business.ejb3,name=InvoiceFileServiceMBean
              
              2006-02-09 16:39:43,282 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] Added url: file:/C:/jboss-4.0.3SP1-EJBRC5/server/all/tmp/aopdynclasses/ucl7891/?dynamic=true, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@6076f4{ url=file:/C:/jboss-4.0.3SP1-EJBRC5/server/all/tmp/deploy/tmp7890chief.ear ,addedOrder=48}
              
              2006-02-09 16:39:43,516 DEBUG [org.jboss.ejb3.tx.UserTransactionImpl] new UserTx: org.jboss.ejb3.tx.UserTransactionImpl@376cc3
              
              2006-02-09 16:39:43,578 DEBUG [org.jboss.ejb3.EJBContainer] binding enc: env/com.ntransit.chief.jmx.InvoiceFileServiceMBean/invoiceFileHistoryFinder to chief/InvoiceFileHistoryFinderBean/local
              
              2006-02-09 16:39:43,578 DEBUG [org.jboss.ejb3.EJBContainer] binding enc: env/com.ntransit.chief.jmx.InvoiceFileServiceMBean/pos to chief/POSPODFileParserBean/local
              
              2006-02-09 16:39:43,657 DEBUG [org.jboss.ejb3.security.JaccHelper] InvoiceFileServiceMBean has no @SecurityDomain - skipping JACC configuration
              
              2006-02-09 16:39:43,703 DEBUG [org.jboss.system.ServiceController] Creating service chief:service=InvoiceFileService
              
              2006-02-09 16:39:43,703 DEBUG [org.jboss.system.ServiceController] adding depends in ServiceController.register: []
              
              2006-02-09 16:39:43,703 INFO [STDOUT] javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: InvoiceFileHistoryFinderBean not bound]
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1052)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:69)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:61)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jboss.ejb3.service.ServiceContainer.injectDependencies(ServiceContainer.java:261)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jboss.ejb3.service.ServiceContainer.populateInvocation(ServiceContainer.java:231)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:167)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:142)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jboss.ejb3.service.ServiceMBeanDelegate.invoke(ServiceMBeanDelegate.java:166)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:960)
              
              2006-02-09 16:39:43,719 INFO [STDOUT] at $Proxy0.create(Unknown Source)
              


              2006-02-09 16:39:44,063 WARN [org.jboss.system.ServiceController] Problem creating service chief:service=InvoiceFileService
              
              java.lang.RuntimeException: Unable to inject jndi dependency: env/com.ntransit.chief.jmx.InvoiceFileServiceMBean/invoiceFileHistoryFinder into field com.ntransit.chief.session.InvoiceFileHistoryFinder com.ntransit.chief.jmx.InvoiceFileServiceMBean.invoiceFileHistoryFinder
              
               at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:74)
              
               at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:61)
              
               at org.jboss.ejb3.service.ServiceContainer.injectDependencies(ServiceContainer.java:261)
              
               at org.jboss.ejb3.service.ServiceContainer.populateInvocation(ServiceContainer.java:231)
              
               at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:167)
              
               at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:142)
              
               at org.jboss.ejb3.service.ServiceMBeanDelegate.invoke(ServiceMBeanDelegate.java:166)
              
               at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
              
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              
               at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:960)
              
               at $Proxy0.create(Unknown Source)
              
               at org.jboss.system.ServiceController.create(ServiceController.java:341)
              
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              
               at java.lang.reflect.Method.invoke(Method.java:585)
              
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
              
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
              
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
              
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
              
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
              
               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
              
               at $Proxy79.create(Unknown Source)
              


              Caused by: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: InvoiceFileHistoryFinderBean 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)
              
               ... 149 more
              
              Caused by: javax.naming.NameNotFoundException: InvoiceFileHistoryFinderBean 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(InitialContext.java:351)
              
               at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1046)
              
               ... 152 more
              


              • 4. Re: RC4, MBean/EJB dependencies
                amwilliams

                Sorry, here's the code snippet above with the annotation in question.

                @Service(objectName="chief:service=InvoiceFileService")
                @Management(InvoiceFileService.class)
                public class InvoiceFileServiceMBean implements InvoiceFileService {
                
                 @EJB InvoiceFileHistoryFinder invoiceFileHistoryFinder;
                


                • 5. Re: RC4, MBean/EJB dependencies
                  amwilliams

                  I was able to finally get this to work, but only after I added the @Depends annotation like Klaus did before. I'm not sure why my case works and his doesn't.

                  Anyway, here's the start of the MBean that now works.

                  @Service(objectName="chief:service=InvoiceFileService")
                  @Management(InvoiceFileService.class)
                  public class InvoiceFileServiceMBean implements InvoiceFileService {
                  @Depends("jboss.j2ee:ear=chief.ear,jar=business.ejb3,name=InvoiceFileHistoryFinderBean,service=EJB3")
                  @EJB InvoiceFileHistoryFinder invoiceFileHistoryFinder;
                  


                  I had to do something similar for all @EJB within each MBean in my project.

                  The error I received before this was that InvoiceFileService was not known. I did see where it was registering later in the deployment, so adding the @Depends annotation makes sense. However, this wasn't a problem in RC3 so I'm not sure what changed. All of these classes are in the same EAR (and EJB3 archive within that) so I'm not sure why the depolyment order matters all of the sudden.

                  I'd like to know if this is the way things must be done from now on or if there's a better way. I'm guessing the latter is true.

                  • 6. Re: RC4, MBean/EJB dependencies
                    klaus_erber

                    Thank you for your replies.

                    I have the same effect when I make a class level @Depends annotation.

                    Without @Depends I get the same Exceptions as amwilliams :


                    11:22:20,282 INFO [ScannerThread] [STDOUT] javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: local not bound]
                    11:22:20,282 INFO [ScannerThread] [STDOUT] at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1052)
                    11:22:20,282 INFO [ScannerThread] [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
                    ...
                    
                    ...
                    11:22:20,470 WARN [ScannerThread] [ServiceController] Problem creating service pistats:service=PIStatsManager
                    java.lang.RuntimeException: Unable to inject jndi dependency: env/de.spiegel.pistats.management.PIStatsManagerMBean/sampleService into field de.spiegel.pistats.management.SampleServiceLocal de.spiegel.pistats.management.PIStatsManagerMBean.sampleService
                     at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:74)
                     at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:61)
                     at org.jboss.ejb3.service.ServiceContainer.injectDependencies(ServiceContainer.java:261)
                    ...
                    




                    • 7. Re: RC4, MBean/EJB dependencies
                      bill.burke

                      If somebody could create a testcase on this and attach it to a JIRA task, that would be most helpful. We won't do another release for a couple of weeks, but this would speed things up.

                      Thanks

                      • 8. Re: RC4, MBean/EJB dependencies
                        klaus_erber

                        ok, I can reproduce it in a minimalistic implementation.

                        I will post a JIRA task with the testcase.

                        • 9. Re: RC4, MBean/EJB dependencies
                          klaus_erber

                          Uuh, sorry, that was a little bit overhasty. I have found a silly typo in my object names (the old ejb3-extention instead of the new .jar). The @Depends annotation works now for me.

                          Without @Depends I still get the NamingException, that is reproduceable. Is that the desired behavior? If not, I can post a JIRA task.

                          As amwilliams I don't like that way. The object names are not so handy to use (see above). And why are they required when everything is in the same deployment unit?

                          Thank you very much for your help.

                          • 10. Re: RC4, MBean/EJB dependencies
                            bill.burke

                            They *SHOULDN'T* be required which is why I'm asking for a reproducable test case in a JIRA task.

                            • 11. Re: RC4, MBean/EJB dependencies
                              cococ

                              I'm also experiencing this problem with RC5 and a patched 4.0.3 SP1. I am no longer getting the NamingException, yet now the MBean service isn't created nor started. Trying to invoke the create() from the jmx-console does nothing.

                              @Service
                              @Management(RouterManagement.class)
                              public class Router implements RouterManagement {
                               @Depends("jboss.j2ee:service=EJB3,ear=myEar.ear,jar=myJar.jar,name=FileManagerBean")
                               @EJB FileManager fm;
                              


                              The output from the console:

                              17:18:23,498 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=myEar.ear,jar=myJar.jar,name=FileManagerBean with dependencies:
                              17:18:23,498 INFO [JmxKernelAbstraction] persistence.units:ear= myEar.ear.ear,jar=myJar.jar.jar,unitName=mysql
                              
                              ...
                              
                              17:18:23,878 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=myEar.ear,jar=myJar.jar,name=Router with dependencies:
                              17:18:23,878 INFO [JmxKernelAbstraction] jboss.j2ee:service=EJB3,ear=myEar.ear,jar=myJar.jar,name=FileManagerBean
                              


                              It seems that when the @Service class has a member bean with a declared dependency, then this MBean service isn't created nor started. When I removed the member variable and re-started the MBean service was created and started. Is there something I'm missing?

                              Thanks.

                              • 12. Re: RC4, MBean/EJB dependencies
                                bdecoste

                                I've confirmed this problem and created a JIRA task EJBTHREE-447. I'm working on this now for RC6.

                                • 13. Re: RC4, MBean/EJB dependencies
                                  cococ

                                  Great, thanks a ton.