9 Replies Latest reply on Nov 26, 2013 1:23 AM by prashamsjain

    Call EJB Jar from MBean inside sar

    ab_99

      I am trying to call an ejb method from inside the start() method of an mbean which is inside a sar.

      The depends tag has been placed inside the jboss-service.xml. But the lookup always fails - NameNotFoundException - env not bound.

       

      How do I lookup the ejb session bean from the mbean? Do I need additional configurations?

       

      --Anurag

        • 1. Re: Call EJB Jar from MBean inside sar
          jaikiran

          Can't say much without looking at the exception stacktrace and the configuration files.

          • 2. Re: Call EJB Jar from MBean inside sar
            ab_99

            The jboss-service.xml is defined as follows -

             

            <server>

              <mbean code="com.registration.Registration" name="registration.mbeans..com:service=Registration">

              <depends>jboss.j2ee:jndiName=com/ejb/configuration/ConfigurationLocal,service=EJB</depends>

              </mbean>

            </server>

             

            The jar containing the EJB and the SAR is deployed in one ear file.

            The start method of the mbean invokes a POJO method which in turn calls an EJB methof

             

            The stack trace -

             

            2011-06-08 10:22:31,756 ERROR [com.utility.adapter.Adapter] envLookUp

            javax.naming.NameNotFoundException: env not bound

                      at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)

                      at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)

                      at org.jnp.server.NamingServer.getObject(NamingServer.java:543)

                      at org.jnp.server.NamingServer.lookup(NamingServer.java:267)

                      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)

                      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:774)

                      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)

                      at javax.naming.InitialContext.lookup(InitialContext.java:392)

             

             

            Please let me know if you need any more information.

             

            --Anurag

            • 3. Re: Call EJB Jar from MBean inside sar
              ab_99

              Also, if I invoke the start() method of the MBean from the JMX console after the server has started; the lookup works without any exceptions.

              • 4. Re: Call EJB Jar from MBean inside sar
                jaikiran

                Anurag Bhatia wrote:

                 

                The jboss-service.xml is defined as follows -

                 

                <server>

                  <mbean code="com.registration.Registration" name="registration.mbeans..com:service=Registration">

                  <depends>jboss.j2ee:jndiName=com/ejb/configuration/ConfigurationLocal,service=EJB</depends>

                  </mbean>

                </server>

                That's an incorrect value in the <depends>. The value should be of the form:

                 

                <depends>jboss.j2ee:ear=YourEARName.ear,jar=YourEJBJarName.jar,name=YourBeanName,service=EJB3</depends>
                

                 

                If the bean is deployed in a standalone jar instead of a ear, then the JMX ObjectName will not the the ear=xyz key/value:

                 

                <depends>jboss.j2ee:jar=YourEJBJarName.jar,name=YourBeanName,service=EJB3</depends>
                
                • 5. Re: Call EJB Jar from MBean inside sar
                  jaikiran

                  After posting my previous reply, I now see that you have tagged your question with "JBoss AS 4.2". So what version of JBoss AS are you using and what version of EJB? EJB2.x or EJB3?

                  • 6. Re: Call EJB Jar from MBean inside sar
                    kkkppp

                    Bumping old thread

                     

                    I have tried to use this syntax in AS 7.1.1 Final and it seems doesn't work. Is this feature not supported anymore?

                     

                    Here is fragment of my jboss-service.xml

                     


                    <mbean code="com.supportwizard.seance.registry.SeanceRegistry" name="supportwizard:service=seanceregistry">
                      <depends>jboss.j2ee:jar=SWSeance-ejb.jar,name=SeanceE,service=EJB3</depends>

                     

                    In log I see:

                     

                    23:21:39,142 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.mbean.service.supportwizard:service=seanceregistry.createjboss.mbean.service.\"jboss.j2ee:jar=SWSeance-ejb.jar,name=SeanceE,service=EJB3\".createMissing[jboss.mbean.service.supportwizard:service=seanceregistry.createjboss.mbean.service.\"jboss.j2ee:jar=SWSeance-ejb.jar,name=SeanceE,service=EJB3\".create]","jboss.mbean.service.supportwizard:service=seanceregistry.startjboss.mbean.service.\"jboss.j2ee:jar=SWSeance-ejb.jar,name=SeanceE,service=EJB3\".startMissing[jboss.mbean.service.supportwizard:service=seanceregistry.startjboss.mbean.service.\"jboss.j2ee:jar=SWSeance-ejb.jar,name=SeanceE,service=EJB3\".start]"]}}}

                     

                    However bean was deployed 10 seconds earlier:

                     

                    23:21:29,251 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-15) JNDI bindings for session bean named SeanceE in deployment unit deployment "SWSeance-ejb.jar" are as follows:

                     

                        java:global/SWSeance-ejb/SeanceE!com.supportwizard.seance.interfaces.SeanceELocal

                        java:app/SWSeance-ejb/SeanceE!com.supportwizard.seance.interfaces.SeanceELocal

                    ...

                     

                    I looked at sources and cannot understand how it supposed to work. It looks like only optional-attribute counts:

                     

                    public class ParsedServiceDeploymentProcessor implements DeploymentUnitProcessor {

                    ...

                    final JBossServiceDependencyConfig[] dependencyConfigs = mBeanConfig.getDependencyConfigs();

                    if (dependencyConfigs != null) {

                         final Service<Object> createDestroyService = mBeanServices.getCreateDestroyService();

                         for (final JBossServiceDependencyConfig dependencyConfig : dependencyConfigs) {

                              final Injector<Object> injector = getInjector(dependencyConfig, mBeanClassHierarchy, createDestroyService);

                              mBeanServices.addDependency(dependencyConfig.getDependencyName(), injector);

                         }

                    }

                    ...

                    private static Injector<Object> getInjector(final JBossServiceDependencyConfig dependencyConfig, final List<ClassReflectionIndex<?>> mBeanClassHierarchy, final Service<Object> service) {

                         final String attrName = dependencyConfig.getOptionalAttributeName();

                         return attrName != null ? getPropertyInjector(attrName, mBeanClassHierarchy, service, Values.injectedValue()) : NullInjector.getInstance();

                    }

                    • 7. Re: Call EJB Jar from MBean inside sar
                      hmburgett

                      I'm having similar issues getting an mbean to depend on and use an ejb (both sar & ejb.jar deployed in the same ear).  Did you ever find an answer?

                      • 8. Re: Call EJB Jar from MBean inside sar
                        ab_99

                        Unfortunately, I did not. I had to modify my design.

                        • 9. Re: Call EJB Jar from MBean inside sar
                          prashamsjain

                          I'm having similar issue("JBAS014771: Services with missing/unavailable dependencies") getting an mbean to depend on and use an ejb (both sar & ejb.jar deployed in the same ear).
                          Did anyone found an answer?