5 Replies Latest reply on Oct 21, 2015 5:09 AM by evan pan

    module and ClassNotFoundException

    dario novakovic Newbie

      Hello,

       

      I was struggling with setting up jasper reports 5.6.0 as a jboss module and I almost did it, but when I used barcode in report, I began to get

       

      Caused by: java.lang.NoClassDefFoundError: org/apache/batik/dom/svg/SVGOMDocument

          at net.sf.jasperreports.renderers.BatikRenderer.ensureSvg(BatikRenderer.java:203) [jasperreports-5.6.0.jar:5.6.0]

          at net.sf.jasperreports.renderers.BatikRenderer.ensureSvg(BatikRenderer.java:237) [jasperreports-5.6.0.jar:5.6.0]

          at net.sf.jasperreports.renderers.BatikRenderer.getDimension(BatikRenderer.java:155) [jasperreports-5.6.0.jar:5.6.0]

          at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1524) [jasperreports-5.6.0.jar:5.6.0]

          at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:946) [jasperreports-5.6.0.jar:5.6.0]

          at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:909) [jasperreports-5.6.0.jar:5.6.0]

          at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:786) [jasperreports-5.6.0.jar:5.6.0]

          at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:513) [jasperreports-5.6.0.jar:5.6.0]

          at com.soluma.posta.service.ReportingManagerImpl.generateBarcodeStickers(ReportingManagerImpl.java:443) [SolumaPosta-ejb.jar:]

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_60]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_60]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_60]

          at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_60]

          at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:226) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]

          ... 45 more

      Caused by: java.lang.ClassNotFoundException: org.apache.batik.dom.svg.SVGOMDocument from [Module "net.sf.jasperreports:main" from local module loader @74b9121c (roots: D:\progs\jboss7.1\modules)]

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

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

          ... 75 more

       

       

      This class is 100% in the module and the module is configured like this.:

      <module xmlns="urn:jboss:module:1.0" name="net.sf.jasperreports">
      
          <resources>
              <resource-root path="jasperreports-5.6.0.jar"/>
              <resource-root path="barcode4j-2.1.jar"/>
              <resource-root path="batik-anim.jar"/>
              <resource-root path="batik-awt-util.jar"/>
              <resource-root path="batik-bridge.jar"/>
              <resource-root path="batik-css.jar"/>
              <resource-root path="batik-dom.jar"/>
              <resource-root path="batik-ext.jar"/>
              <resource-root path="batik-gvt.jar"/>
              <resource-root path="batik-parser.jar"/>
              <resource-root path="batik-script.jar"/>
              <resource-root path="batik-svg-dom.jar"/>
              <resource-root path="batik-svggen.jar"/>
              <resource-root path="batik-util.jar"/>
              <resource-root path="batik-xml.jar"/>
              <resource-root path="bcel-5.2.jar"/>
              <resource-root path="bsh-2.0b4.jar"/>
              <resource-root path="commons-beanutils-1.8.0.jar"/>
              <resource-root path="commons-collections-3.2.1.jar"/>
              <resource-root path="commons-digester-2.1.jar"/>
              <resource-root path="commons-javaflow-20060411.jar"/>
              <resource-root path="dom4j-1.6.1.jar"/>
              <resource-root path="groovy-all-2.0.1.jar"/>
              <resource-root path="iText-2.1.7.js2.jar"/>
              <resource-root path="jaxen-1.1.1.jar"/>
              <resource-root path="jcommon-1.0.15.jar"/>
              <resource-root path="jfreechart-1.0.12.jar"/>
              <resource-root path="jxl-2.6.10.jar"/>
              <resource-root path="png-encoder-1.5.jar"/>
              <resource-root path="velocity-1.7-dep.jar"/>
          </resources>             
          
          <dependencies>
              <module name="org.apache.commons.logging" />
              <module name="org.apache.xerces" />
              <module name="org.apache.xalan" />
              <module name="sun.jdk" />
              <module name="javax.api"/>
          </dependencies>
      
                                   
      </module>    
      

       

      Can anybody please help with a suggestion? What could possibly be wrong here? All jars and classes are available, but some of them jboss is able to load and others it won't load. I just don't understand what would be general approach for modularizing if this doesn't work. I think it has to do something with xerces and xml-apis which was giving me class loading errors until I replaced it with dependencies to jboss built-in modules (line 37,38).

       

      Thank you for any help!

        • 1. Re: module and ClassNotFoundException
          dario novakovic Newbie

          UPDATE:

          This is the line that actually throws CNFE:

          BatikRenderer.java:203

          SVGDocumentFactory documentFactory = new SAXSVGDocumentFactory(userAgent.getXMLParserClassName(), true);

           

          The way I see it: japser depends on xml parser, I configured it to use jboss's xerces and now xml parsing classpath is messed up. I am desperate...

          • 2. Re: module and ClassNotFoundException
            Tomaz Cerar Master

            Where is class org.apache.batik.dom.svg.SVGOMDocument located?

            • 3. Re: module and ClassNotFoundException
              dario novakovic Newbie

              It is in

              batik-svg-dom.jar

              which is in the module/main directory, alongside jasperreports-5.6.0.jar.


              I am sure that this exception and message are misleading, and that problem is caused by something else.

              I even tried mergeing jar files and put entire content of batik-svg-dom.jar into jasperreports-5.6.0.jar, that didn't help even though jboss loads jasper classes from the same jar.


              I did this in my application:

              Class.forName("org.apache.batik.dom.svg.SVGDocumentFactory")

              and it works, SVGDocumentFactory is in batik-svg-dom.jar and class loader has no problems with it.


              I believe that some root cause is masked and it prevents org.apache.batik.dom.svg.SVGOMDocument from constructing/loading/instantiating/whatever. Message I got is completely misleading.

              • 4. Re: module and ClassNotFoundException
                dario novakovic Newbie

                As I said, err msg was completely misleading, the real cause is

                 

                09:45:20,326 WARN  [org.jboss.modules] (http-/0.0.0.0:8080-2) Failed to define class org.apache.batik.dom.svg.SVGOMDocument in Module "net.sf.jasperreports:main" from local module loader @74b9121c (roots: D:\progs\jboss7.1\modules): java.lang.LinkageError: Failed to link org/apache/batik/dom/svg/SVGOMDocument (Module "net.sf.jasperreports:main" from local module loader @74b9121c (roots: D:\progs\jboss7.1\modules))

                    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)

                    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)

                    at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)

                    at org.jboss.modules.Module.loadModuleClass(Module.java:527)

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

                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

                    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

                    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

                    at net.sf.jasperreports.renderers.BatikRenderer.ensureSvg(BatikRenderer.java:203) [jasperreports-5.6.0.jar:5.6.0]

                    at net.sf.jasperreports.renderers.BatikRenderer.ensureSvg(BatikRenderer.java:237) [jasperreports-5.6.0.jar:5.6.0]

                    at net.sf.jasperreports.renderers.BatikRenderer.getDimension(BatikRenderer.java:155) [jasperreports-5.6.0.jar:5.6.0]

                    at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1524) [jasperreports-5.6.0.jar:5.6.0]

                    at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:946) [jasperreports-5.6.0.jar:5.6.0]

                    at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:909) [jasperreports-5.6.0.jar:5.6.0]

                    at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:786) [jasperreports-5.6.0.jar:5.6.0]

                    at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:513) [jasperreports-5.6.0.jar:5.6.0]

                ...

                    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_60]

                Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/svg/SVGDocument

                    at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_60]

                    at java.lang.ClassLoader.defineClass(ClassLoader.java:800) [rt.jar:1.7.0_60]

                    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [rt.jar:1.7.0_60]

                    at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)

                    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)

                    ... 83 more

                Caused by: java.lang.ClassNotFoundException: org.w3c.dom.svg.SVGDocument from [Module "net.sf.jasperreports:main" from local module loader @74b9121c (roots: D:\progs\jboss7.1\modules)]

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

                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

                    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

                    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

                    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

                    ... 88 more

                 

                I had to set log level jboss.modules=TRACE to get this real error message. After that it was simple to add xml-apis-ext.jar to my module and it works. So, If you are having problems with jboss modules, like many people do, just set the trace log level to reveal real error messge.

                 

                Again, I spent two days debugging XML classpath related problem. Crimson, Xerces, endoresd, module this, module that, apis, implementations, all that pile of crap makes working with XML in java a real pain.

                • 5. Re: module and ClassNotFoundException
                  evan pan Newbie

                  Thanks for sharing those codes. But I wonder do I need another barcode decoder to help deal with that? Any sugegstion will be appreciated. Thanks in advance.