3 Replies Latest reply on Jun 21, 2007 10:46 AM by Advait

    ClassNotFoundException when class is present in WEB-INF/lib

    Advait Newbie

      Hi,
      This is wierdest CNFE I have ever encountered. I am using JBoss Portal 2.6, JBoss AS 4.0.5 GA.

      I have a war file which contains acegi-security-1.0.1.jar in WEB-INF/lib
      This file has a class: org.acegisecurity.userdetails.UsernameNotFoundException. But still I get ClassNotFoundException: org.acegisecurity.userdetails.UsernameNotFoundException when portlet is initialized at server startup

      I have enabled logging of class loading in log4j. This is UsernameNotFoundException related logs from ucl.log:

      [82033,RepositoryClassLoader,main] loadClass org.jboss.mx.loading.UnifiedClassLoader3@12c5bfc{ url=file:/D:/jboss-cas-2.6/server/default/tmp/deploy/tmp61177pebble-mframe-exp.war/ ,addedOrder=54} name=org.acegisecurity.userdetails.UsernameNotFoundException, loadClassDepth=0
      [82033,RepositoryClassLoader,main] loadClassImpl, name=org.acegisecurity.userdetails.UsernameNotFoundException, resolve=false
      [82033,LoadMgr3,main] Begin beginLoadTask, task=org.jboss.mx.loading.ClassLoadingTask@f1156e{classname: org.acegisecurity.userdetails.UsernameNotFoundException, requestingThread: Thread[main,5,jboss], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@12c5bfc{ url=file:/D:/jboss-cas-2.6/server/default/tmp/deploy/tmp61177pebble-mframe-exp.war/ ,addedOrder=54}, loadedClass: nullnull, loadOrder: 2147483647, loadException: null, threadTaskCount: 0, state: 0, #CCE: 0}
      [82033,RepositoryClassLoader,main] getResourceLocally(org.jboss.mx.loading.UnifiedClassLoader3@27e353{ url=file:/D:/jboss-cas-2.6/server/default/conf/ ,addedOrder=1}), name=org/acegisecurity/userdetails/UsernameNotFoundException.class, resURL:null
      [82033,RepositoryClassLoader,main] getResourceLocally(org.jboss.mx.loading.UnifiedClassLoader3@16752c9{ url=file:/D:/jboss-cas-2.6/server/default/deploy/jboss-portal.sar/ ,addedOrder=9}), name=org/acegisecurity/userdetails/UsernameNotFoundException.class, resURL:null
      [82033,RepositoryClassLoader,main] getResourceLocally(org.jboss.mx.loading.UnifiedClassLoader3@18eb00c{ url=file:/D:/jboss-cas-2.6/server/default/deploy/jbossweb-tomcat55.sar/ ,addedOrder=10}), name=org/acegisecurity/userdetails/UsernameNotFoundException.class, resURL:null
      [82033,RepositoryClassLoader,main] getResourceLocally(org.jboss.mx.loading.UnifiedClassLoader3@b48230{ url=file:/D:/jboss-cas-2.6/server/default/deploy/jbossws14.sar/ ,addedOrder=11}), name=org/acegisecurity/userdetails/UsernameNotFoundException.class, resURL:null
      [82033,RepositoryClassLoader,main] loadClassLocally, org.jboss.mx.loading.UnifiedClassLoader3@12c5bfc{ url=file:/D:/jboss-cas-2.6/server/default/tmp/deploy/tmp61177pebble-mframe-exp.war/ ,addedOrder=54} name=org.acegisecurity.userdetails.UsernameNotFoundException
      [82049,RepositoryClassLoader,main] findClass, name=org.acegisecurity.userdetails.UsernameNotFoundException
      [82049,RepositoryClassLoader,main] CFNE: Adding to blacklist: org.acegisecurity.userdetails.UsernameNotFoundException
      [82049,RepositoryClassLoader,main] CFNE: Adding to blacklist: org.acegisecurity.userdetails.UsernameNotFoundException
      [82049,RepositoryClassLoader,main] loadClassLocally, org.jboss.mx.loading.UnifiedClassLoader3@12c5bfc{ url=file:/D:/jboss-cas-2.6/server/default/tmp/deploy/tmp61177pebble-mframe-exp.war/ ,addedOrder=54} name=org.acegisecurity.userdetails.UsernameNotFoundException not found
      [82049,LoadMgr3,main] Begin endLoadTask, task=org.jboss.mx.loading.ClassLoadingTask@f1156e{classname: org.acegisecurity.userdetails.UsernameNotFoundException, requestingThread: Thread[main,5,jboss], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@12c5bfc{ url=file:/D:/jboss-cas-2.6/server/default/tmp/deploy/tmp61177pebble-mframe-exp.war/ ,addedOrder=54}, loadedClass: nullnull, loadOrder: 2147483647, loadException: null, threadTaskCount: 0, state: 0, #CCE: 0}
      [82049,RepositoryClassLoader,main] loadClass org.jboss.mx.loading.UnifiedClassLoader3@12c5bfc{ url=file:/D:/jboss-cas-2.6/server/default/tmp/deploy/tmp61177pebble-mframe-exp.war/ ,addedOrder=54} name=org.acegisecurity.userdetails.UsernameNotFoundException not found

      Any idea, whats going on?

      Thanks & Regards
      Advait Trivedi

        • 1. Re: ClassNotFoundException when class is present in WEB-INF/
          Sohil Shah Master

          Advait-

          You problem is tomcat isolated class loading (which btw is a good thing)

          To fix this-

          1/ Go to deploy/jbossweb-tomcat55.sar/META-INF/jboss-service.xml

          2/ Make the value of UseJBossWebLoader to "true" from its default value of "false"


          Thanks

          • 2. Re: ClassNotFoundException when class is present in WEB-INF/
            Advait Newbie

            Hi Sohil,

            I tried doing true, but this is even more catastrophic: I have cas.war (http://www.ja-sig.org/products/cas/) deployed on my JBoss Portal, for SSO. It has common-logging and log4j JARs. If I make above to "true", then following is coming while server startup:

            11:03:49,083 INFO [PortletAppDeployment] Parsing jboss-portlet.xml/portal-core
            11:03:50,005 INFO [TomcatDeployer] deploy, ctxPath=/cas, warUrl=.../deploy/cas.war/
            11:03:51,036 INFO [[/cas]] Initializing Log4J from [classpath:log4j.properties]
            ERROR: invalid console appender config detected, console stream is looping

            See this: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=111078
            And the start up halts :(
            So I never reach to the point where my original problem starts.

            Thanks & Regards,
            Advait

            • 3. Re: ClassNotFoundException when class is present in WEB-INF/
              Advait Newbie

              Hi Sohil,

              I ended up with another problem. I have JB AS 4.0.5_GA and JBoss Portal 2.4 on top of it. I have pebble.war which contains WEB-INF/lib/spring-dao-1.2.8.jar which contains TransactionAspectSupport.class. I have alfresco.war which contains WEB-INF/lib/spring.jar which also contains TransactionAspectSupport.class.

              First I had, UseJBossWebLoader=false and Java2ClassLoadingCompliance=false, but then while deploying pebble.war it gave following exception:

              java.lang.NoClassDefFoundError: net/sourceforge/pebble/web/action/ActionNotFoundException
              java.lang.Class.getDeclaredConstructors0(Native Method)
              java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
              java.lang.Class.getConstructor0(Class.java:2640)
              java.lang.Class.newInstance0(Class.java:321)

              Then in changed UseJBossWebLoader=true. Result: pebble.war got deployed successfully but deployment of alfresco.war threw exceptions:

              java.lang.NoSuchMethodError: org.alfresco.util.transaction.SpringAwareUserTransaction.doFinally(Lorg/springframework/transaction/interceptor/TransactionAspectSupport$TransactionInfo;)V
              at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:420)
              at org.alfresco.repo.transaction.TransactionUtil.executeInTransaction(TransactionUtil.java:186)

              Please note that I dont have any spring related jars in JBOSS_HOME/server/default/lib

              Thanks & Regards,
              Advait Trivedi