NoClassDefFoundError / WebApp

Help
m_wells
2005-08-17
2013-05-02
  • m_wells

    m_wells - 2005-08-17

    The classpath issue seems to be in resolving either the source or target class being mapped (I suspect the source class).  Any help greatly appreciated...

    Mapper.map(UserPrincipleDTO, WSUserPrincipleDTO)

    The source class (UserPrincipleDTO) is common-source.jar in the APP-INF/lib folder (see deployment below).
    The target class (WSUserPrincipleDTO) is in the WEB-INF/classes folder together with the property map xml file (see deployment below).
                   
    ------------STACK TRACE---------------
    .
    .
    .
    Initializing dozer version 1.4
    .
    .
    .
    java.lang.NoClassDefFoundError   
    at com.nr.dm.sm.pres.ui.ws.session.DMUISessionService.login(DMUISessionService.java:81)   
    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 weblogic.webservice.component.javaclass.JavaClassInvocationHandler.invoke(JavaClassInvocationHandler.java:133)   
    at weblogic.webservice.core.handler.InvokeHandler.handleRequest(InvokeHandler.java:104)   
    at weblogic.webservice.core.HandlerChainImpl.handleRequest(HandlerChainImpl.java:143)   
    at weblogic.webservice.core.DefaultOperation.process(DefaultOperation.java:531)   
    at weblogic.webservice.server.Dispatcher.process(Dispatcher.java:204)   
    at weblogic.webservice.server.Dispatcher.doDispatch(Dispatcher.java:176)   
    at weblogic.webservice.server.Dispatcher.dispatch(Dispatcher.java:96)   
    at weblogic.webservice.server.WebServiceManager.dispatch(WebServiceManager.java:98)   
    at weblogic.webservice.server.servlet.WebServiceServlet.serverSideInvoke(WebServiceServlet.java:298)   
    at weblogic.webservice.server.servlet.ServletBase.doPost(ServletBase.java:485)   
    at weblogic.webservice.server.servlet.WebServiceServlet.doPost(WebServiceServlet.java:268)   
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)   
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)   
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)   
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)   
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)   
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)   
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)   
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)   
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)   
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)   
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)   
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)</bea_fault:stacktrace>

    ------------DEPLOYMENT-------------

    I have 2 mapping files (one in each WebApp), both are described in the dozerContext.xml

    My deployment is as follows:-

    EAR/
        APP-INF/
            lib/
                dozer-full.jar
                common-source.jar
            classes/
                dozerContext.xml
        MyWebApp1.jar
            WEB-INF/
                classes/
                    WebApp1Mapping.xml
                    com....(all classes in the WebApp1)
        MyWebApp2.jar
            WEB-INF/
                classes/
                    WebApp2Mapping.xml
                    com....(all classes in the WebApp2)
                   

    ------------WebApp1Mapping.xml-------------

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mappings PUBLIC "-//DOZER//DTD MAPPINGS//EN" "http://dozer.sourceforge.net/dtd/dozerbeanmapping.dtd">
    <mappings>

        <mapping>
            <!--source class is in a jar in the APP-INF/lib folder -->
            <classA>com.nr.dm.sm.pres.ui.ws.model.wlgenerated.session.WSUserPrincipleDTO</classA>
            <!--target class is in the WEB-INF/classes folder-->
            <classB>com.nr.dm.model.common.UserPrincipleDTO</classB>
        </mapping>
    </mappings>

     
    • seb

      seb - 2005-08-17

      You can try to move dozer-full.jar in every WEB-INF/lib/ or modifiy the sources to change the classLoader (see the previous thread)
      Good luck

       
      • Franz Garsombke

        Franz Garsombke - 2005-08-17

        I will try to get this fixed today.

        Franz

         
        • m_wells

          m_wells - 2005-08-17

          In an attempt to get things going I tried simplifying my deployment but still have classloader problems (see stack trace below).

          The com.nr.dm.sm.pres.ui.ws.model.wlgenerated.session.WSUserRoleDTO that is failing to load is in the source.jar (I've also tried putting the classes in the classes folder with the same error).

          Any ideas?

          --------DEPLOYMENT------

          My deployment is now as follows-

          EAR/
          ----WebApp.jar
          --------WEB-INF
          --------------lib
          -----------------source.jar
          -----------------dozer-full-1.4.3.jar
          --------------classes
          -----------------SMWebAppPropertyMapping.xml
          -----------------dozerContext.xml

          ------STACK TRACE--------

          ERROR net.sf.dozer.util.mapping.Mapper - Error in loading dozer mapping file: /SMWebAppPropertyMapping.xml : net.sf.dozer.util.mapping.MappingException: org.xml.sax.SAXException: unable to add 'classA' to <mapping> due to the following exception:
          >>>--- Begin Exception ---<<<
          java.lang.ClassNotFoundException: com.nr.dm.sm.pres.ui.ws.model.wlgenerated.session.WSUserRoleDTO
                  at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:198)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
                  at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:223)
                  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
                  at java.lang.Class.forName0(Native Method)
                  at java.lang.Class.forName(Class.java:140)
                  at net.sf.dozer.util.mapping.fieldmap.ClassMap.setSourceName(ClassMap.java:100)
                  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.exolab.castor.mapping.loader.FieldHandlerImpl.setValue(FieldHandlerImpl.java:463)
                  at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:803)
                  at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
                  at org.apache.xerces.impl.dtd.XMLDTDValidator.endNamespaceScope(Unknown Source)
                  at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
                  at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
                  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
                  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
                  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
                  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
                  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
                  at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:555)
                  at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:487)
                  at net.sf.dozer.util.mapping.util.MappingFileReader.read(MappingFileReader.java:70)
                  at net.sf.dozer.util.mapping.Mapper.readMappingsFromFile(Mapper.java:90)
                  at net.sf.dozer.util.mapping.Mapper.<clinit>(Mapper.java:128)
                  at com.nr.dm.sm.pres.ui.ws.session.DMUISessionService.login(DMUISessionService.java:81)
                  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 weblogic.webservice.component.javaclass.JavaClassInvocationHandler.invoke(JavaClassInvocationHandler.java:133)
                  at weblogic.webservice.core.handler.InvokeHandler.handleRequest(InvokeHandler.java:104)
                  at weblogic.webservice.core.HandlerChainImpl.handleRequest(HandlerChainImpl.java:143)
                  at weblogic.webservice.core.DefaultOperation.process(DefaultOperation.java:531)
                  at weblogic.webservice.server.Dispatcher.process(Dispatcher.java:204)
                  at weblogic.webservice.server.Dispatcher.doDispatch(Dispatcher.java:176)
                  at weblogic.webservice.server.Dispatcher.dispatch(Dispatcher.java:96)
                  at weblogic.webservice.server.WebServiceManager.dispatch(WebServiceManager.java:98)
                  at weblogic.webservice.server.servlet.WebServiceServlet.serverSideInvoke(WebServiceServlet.java:298)
                  at weblogic.webservice.server.servlet.ServletBase.doPost(ServletBase.java:485)
                  at weblogic.webservice.server.servlet.WebServiceServlet.doPost(WebServiceServlet.java:268)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                  at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
                  at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
                  at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
                  at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
                  at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
                  at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
                  at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
                  at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
                  at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
                  at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
          >>>---- End Exception ----<<<
          {file: [not available]; line: 13; column: 83}

           
    • Franz Garsombke

      Franz Garsombke - 2005-08-17

      Hmmm....that doesn't make any sense. The only suggestion I would have is putting your jars in APP-INF/lib of the Ear?

      Let me know if that helps.

      Franz

       
      • m_wells

        m_wells - 2005-08-18

        Should I raise this issue as a bug?  I've had 2 of my peers checking that I have not missed something.

        We'd really like to use Dozer as it looks like it should do exactly what we want, but I'm not sure how much more time I can afford to spend trying to configure the tool, which is a real shame.

        If you need any more info from me I'm happy to supply it.

        Regards, martin

         
    • m_wells

      m_wells - 2005-08-18

      I have already tried putting dozer libraries in the APP-INF/lib folder and was surprised that this did not solve the classloader problem.

      I have just run another test where I call Class.forName() for the class that is not being loaded in the same class that I call Mapper.map().

      The result is that this class can be loaded this way, but I get the ClassNotFoundException when dozer tries to load it.

      try
      {
          return outTranslator.createLoginResponse(principleDTO);
          Class.forName(WSUserRoleDTO.class.getName());
      }
      catch (ClassNotFoundException e)
      {
          e.printStackTrace();
      }
      return new WSLoginResponseDTO ((WSUserPrincipleDTO) Mapper.map(principleDTO, WSUserPrincipleDTO.class));

       
    • m_wells

      m_wells - 2005-08-18

      I've stepped into the Dozer source code in an attempt to track down the error.

      The error originates in MappingFileReader.read() which is called from the static initialiser in the Mapper class.

      Looks like the problem is with the Castor configuration, since a MarshalException is thrown during Unmarshalling the objects in the bean mappings file.

      mappings = (Mappings) unmarshaller.unmarshal(new InputStreamReader(stream));

       
    • Franz Garsombke

      Franz Garsombke - 2005-08-18

      I have fixed this problem (using Thread.currentThread.getContextClassLoader()) and will get it in today. -I tested two scenarios in WebLogic. I have a EAR file with two webapps. If I put the dozer jar into APP-INF/lib I get one instance of dozer for both webapps (not ideal). If I put the dozer jar in both webapps WEB-INF/lib directories and a beanmapping file at each WEB-INF/classes I am able to successfully have an instance for each webapp.

      This seemed like the simplest solution for now. Later we can figure out how to put the dozer jar in APP-INF/lib and have unique instances per webapp.

      Hope this helps.

      Franz

       
    • m_wells

      m_wells - 2005-08-19

      Thanks for that, I'll continue using the workaround until the next release. 

      Regards, Martin

       
    • m_wells

      m_wells - 2005-08-19

      Hi Franz, can you clarify what you mean when you say that it is "not ideal" to have a single instance of dozer shared between multiple Web Apps.

      Are there any particular issues I should be aware of if I were to deploy my application this way?

      Cheers, Martin

       
      • Franz Garsombke

        Franz Garsombke - 2005-08-19

        Sorry about that. I just meant that it was not 'ideal' if you did want multiple instances :) It is perfectly fine to have one instance for your EAR file. That is currently how we use dozer across our EJBs, WebApps, etc.

        Thanks.

        Franz

         
    • m_wells

      m_wells - 2005-08-19

      Great, that's what I'd hope you say:-)

      Incidentally, the fix in version 1.4.5 didn't work for me, but I can carry on with the workaround. I've updated the bug report with some info that may help.

      If I had time I would get involved with the Dozer project myself, but I'm extremely busy with other work.

      Regards, Martin

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks