10 Replies Latest reply on Jul 18, 2005 11:42 PM by gray1

    java.lang.ClassCircularityError on JBoss 3.0.6

    crobert


      Hello,


      First of all, the JBoss version I'm working with is 3.0.6

      I'm having the following problem:

      In an EAR I have:
      - a couple of Stateless Session Beans and
      - a loaded-on-startup servlet (in a WAR inside the EAR)

      On the servlet's init(), I look-up those EJBs and start another thread which, at its discretion makes calls on the lookup()'ed EJBs.

      The problem is that sometimes I get java.lang.ClassCircularityError(s) like the ones below:

      java.lang.ClassCircularityError:org/jboss/ejb/StatelessSessionEnterpriseContext$SessionContextImpl
      at org.jboss.ejb.StatelessSessionEnterpriseContext.(StatelessSessionEnterpriseContext.java:45)
      at org.jboss.ejb.plugins.StatelessSessionInstancePool.create(StatelessSessionInstancePool.java:61)
      at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:184)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:63)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:712)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:98)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
      at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:111)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)


      or:

      java.lang.ClassCircularityError: org/jboss/resource/connectionmanager/CachedConnectionManager$IdentityWrapper
      java.lang.ClassCircularityError: org/jboss/resource/connectionmanager/CachedConnectionManager$IdentityWrapper
      at org.jboss.resource.connectionmanager.CachedConnectionManager.pushMetaAwareObject(CachedConnectionManager.java:137)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:183)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
      at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:144)
      at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
      at org.jboss.ejb.Container.invoke(Container.java:712)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:98)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
      at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:111)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)

      It may happen and indeed it does happen that the call on the EJBs runs _before_ the "successfully deployed" message from JBoss for that EAR.

      Looking at that specific line where the exception(s) are generated, I noticed that it happens on the line where the inner class is instatiated (org/jboss/ejb/StatelessSessionEnterpriseContext$SessionContextImpl or CachedConnectionManager$IdentityWrapper).

      Has anyone seen such behavior ? Is it normal ? If not, has it been resolved in the newer JBoss versions ?

      Robert

        • 1. Re: java.lang.ClassCircularityError on JBoss 3.0.6

          This was fixed a while ago.

          Regards,
          Adrian

          • 2. Re: java.lang.ClassCircularityError on JBoss 3.0.6
            crobert


            Thanks for your reply, Adrian.

            Could you please indicate the bug id or something like that (the JBoss version in which this is fixed) ? I've looked on the Sourceforge 'Bug Tracker' for JBoss and the only bugs relevant to my problem were:

            1. http://sourceforge.net/tracker/index.php?func=detail&aid=578028&group_id=22866&atid=376685

            2. http://sourceforge.net/tracker/index.php?func=detail&aid=673675&group_id=22866&atid=376685

            Both of them appear as 'Fixed' but this information is conflicting with the 'Comments' listed over there. Plus there's no mention of either bugs in the JBoss 3.0.7 and 3.0.8 ChangeLogs

            Thanks again,
            Robert

            PS: My JDK is 1.3.1

            • 3. Re: java.lang.ClassCircularityError on JBoss 3.0.6

              I doubt it appears in the changelog.
              The problem was due to build putting classes in more
              than one jar. This broke with earlier implementations
              of the UnifiedClassloader.

              Regards,
              Adrian

              • 4. Re: java.lang.ClassCircularityError on JBoss 3.0.6
                crobert


                Well, I've tested with JBoss 3.0.8 (which should be the latest bugfix release in 3.0.x) and the problem still appears, this time with a different stacktrace:

                java.lang.ClassCircularityError: org/jboss/ejb/EnterpriseContext$UserTransactionImpl
                at org.jboss.ejb.EnterpriseContext$EJBContextImpl.getUserTransaction(EnterpriseContext.java:434)
                at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:128)
                at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
                at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
                at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
                at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
                at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
                at org.jboss.ejb.Container.invoke(Container.java:738)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
                at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:99)
                at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
                at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
                at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
                at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:111)
                at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)

                I haven't tested (and I don't plan to test ) it with 3.2.x or 4.x.x as too many things changed between these releases and 3.0.x.

                I guess I'll have to make some workaround for it. Is there an afterDeploy() type of event in JBoss that I can add a listener to, or something similar ? (although this will tie the code to the specific AS)

                Regards,
                Robert

                • 5. Re: java.lang.ClassCircularityError on JBoss 3.0.6
                  srshende

                  Hello,
                  Try to keep only one version of the classes that are being shared among beans and servlets.
                  ClassCirularityError normally occurs when one class file is included in multiple jar files and when these jar files are deployed , the each instance of that common class is considered as different version by the classloader and hence it gives ClassCircularitError. Some time it also thorws LinkageError.

                  Correct me if any thing wrong.

                  ~Sanjay

                  • 6. Re: java.lang.ClassCircularityError on JBoss 3.0.6
                    crobert


                    Well Sanjay, Java complains about ClassCircularityError on a JBoss class, so assuming that your hypothesis is right, it means that JBoss classes are packed in multiple jar files.

                    I do have only one jar with all the necessary classes.
                    Plus, this only happens before JBoss displaying the message with 'successfully deployed X.ear'. That's what has led me to suspect that it might be something related to the insufficient initialization of the Bean resources (??)

                    Anyway, thanks for your help,
                    Robert

                    • 7. Re: java.lang.ClassCircularityError on JBoss 3.0.6
                      crobert


                      Update: I get this error with JBoss 3.2.2 too.

                      I guess the UnifiedClassLoader doesn't behave like it should.

                      Robert

                      • 8. Re: java.lang.ClassCircularityError on JBoss 3.0.6
                        ioparra

                        Add on to this.
                        We are using JBoss3.2.1 and have found the CCE happen to many random classes(org.jboss, com.ourcompany, org.thirdparty, etc).

                        I don't know if it exists post 3.2.2. What I have noticed is that if we restart the appserver, it is fine(sometimes, it may take a few restarts).

                        Sounds like a race scenario in the ClassLoader.

                        I'm actively hunting it down, with little results. If someone can post a work around or the such, it would be appreciated.

                        -Ivan

                        • 9. Re: java.lang.ClassCircularityError on JBoss 3.0.6
                          ioparra
                          • 10. Re: java.lang.ClassCircularityError on JBoss 3.0.6
                            gray1

                            I get this problem on JBoss 4.0.1 and JDK 1.4.2_08

                            So it has not been fixed.