3 Replies Latest reply on Aug 9, 2013 10:43 AM by andilog

    java.lang.ClassNotFoundException while Migration 4.2.3 to 5.1 GA or 7.1

    andilog

      Hello everyone.

       

      I am working on a Migration with a big application. It consists of two parts: one is .ear and the other is .war.

       

      I have read a lot of postings and tried many things... this is really hard job to migrate, because I have not invented that application by myself.

      The application is based on struts.

       

      Last thing I have done is written here: https://community.jboss.org/wiki/useJBossWebClassLoaderinJBoss5

       

      Right now I am facing following error:

       

      14:27:53,771 ERROR [[action]] Servlet.service() for servlet action threw exception
      java.lang.ClassNotFoundException: com.myCompany.exception.NotLoggedInException from
                BaseClassLoader@5dcc1ef4{VFSClassLoaderPolicy@4045548
                {name=vfsfile:/C:/Users/amartin/Desktop/Logisco/Webchannel/rt/jboss-5.1.0.GA/server/WebChannel51/deploy/WebChannel.war/
                domain=ClassLoaderDomain@df1cbf6{
                     name=DefaultDomain parentPolicy=BEFORE parent=org.jboss.bootstrap.NoAnnotationURLClassLoader@58fe64b9}
                roots=[MemoryContextHandler@947579911[path= context=vfsmemory://a2s11x-4bzqjl-hjr2yvcp-1-hjr2z5pf-2b
                     real=vfsmemory://a2s11x-4bzqjl-hjr2yvcp-1-hjr2z5pf-2b],
                FileHandler@236838025[path=WebChannel.war/WEB-INF/classes
                context=file:/C:/Users/amartin/Desktop/Logisco/Webchannel/rt/jboss-5.1.0.GA/server/WebChannel51/deploy/
                real=file:/C:/Users/amartin/Desktop/Logisco/Webchannel/rt/jboss-5.1.0.GA/server/WebChannel51/deploy/WebChannel.war/WEB-INF/classes/],
                DelegatingHandler@1249488284[path=WebChannel.war/WEB-INF/lib/antlr.jar
                context=file:/C:/Users/amartin/Desktop/Logisco/Webchannel/rt/jboss-5.1.0.GA/server/WebChannel51/deploy/
                ...(edit: shorted quite long list...)
          at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:448)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
          at com.usocome.client.webchannel.action.LoginAction.execute(LoginAction.java:39)
          at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
          at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
          at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
          at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
          at java.lang.Thread.run(Thread.java:619)
      

       

      The class .com.myCompany.exception.NotLoggedInException is placed in the .ear.

       

      WEB-INF/jboss-classloading.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!--  Migration 5.1 - AMartin 2013.07.30 -->
      <!-- A hack to make this classloader a top-level classloader
           The actual value is ignored since DefaultDomain
           already exists.
      -->
      <classloading xmlns="urn:jboss:classloading:1.0"
                    name="WebChannel.war"
                    domain="DefaultDomain"
                    parent-domain="Ignored"
                    export-all="NON_EMPTY"
                    import-all="true">
      </classloading>
      

       

      I am thinking about scope, permission and build path, but could not find any solution yet.

      Hope someone can give me a hint.

        • 1. Re: java.lang.ClassNotFoundException while Migration 4.2.3 to 5.1 GA
          andilog

          Just found an entry in struts-config.xml:

           

           

            <global-exceptions>
          ...
              <exception key="global.error.notloggedin" path="/checkLogin.do" scope="request" type="com.myCompany.exception.NotLoggedInException" />
          ...
            </global-exceptions>
          
          • 2. Re: java.lang.ClassNotFoundException while Migration 4.2.3 to 5.1 GA
            andilog

            Having the same problem with JBoss 7.1 migration.

             

            I think I need to know how provide a class from an ear-file to a war-file.

            Not sure, but maybe I have to consider EJB2.0 (used in the ear).

            • 3. Re: java.lang.ClassNotFoundException while Migration 4.2.3 to 5.1 GA
              andilog

              I found the solution.

               

              JBoss AS 7 Configuration, Deployment and Administration, Francesco Marchioni:

               

              Therefore, applications that are packaged as top-level archives (such as WAR, JAR,

              and SAR) are assigned the following module name:

              deployment.[archive name]

              For example, a web application named WebExample1.war will be deployed as the

              following module name:

              deployment.WebExample1.war

               

              On the other hand, on applications that contain nested modules (such as the

              EAR archive), every single archive will be assigned a module name using this

              classification:

              deployment.[ear archive name].[sub deployment archive name]

              So, the same web application, if contained in the archive EnterpriseApp.ear, 

              will be deployed with the following name:

              deployment.EnterpriseApp.ear.WebExample1.war

               

              My ear-project contains application.xml:

               

              <?xml version="1.0" encoding="ISO-8859-1"?>
              <application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                           version="6"
                           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
              
              
                 <display-name>MyCompanyName</display-name>
                 <description>EAR generated by Middlegen</description>
                 <module>
                    <ejb>com.mycompany-ejb.jar</ejb>
                 </module>
              
              </application>
              

               

              In the war-project I added WebConten/META-INF/MANIFEST.MF file:

              Manifest-Version: 1.0
              Class-Path: 
              Dependencies: deployment.mycompany.ear.com.mycompany-ejb.jar
              

               

              Dependencies are the module names.(Here from application.xml).

              Class-Path would contain the name of the JAR-File.

               

              Solution for 5.1 is missing, but not relevant for me at moment.