5 Replies Latest reply on Oct 15, 2008 5:23 PM by ericw78

    EJB3 call EJB2

    ericw78

      I try to call an ejb2 from an ejb3.
      It works fine when I fisrt start Jboss and then hot deploy my ejb3
      But I have an error when my jboss first start with ejb3

      Here is my ejb3 code :

      @Stateless(name="ejb/Eproc")
      public class EprocBean implements Eproc {
      
       @EJB(mappedName="ejb/xx/AdminLocal") private AdminLocalHome adminLocalHome;
       private AdminLocal ejbAdmin;
      
       @PostConstruct
       public void initialiserEProcBean() {
      
       ejbAdmin = adminLocalHome.create();
       }
      }

      AdminLocalHome is my ejb2 and is packaging in a different jar (AdminLocalHome => EJB2.jar and EprocBean => Eproc.jar)

      I am using JBOSS 4.2.2 GA

      Here is my error when jboss start :
      13:18:06,124 WARN [Ejb3DescriptorHandler.getContainers(300)] Descriptor based bean has no ejb-class defined: Eproc
      13:18:06,171 WARN [ServiceController.start(424)] Problem starting service jboss.j2ee:service=EJB3,module=EprocEjb.jar
      java.lang.NoClassDefFoundError: Lcom/xx/interfaces/AdminLocalHome;
      at java.lang.Class.getDeclaredFields0(Native Method)
      at java.lang.Class.privateGetDeclaredFields(Class.java:2259)
      at java.lang.Class.getDeclaredFields(Class.java:1715)
      at org.jboss.injection.InjectionUtil.processFieldAnnotations(InjectionUtil.java:131)
      at org.jboss.injection.InjectionUtil.processAnnotations(InjectionUtil.java:174)
      at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:358)
      at org.jboss.ejb3.SessionContainer.processMetadata(SessionContainer.java:140)
      at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:292)
      at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:356)
      at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
      at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
      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:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      ...
      13:18:06,486 INFO [EJB3Deployer.start(513)] Deployed: file:/C:/Dev/xx2/jboss-4.2.2.GA/server/default/deploy/EprocEjb.jar
      13:18:07,540 INFO [EjbModule.createService(341)] Deploying Mail
      13:18:07,603 INFO [EjbModule.createService(341)] Deploying CommandeFacade
      13:18:07,619 INFO [EjbModule.createService(341)] Deploying Stats
      13:18:07,635 INFO [EjbModule.createService(341)] Deploying Organisation
      13:18:07,635 INFO [EjbModule.createService(341)] Deploying Ventilation
      13:18:07,650 INFO [EjbModule.createService(341)] Deploying PlaceDeMarche
      13:18:07,666 INFO [EjbModule.createService(341)] Deploying Integration
      13:18:07,682 INFO [EjbModule.createService(341)] Deploying CommandeTransaction
      13:18:07,682 INFO [EjbModule.createService(341)] Deploying Budget
      13:18:07,713 INFO [EjbModule.createService(341)] Deploying MarquesReferences
      13:18:07,729 INFO [EjbModule.createService(341)] Deploying AffichageFacade
      13:18:07,760 INFO [EjbModule.createService(341)] Deploying Exploitation
      13:18:07,776 INFO [EjbModule.createService(341)] Deploying Langue
      13:18:07,792 INFO [EjbModule.createService(341)] Deploying Utilisateur
      13:18:07,808 INFO [EjbModule.createService(341)] Deploying Site
      13:18:07,823 INFO [EjbModule.createService(341)] Deploying Admin
      13:18:07,823 INFO [EjbModule.createService(341)] Deploying Batch
      13:18:07,839 INFO [EjbModule.createService(341)] Deploying CommandeFacture
      13:18:08,358 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Mail' to jndi 'ejb/xx/MailLocal'
      13:18:08,390 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Mail' to jndi 'ejb/xx/Mail'
      13:18:08,437 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'CommandeFacade' to jndi 'ejb/xx/CommandeFacadeLocal'
      13:18:08,469 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'CommandeFacade' to jndi 'ejb/xx/CommandeFacade'
      13:18:08,484 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Stats' to jndi 'ejb/xx/StatsLocal'
      13:18:08,500 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Stats' to jndi 'ejb/xx/Stats'
      13:18:08,516 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Organisation' to jndi 'ejb/xx/OrganisationLocal'
      13:18:08,532 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Organisation' to jndi 'ejb/xx/Organisation'
      13:18:08,547 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Ventilation' to jndi 'ejb/xx/VentilationLocal'
      13:18:08,563 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Ventilation' to jndi 'ejb/xx/Ventilation'
      13:18:08,610 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'PlaceDeMarche' to jndi 'ejb/xx/PlaceDeMarcheLocal'
      13:18:08,626 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'PlaceDeMarche' to jndi 'ejb/xx/PlaceDeMarche'
      13:18:08,642 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Integration' to jndi 'ejb/xx/IntegrationLocal'
      13:18:08,657 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Integration' to jndi 'ejb/xx/Integration'
      13:18:08,673 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'CommandeTransaction' to jndi 'ejb/xx/CommandeTransactionLocal'
      13:18:08,689 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'CommandeTransaction' to jndi 'ejb/xx/CommandeTransaction'
      13:18:08,705 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Budget' to jndi 'ejb/xx/BudgetLocal'
      13:18:08,736 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Budget' to jndi 'ejb/xx/Budget'
      13:18:08,768 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'MarquesReferences' to jndi 'ejb/xx/MarquesReferencesLocal'
      13:18:08,799 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'MarquesReferences' to jndi 'ejb/xx/MarquesReferences'
      13:18:08,831 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'AffichageFacade' to jndi 'ejb/xx/AffichageFacadeLocal'
      13:18:08,878 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'AffichageFacade' to jndi 'ejb/xx/AffichageFacade'
      13:18:08,909 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Exploitation' to jndi 'ejb/xx/ExploitationLocal'
      13:18:08,925 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Exploitation' to jndi 'ejb/xx/Exploitation'
      13:18:08,941 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Langue' to jndi 'ejb/xx/LangueLocal'
      13:18:08,956 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Langue' to jndi 'ejb/xx/Langue'
      13:18:09,004 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Utilisateur' to jndi 'ejb/xx/UtilisateurLocal'
      13:18:09,035 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Utilisateur' to jndi 'ejb/xx/Utilisateur'
      13:18:09,051 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Site' to jndi 'ejb/xx/Site'
      13:18:09,051 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Site' to jndi 'ejb/xx/Site'
      13:18:09,098 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Admin' to jndi 'ejb/xx/AdminLocal'
      13:18:09,177 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Admin' to jndi 'ejb/xx/Admin'
      13:18:09,192 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'Batch' to jndi 'ejb/xx/BatchLocal'
      13:18:09,224 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'Batch' to jndi 'ejb/xx/Batch'
      13:18:09,255 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'CommandeFacture' to jndi 'ejb/xx/CommandeFactureLocal'
      13:18:09,303 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'CommandeFacture' to jndi 'ejb/xx/CommandeFacture'
      13:18:09,303 INFO [EJBDeployer.start(664)] Deployed: file:/C:/Dev/xx2/jboss-4.2.2.GA/server/default/deploy/xxEjb.jar
      13:18:09,633 INFO [EjbModule.createService(341)] Deploying SIProxy
      13:18:09,680 INFO [BaseLocalProxyFactory.start(188)] Bound EJB LocalHome 'SIProxy' to jndi 'ejb/xx/SIProxyLocal'
      13:18:09,696 INFO [ProxyFactory.rebindHomeProxy(493)] Bound EJB Home 'SIProxy' to jndi 'ejb/xx/SIProxy'
      13:18:09,696 INFO [EJBDeployer.start(664)] Deployed: file:/C:/Dev/xx2/jboss-4.2.2.GA/server/default/deploy/SIProxy.jar
      13:18:09,759 INFO [TomcatDeployer.performDeployInternal(127)] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
      13:18:09,979 ERROR [URLDeploymentScanner.scan(660)] Incomplete Deployment listing:

      --- MBeans waiting for other MBeans ---
      ObjectName: jboss.j2ee:service=EJB3,module=EprocEjb.jar
      State: FAILED
      Reason: java.lang.NoClassDefFoundError: Lcom/xx/interfaces/AdminLocalHome;

      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss.j2ee:service=EJB3,module=EprocEjb.jar
      State: FAILED
      Reason: java.lang.NoClassDefFoundError: Lcom/xx/interfaces/AdminLocalHome;


      13:18:10,137 INFO [Http11Protocol.start(209)] DÚmarrage de Coyote HTTP/1.1 sur http-127.0.0.1-8080
      13:18:10,168 INFO [AjpProtocol.start(193)] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
      13:18:10,184 INFO [Server.doStart(504)] JBoss (MX MicroKernel) [4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)] Started in 27s:177ms

      It look like when my ejb3 start, jboss has not yet loaded interfaces classes which are in ejb2.jar.
      I should explain why "java.lang.NoClassDefFoundError: Lcom/xx/interfaces/AdminLocalHome;"

      But how to solve it ?

      Thanks
      Eric

        • 1. Re: EJB3 call EJB2
          ericw78

          Someone to help me please ?
          Thanks
          Eric

          • 2. Re: EJB3 call EJB2
            jaikiran

            Looks like you are deploying these 2 separately in two separate jar files. Any specific need to deploy these independently? The easiest way is to package both these ejb jars in an EAR and deploy that EAR.

            • 3. Re: EJB3 call EJB2
              ericw78

              Yes, there are in 2 separate jars because they come from 2 different projects.
              Why do you say me to package them into an ear ?
              What is different using ear ?

              • 4. Re: EJB3 call EJB2
                jaikiran

                 

                "ericw78" wrote:
                Yes, there are in 2 separate jars because they come from 2 different projects.
                Why do you say me to package them into an ear ?
                What is different using ear ?



                I suspect that since these beans belong to two different jars (applications), the classes are not shared. Having said that, i can't explain why the hot deployment works.

                You can try adding the bean interfaces to the other jar (EprocEjb.jar).



                • 5. Re: EJB3 call EJB2
                  ericw78

                   

                  "jaikiran" wrote:
                  You can try adding the bean interfaces to the other jar (EprocEjb.jar).

                  It seems to be a great idea ;-(

                  I found another solution : I have renamed my ejb3 jar to "Zebj3.jar". Then it is loaded in last position (after my ejb2 jar) and I get no more error when jboss start...