Why can't I reference net.sf.jasperreports.engine.DefaultJasperReportsContext from JSF?

1.5k views Asked by At

I grabbed an old JSF (in Netbeans) project that I needed to update. I noticed that the libraries were missing, so I went and snagged the current version of JasperReports (.jar) and all the commons/other support .jars necessary. Ultimately, when I try to run the project it fails at the JasperSoft JRXmlLoader.load(inputStream) call with:

java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.DefaultJasperReportsContext
at net.sf.jasperreports.engine.JRRuntimeException.getMessage(JRRuntimeException.java:146)
at net.sf.jasperreports.engine.JRRuntimeException.getMessage(JRRuntimeException.java:138)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
at java.lang.String.valueOf(String.java:2982)
at java.lang.StringBuilder.append(StringBuilder.java:131)
at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:695)
at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
at java.lang.Throwable.printEnclosedStackTrace(Throwable.java:709)
at java.lang.Throwable.printStackTrace(Throwable.java:667)
at java.lang.Throwable.printStackTrace(Throwable.java:721)
at com.sun.enterprise.server.logging.UniformLogFormatter.uniformLogFormat(UniformLogFormatter.java:448)
at com.sun.enterprise.server.logging.UniformLogFormatter.format(UniformLogFormatter.java:178)
at java.util.logging.StreamHandler.publish(StreamHandler.java:211)
at java.util.logging.ConsoleHandler.publish(ConsoleHandler.java:116)
at java.util.logging.Logger.log(Logger.java:738)
at java.util.logging.Logger.doLog(Logger.java:765)
at java.util.logging.Logger.log(Logger.java:875)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:86)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:745)

Other possibly related oddities: While the project clean/builds into a .war fine (no errors), running it in Netbeans gives a popup about "One or more projects were compiled with errors." and lets me run anyways. I see no errors in the console/logs though. I have found a couple of CSS files (inside JasperReports) that are being flagged as being in error (the "background:" tag specifically), but why would Netbeans even try to parse CSS? If I pull out support files (such as commons-digester) then it blows up at the same location (the call to JasperSoft), but with no class found for digester. So, we DO seem to be getting into JasperSoft despite the text of the error I'm getting... Any ideas on how to resolve this class that can't be found even though JasperSoft itself is clearly starting to run before hitting the error?

1

There are 1 answers

1
Brian Knoblauch On BEST ANSWER

JasperSoft and support libraries cannot be copied into source as class files (unlike what is commonly done with other support libraries in desktop applications for JWS), they must be referenced as true libraries.