4 Replies Latest reply on Aug 15, 2006 5:31 PM by Kai Ruddies

    No (remote) JNDI binding for ejb in ear

    Kai Ruddies Newbie

      Hi,

      i changed the slsb example from the ejb3 trailblazer and got some problems. After adding a remote interface to class StatelessCalculator there are not longer JNDI bindings.

      Without the Remotecalculator interface i saw the JNDI Binding for the Bean and the local interface.

      I Use jboss-4.0.4.GA installed with option ejb3


      StatelessCalculator.java

      package ejb3trail.ejb;
      
      import javax.ejb.*;
      
      @Stateless
      // @LocalBinding (jndiBinding="EJB3Trail/slsb/Calculator")
      public class StatelessCalculator implements Calculator, RemoteCalculator
      {
       public double calculate(int start, int end, double growthrate, double saving)
       {
       double tmp = Math.pow(1. + growthrate / 12., 12. * (end - start) + 1);
       return saving * 12. * (tmp - 1) / growthrate;
       }
      
       public String getServerInfo()
       {
       return "This is the JBoss EJB 3.0 Trail Blazer";
       }
      
      }
      


      Calculator.java

      package ejb3trail.ejb;
      
      public interface Calculator
      {
       public double calculate(int start, int end, double growthrate, double saving);
      }
      


      RemoteCalculator.java

      package ejb3trail.ejb;
      
      public interface RemoteCalculator
      {
       public double calculate(int start, int end, double growthrate, double saving);
      
       public String getServerInfo();
      }
      


      ejb3trail.ear

      META-INF/
      META-INF/MANIFEST.MF
      avalon-framework-4.1.3.jar
      commons-logging-1.1.jar
      ejb3trail-ejb-0.0.1.jar
      jboss-annotations-ejb3-4.0.4.GA.jar
      jboss-ejb3x-4.0.4.GA.jar
      log4j-1.2.9.jar
      logkit-1.0.1.jar
      META-INF/application.xml
      META-INF/jboss-app.xml
      servlet-api-2.3.jar
      META-INF/maven/
      META-INF/maven/ejb3trail/
      META-INF/maven/ejb3trail/ejb3trail-ear/
      META-INF/maven/ejb3trail/ejb3trail-ear/pom.xml
      META-INF/maven/ejb3trail/ejb3trail-ear/pom.properties
      


      application.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
       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">
       <display-name>ejb3trail</display-name>
       <description>ejb3trail server</description>
      
       <module>
       <ejb>ejb3trail-ejb-0.0.1.jar</ejb>
       </module>
      
      </application>
      
      


      jboss-app.xml

      <!DOCTYPE jboss-app
       PUBLIC "-//JBoss//DTD J2EE Application 1.4//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd">
      <jboss-app>
       <loader-repository>
       ejb3trail:app=ejb3
       </loader-repository>
      </jboss-app>
      


      ejb3trail-ejb-0.0.1.jar

      META-INF/
      META-INF/MANIFEST.MF
      ejb3trail/
      ejb3trail/ejb/
      ejb3trail/ejb/Calculator.class
      ejb3trail/ejb/LocalRemoteCalculator.class
      ejb3trail/ejb/RemoteCalculator.class
      ejb3trail/ejb/StatelessCalculator.class
      META-INF/ejb-jar.xml
      META-INF/maven/
      META-INF/maven/ejb3trail/
      META-INF/maven/ejb3trail/ejb3trail-ejb/
      META-INF/maven/ejb3trail/ejb3trail-ejb/pom.xml
      META-INF/maven/ejb3trail/ejb3trail-ejb/pom.properties
      



      ejb-jar.xml

      <ejb-jar version="3.0">
      </ejb-jar>
      


      JBoss console

      22:27:15,359 INFO [Server] JBoss (MX MicroKernel) [4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)] Started i
      n 15s:922ms
      22:28:25,375 INFO [EARDeployer] Init J2EE application: file:/C:/jboss-4.0.4.GA/server/default/deploy/ejb3trail.ear
      22:28:27,093 INFO [Ejb3Deployment] EJB3 deployment time took: 734
      22:28:27,171 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=ejb3trail.ear,jar=ejb3trail-ejb-0.0.1.jar,nam
      e=LocalRemoteCalculator,service=EJB3 with dependencies:
      22:28:27,453 INFO [EJBContainer] STARTED EJB: ejb3trail.ejb.LocalRemoteCalculator ejbName: LocalRemoteCalculator
      22:28:27,453 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=ejb3trail.ear,jar=ejb3trail-ejb-0.0.1.jar,nam
      e=StatelessCalculator,service=EJB3 with dependencies:
      22:28:27,468 INFO [EJBContainer] STARTED EJB: ejb3trail.ejb.StatelessCalculator ejbName: StatelessCalculator
      


      jmx-console service=JNDIView shows

      java: Namespace
      
       +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
       +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
       +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
       +- comp (class: javax.naming.Context)
       +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
       +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- jaas (class: javax.naming.Context)
       | +- other (class: org.jboss.security.plugins.SecurityDomainContext)
       | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
       | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
       | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
       +- timedCacheFactory (class: javax.naming.Context)
      Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
       +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
       +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
       +- Mail (class: javax.mail.Session)
       +- comp.ejb3 (class: javax.naming.Context)
       | NonContext: null
       +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
       +- TransactionManager (class: org.jboss.tm.TxManager)
      
      
      Global JNDI Namespace
      
       +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
       +- EventDispatcher (class: org.jboss.ws.eventing.mgmt.DispatcherDelegate)
       +- UserTransactionSessionFactory (proxy: $Proxy42 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
       +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
       +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
       +- topic (class: org.jnp.interfaces.NamingContext)
       | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
       | +- testTopic (class: org.jboss.mq.SpyTopic)
       | +- securedTopic (class: org.jboss.mq.SpyTopic)
       +- queue (class: org.jnp.interfaces.NamingContext)
       | +- A (class: org.jboss.mq.SpyQueue)
       | +- testQueue (class: org.jboss.mq.SpyQueue)
       | +- ex (class: org.jboss.mq.SpyQueue)
       | +- DLQ (class: org.jboss.mq.SpyQueue)
       | +- D (class: org.jboss.mq.SpyQueue)
       | +- C (class: org.jboss.mq.SpyQueue)
       | +- B (class: org.jboss.mq.SpyQueue)
       +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
       +- jmx (class: org.jnp.interfaces.NamingContext)
       | +- invoker (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor (proxy: $Proxy36 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
       | +- rmi (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
       +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
      


      If deploy only the ejb.jar i see the JNDI Bindings

      ...
      +- EJB3Trail (class: org.jnp.interfaces.NamingContext)
       | +- LocalCalculator (proxy: $Proxy80 implements interface ejb3trail.ejb.Calculator,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
       | +- RemoteCalculator (proxy: $Proxy79 implements interface ejb3trail.ejb.RemoteCalculator,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
      ...
      



      What's wrong? Any ideas?

      Regards Kai

        • 1. Re: No (remote) JNDI binding for ejb in ear
          Kai Ruddies Newbie

          deploying the EJB3Trail.ear as it is shows following JNDIView

          +- EJB3Trail (class: org.jnp.interfaces.NamingContext)
           | +- TransCalculator (class: org.jnp.interfaces.NamingContext)
           | | +- local (proxy: $Proxy129 implements No ClassLoaders found for: trail.transaction.Calculator (no security manager: RMI class loader disabled))
           | +- SecureCalculator (class: org.jnp.interfaces.NamingContext)
           | | +- local (proxy: $Proxy122 implements No ClassLoaders found for: trail.security.Calculator (no security manager: RMI class loader disabled))
           | +- StatelessCalculator (class: org.jnp.interfaces.NamingContext)
           | | +- local (proxy: $Proxy126 implements No ClassLoaders found for: trail.slsb.Calculator (no security manager: RMI class loader disabled))
           | +- StatefulCalculator (class: org.jnp.interfaces.NamingContext)
           | | +- localStatefulProxyFactory (class: org.jboss.ejb3.stateful.StatefulLocalProxyFactory)
           | | +- local (class: java.lang.Object)
          


          after adding the remote interface RemoteCalculator to StatelessCalculator its not longer listed in the JNDIView

           +- EJB3Trail (class: org.jnp.interfaces.NamingContext)
           | +- TransCalculator (class: org.jnp.interfaces.NamingContext)
           | | +- local (proxy: $Proxy129 implements No ClassLoaders found for: trail.transaction.Calculator (no security manager: RMI class loader disabled))
           | +- SecureCalculator (class: org.jnp.interfaces.NamingContext)
           | | +- local (proxy: $Proxy122 implements No ClassLoaders found for: trail.security.Calculator (no security manager: RMI class loader disabled))
           | +- StatefulCalculator (class: org.jnp.interfaces.NamingContext)
           | | +- localStatefulProxyFactory (class: org.jboss.ejb3.stateful.StatefulLocalProxyFactory)
           | | +- local (class: java.lang.Object)
          


          What should i mind when im using remote interfaces?

          Does the message "(no security manager: RMI class loader disabled))" refer to my problem?



          • 2. Re: No (remote) JNDI binding for ejb in ear
            Kai Ruddies Newbie

            in another topic there is the same problem with ejb.jar packaged in an ear file:

            http://www.jboss.com/index.html?module=bb&op=viewtopic&t=86420

            is there a general problem with packaged ejb.jar's in an ear file in combination with remote interfaces?

            • 3. Re: No (remote) JNDI binding for ejb in ear
              Kai Ruddies Newbie

              I found another exciting thing.

              I created 3 different calculator beans

              - LocalStatelessCalculator
              -> implements only the local interface Calculator
              - RemoteStatelessCalculator
              -> implements only the remote interface RemoteCalculator
              - StatelessCalculator
              -> implements both interfaces

              the JNDIView shows the follwing:

              +- ejb3trail (class: org.jnp.interfaces.NamingContext)
               | +- RemoteStatelessCalculator (class: org.jnp.interfaces.NamingContext)
               | | +- local (proxy: $Proxy64 implements No ClassLoaders found for: ejb3trail.ejb.RemoteCalculator (no security manager: RMI class loader disabled))
               | +- LocalStatelessCalculator (class: org.jnp.interfaces.NamingContext)
               | | +- local (proxy: $Proxy62 implements No ClassLoaders found for: ejb3trail.ejb.Calculator (no security manager: RMI class loader disabled))
              


              The StatelessCalculator Bean which implements both interfaces is not listend in the JNDIView.

              The LocalStatelessCalculator is listed correct.

              The RemoteStatelessCalculator is listed erroneous as local.

              Maybe this is the reason, why i didn't see any JNDIView entries if my Bean implements both interfaces. Probably it causes a conflict because 2 interfaces shall bound as local.

              If i deploy the single ejb.jar containing the same beans, everything is fine:

               +- LocalStatelessCalculator (class: org.jnp.interfaces.NamingContext)
               | +- local (proxy: $Proxy62 implements interface ejb3trail.ejb.Calculator,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
               +- RemoteStatelessCalculator (class: org.jnp.interfaces.NamingContext)
               | +- remote (proxy: $Proxy64 implements interface ejb3trail.ejb.RemoteCalculator,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
               +- StatelessCalculator (class: org.jnp.interfaces.NamingContext)
               | +- local (proxy: $Proxy62 implements interface ejb3trail.ejb.Calculator,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
               | +- remote (proxy: $Proxy64 implements interface ejb3trail.ejb.RemoteCalculator,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
              


              • 4. Re: No (remote) JNDI binding for ejb in ear
                Kai Ruddies Newbie

                Problem solved.

                Maven2 copied the dependencies of my ejb project into the ear-file

                ...
                jboss-annotations-ejb3-4.0.4.GA.jar
                jboss-ejb3x-4.0.4.GA.jar
                ...

                Now i marked the dependencies with

                <scope>provided</scope>


                so that they're not longer included and it works :)