4 Replies Latest reply on Oct 10, 2003 4:47 PM by asubu

    Ear Sar ClassLoader related Problems

    shreedharn

      Hi guys,

      Am in the process of porting my application from JBoss3.0 to JBoss3.2. And no surprise I am having lots of class loader related problem. It wud be gr8 help if somebody could find out where I had gone wrong.

      I have ear and a sar for my application. EJB/Web stuffs are packed in the ear and my services are packed in sar. There are few classes that are duplicated in both the archives which gives a lot of ClassLoader related problem.

      When deployed as is [myapp.ear and myapp.sar copied to deploy directory], it gives a LinkageError stating that there are duplicate classes.

      I tried to define the class loader scope for ear (using <loader-repository> in jboss-app.xml), but when any of service class accesses the ejb, it gives a classcast exception when casting EJB Home. Then I used ByValueInvokerInterceptor to avoid call by reference mode. (courtesy http://www.mail-archive.com/jboss-development@lists.sourceforge.net/msg37149.html//www.mail-archive.com/jboss-development@lists.sourceforge.net/msg37149.html), after which I am able to successfully look up. But calling a finder (on the looked up home) leads to a NullPointerException! (see stack trace at the end of posting)

      Then I tried providing same value in <loader-repository> in jboss-app.xml of both ear and sar. Still there was a ClassCastException during Home look up!!

      Any clues will be highly helpful.

      Thanks,
      Shreedhar


      java.lang.NullPointerException
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityC
      ontainer.java:994)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractIntercep
      tor.java:88)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(Ent
      itySynchronizationInterceptor.java:188)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invo
      keHome(CachedConnectionInterceptor.java:215)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractIntercep
      tor.java:88)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInst
      anceInterceptor.java:91)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInte
      rceptor.java:61)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCrea
      tionInterceptor.java:28)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte
      rceptor.java:88)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
      torCMT.java:243)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
      va:74)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
      tor.java:92)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
      20)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyF
      actoryFinderInterceptor.java:93)
      at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java
      :477)
      at org.jboss.ejb.Container.invoke(Container.java:694)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBea
      nDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)

      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.jav
      a:83)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.
      java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:4
      5)
      at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
      at $Proxy106.findByPrimaryKey(Unknown Source)

        • 1. Re: Ear Sar ClassLoader related Problems

          If you don't want to share classes between deployments,
          you need to use the ByValueInvokerInterceptor rather than
          the InvokerInterceptor and useRemote interfaces.

          This makes remote interfaces use Pass By Value inside the
          same VM (about 10x slower)

          Regards,
          Adrian

          • 2. Re: Ear Sar ClassLoader related Problems
            shreedharn

            Hi Adrian,

            I wud like to ideally share the classes between deployments. i.e. SAR(service archive for our application) and EAR. But since there are classes duplicated in the SAR and EAR, I get linkage error(DuplicateClassException) during EAR deployment.
            Is there any better way to solve this problem? or should I pack in such a way that the classes are not duplicated in the archives.

            Add. Info:
            (1)Initially I was using app-service.xml instead of SAR. I moved to SAR hoping that I could have more control over classloader by using jboss-app.xml.

            (2) My deployment structure -
            deploy/app.sar
            deploy/app.ear

            Thanks,
            Shreedhar Natarajan

            • 3. Re: Ear Sar ClassLoader related Problems

              We don't have support for class dependencies.

              The sar will be loaded before the ear, so putting the classes in the
              sar will work.

              If you redeploy the sar, make sure you redeploy the ear.

              Alternatively, statically deploy the shared classes in
              server/default/lib

              Regards,
              Adrian

              • 4. Re: Ear Sar ClassLoader related Problems
                asubu

                Hi,
                I am also facing a similar problem, when JBOSS starts the MBEAN is trying to look up an entity bean and I get the following exception. Can anyone help me here?

                ava.lang.NullPointerException
                at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createBeanClassInstance(JDBCStoreManager.java:555)
                at org.jboss.ejb.plugins.CMPPersistenceManager.createBeanClassInstance(CMPPersistenceManager.java:137)
                at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createBeanClassInstance(CachedConnectionInterceptor.java:
                at org.jboss.ejb.EntityContainer.createBeanClassInstance(EntityContainer.java:226)
                at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:146)
                at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:79)
                at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
                at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
                at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88)
                at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
                at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:74)
                at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92)
                at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
                at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
                at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:477)
                at org.jboss.ejb.Container.invoke(Container.java:694)
                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:324)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
                at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
                at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:83)
                at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
                at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
                at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173)
                at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)