3 Replies Latest reply on Oct 28, 2015 10:54 AM by Miha Valencic

    Indeterminate ClassNotFound: BeansException

    Miha Valencic Newbie

      Hi!

       

      I have a strange issue and I can't pinpoint the exact scenario, but redeploying usually triggers it. The background: Running jboss 7.1.1 on a Mac (or Windows) with Liferay installed. I have a Spring MVC portlet, which calls a web service (proxy generated using jax-ws's wsimport command).

       

      The portlet includes the following jar files: aopalliance.jar, gson.jar, spring-aop.jar, spring-asm.jar, spring-beans.jar, spring-context-support.jar, spring-context.jar, spring-core.jar, spring-expression.jar, spring-jdbc.jar, spring-tx.jar, spring-web.jar, spring-webmvc-portlet.jar, spring-webmvc.jar

       

      The portlet is deployed fine after a restart. When I redeploy it (copying the portelt war file to liferay/deploy, where it is picked up by JBoss AS), I usually (but not always) get an exception:

       

      12:06:53,587 ERROR [org.springframework.web.portlet.DispatcherPortlet] (MSC service thread 1-1) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'podporaController': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/BeansException. This exception is triggered by calling the webservice inside "@PostConstruct public void initializePortlet()" method.

       

      Which is strange, since BeansException is contained in the spring-beans.jar file. The JBoss AS does NOT have spring module installed (that's why I'm including the jars here), but Liferay deployment does include its own spring jars. Interestingly enough, the liferay module does NOT include spring jars, so I have to include them in my portlet WAR file.


      How would I go about troubleshooting the classloader or whatever in order to fix this issue?


      Kind regards,

      Miha.


      PS: Additional trace that might give some clues to the advanced gurus here:

       

      Caused by: java.lang.ClassNotFoundException: org.springframework.beans.BeansException from [Module "org.apache.cxf:main" from local module loader @1d140071 (roots: /Users/miha/work/MIZS/liferay/jboss-7.1.1/modules)]

        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)


      Edit: I've even disabled the org.apache.cxf module in jboss-deployment-structure.xml, but I'm still getting this error sometimes, although less frequently (??? seems like the twilight zone )

        • 1. Re: Indeterminate ClassNotFound: BeansException
          Miha Valencic Newbie

          What I've done so far is disable the org.apache.cxf module, moved the initialization to the "first request" and added JAX-WS runtime jars to the WAR. It is now "mostly" working, though I doubt this is the way to go. I get this warning when redeploying:

           

          19:17:17,419 WARN  [org.jboss.as.ee] (MSC service thread 1-2) JBAS011006: Not installing optional component com.sun.xml.ws.transport.http.servlet.WSAsyncListener$1 due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Could not find default constructor for class com.sun.xml.ws.transport.http.servlet.WSAsyncListener$1


          I just wish it would work with cxf and spring... I'm probably missing some stupid configuration setting somewhere?

          • 2. Re: Indeterminate ClassNotFound: BeansException
            Tomaz Cerar Master

            You can ignore the warning, is just bug in spring code, but doesn't affect anything in later version (i think in WildFly 8.0) we changed that warning to debug as it doesn't really break anything.

             

            You could upgrade to latest version of AS, at the moment that is WildFly 9.0.2.Final, with 10.final coming shortly.

            • 3. Re: Indeterminate ClassNotFound: BeansException
              Miha Valencic Newbie

              Tomaz, thanks for the answer. This explains the latest warning, but no so much why I need to disable the whole CXF stack and include JAX-WS RT jars in order for it to work? Is this simply because spring is involved and "crossing contexts" (by that I mean modules like my own, CXF, etc) makes the class loader unpredicatble?

               

              Liferay unfortunately does not "support" newer versions of JBoss so latest Wilfly versions are (unfortunately) out of the question.

               

              Thanks,

              Miha.