This is exactly what this list is for, so ask away.
It sounds like you are running into some Classpath issues, which can
be a real pain to sort out. Let's see what we can suggest.
Log4j can be notorious for this, because it will store stuff in the
system classpath, and JavaLoader accesses that as well (it has to for
core Java classes), and CF starts up with it. Later version of log4j
handle this a bit nicer however.
Let's focus on the latest version of commons-logging, and see what is
going on there:
Looking at the stack trace, at line:
(ReportServiceImpl.java:87)
What is happening in the source code?
We can also see:
> Caused by: net.sf.jasperreports.engine.JRException: Could not
> instantiate report compiler :
> net.sf.jasperreports.engine.design.JRJavacCompiler
> at net.sf.jasperreports.engine.JasperCompileManager.getCompiler
> (JasperCompileManager.java:480)
> Caused by: java.lang.ClassCastException:
> net.sf.jasperreports.engine.design.JRJavacCompiler cannot be cast to
> net.sf.jasperreports.engine.design.JRCompiler
> at net.sf.jasperreports.engine.JasperCompileManager.getCompiler
> (JasperCompileManager.java:476)
Doing a google search on this seems to mean that some other people are
running into the same issue, and it seems to be classpath related as
well.
Do me a favour, try it without the itext.jar, and see what happens. It
*shouldn't* work, but maybe it will.
Mark
--
E: mark....@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com
| array | |
|---|---|
| 1 | C:\www\national-website\html\root\testapp\lib\commons-collections-2.1.jar |
| 2 | C:\www\national-website\html\root\testapp\lib\commons-digester-1.7.jar |
| 3 | C:\www\national-website\html\root\testapp\lib\commons-logging-1.1.jar |
| 4 | C:\www\national-website\html\root\testapp\lib\jasperreports-3.5.3.jar |
| 5 | C:\www\national-website\html\root\testapp\lib\log4j-1.2.14.jar |
| 6 | C:\www\national-website\html\root\testapp\lib\ojdbc5-11.1.0.7.0.jar |
| 7 | C:\www\national-website\html\root\testapp\lib\printable-reports.jar |
| 8 | C:\www\national-website\html\root\testapp\lib\reports-test.jar |
Hi Mark,
Thanks for getting back to me.
That line in the Java code is calling:
JasperRunManager.runReportToPdfStream(input, out, params, conn);
JasperRunManager being net.sf.jasperreports.engine.JasperRunManager
I've tried without the itext-2.1.0.jar in my lib directory, and it givesat org.xyz.printablereports.ReportServiceImpl.createPDF(ReportServiceImpl.java:163)
org.xyz.printablereports.ReportException: Error creating PDF File
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Caused by: net.sf.jasperreports.engine.JRException: Could not instantiate report compiler : net.sf.jasperreports.engine.design.JRJavacCompiler
at net.sf.jasperreports.engine.JasperCompileManager.getCompiler(JasperCompileManager.java:480)
at net.sf.jasperreports.engine.JasperCompileManager.loadEvaluator(JasperCompileManager.java:242)
at net.sf.jasperreports.engine.fill.JRFillDataset.createCalculator(JRFillDataset.java:420)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:411)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:78)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:60)
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:147)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:57)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:421)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:382)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdfStream(JasperRunManager.java:167)
at org.xyz.printablereports.ReportServiceImpl.createPDF(ReportServiceImpl.java:160)To me this is kind of interesting, because we are still getting a ClassCastException?
... 37 more
Caused by: java.lang.ClassCastException: net.sf.jasperreports.engine.design.JRJavacCompiler cannot be cast to net.sf.jasperreports.engine.design.JRCompiler
at net.sf.jasperreports.engine.JasperCompileManager.getCompiler(JasperCompileManager.java:476)
... 48 more
Note the line numbers have changed here because I updated the Java code in an effort to try and work out what was happening.
Also - is there any way to lock down the classloader so there's absolutely nothing else in the classpath except what is in that lib directory? I was hoping this was what would happen with Javaloader, and indeed if I debug like this, I get this output:
Okay, well try this then - try to run your JasperReports code, but
without your own jasperreports*.jar
See how that goes.
Mark
You definitely haven't set loadColdFusionClasspath to true?
Mark
ROOT CAUSE:
java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRException
at org.xyz.Main.doStuff(Unknown Source)
There is a JRException.class in
C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\lib\cfusion.jar\net\sf\jasperreports\engine\
so it's still a bit weird.
If my understanding is correct, I have explicitly set
loadColdFusionClasspath to false. This is where I instantiate the
loader:
<cfset loader = createObject("component",
"javaloader.JavaLoader").init(aJars,false)>
I'm wondering if our best option might be to try and determine what
version of jasper reports is in the cfusion.jar, and try and write our
report to use this?
Thanks again for your help as always!
Andrew.
2009/9/10 Mark Mandel <mark....@gmail.com>
Make the ColdFusion version run it.
Mark
On Thu, Sep 10, 2009 at 3:47 PM, Andrew Myers <am2...@gmail.com> wrote:
>
> <cfset loader = createObject("component",
> "javaloader.JavaLoader").init(aJars,false)>
--
I'll do some testing later on using the cfusion.jar rather than the
jasper reports jar and see if I can replicate the behaviour running it
from the command line.
java.lang.NullPointerException
at net.sf.jasperreports.engine.JRPropertiesMap.getProperty(JRPropertiesMap.java:102)
at net.sf.jasperreports.engine.util.JRProperties.getProperty(JRProperties.java:474)
at net.sf.jasperreports.engine.util.JRProperties.getIntegerProperty(JRProperties.java:512)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:144)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:108)
at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:669)
at net.sf.jasperreports.engine.fill.JRFillDataset.setDatasource(JRFillDataset.java:613)
at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:602)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:905)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:734)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:692)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:363)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdfStream(JasperRunManager.java:163)
at org.xyz.printablereports.ReportServiceImpl.createPDF(ReportServiceImpl.java:160)
2009/9/10 Mark Mandel <mark....@gmail.com>:
From there you can normally determine what is missing.
Mark
--
An update. We've got this working today.
My colleague found this thread: http://forums.adobe.com/thread/40084
It suggested renaming the jasper reports jar to start with the letter
"a" so it appears in the classpath first. I also found that I needed
to do the same with the itext jars.
So what I have is this setup:
In C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\lib
a-jasperreports-3.5.3.jar
a-itext-2.1.0.jar
Then the rest of my jars in my "lib" subdirectory.
I load these as follows:
<cfdirectory action="list" name="qJars" directory="#jarPath#"
filter="*.jar" sort="name asc"/>
<cfloop query="qJars">
<cfscript>
ArrayAppend(aJars, directory & separator & name);
</cfscript>
</cfloop>
<cfset loader = createObject("component",
"javaloader.JavaLoader").init(aJars,true)>
And can call the code without trouble.
It's not what I'd call elegant, and I've probably just broken
cfreports, but I am not using that anyway.
Thought I should post this follow-up anyway for completeness in case
anyone else ever needs it.
Andrew.
c:\www\national-website\html\root\testapp
(c:\www\national-website\html\root\ being my web root).
The jars were in
c:\www\national-website\html\root\testapp\lib
Obviously I'll tidy this up when and if we come to deploy it, but that
was my test setup.
Andrew.
2009/9/11 Mark Mandel <mark....@gmail.com>:
2009/9/11 Mark Mandel <mark....@gmail.com>: