Hi all,
Would be very much appeciative if someone could point me in the right direction
try {
if (conn != null) {
File f = new File(reportFile);
InputStream is = new FileInputStream(f);
JasperReport jasperReport = JasperCompileManager.compileReport(
is);
jasperPrint = JasperFillManager.fillReport(jasperReport, params, conn);
}
} catch (JRException ejr) {
ejr.printStackTrace();
}catch (Exception __ex) {
__ex.printStackTrace();
}
it gives me the following exception :
java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:161)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:119)
at net.sf.jasperreports.engine.util.JRSingletonCache.createInstance(JRSingletonCache.java:88)
at net.sf.jasperreports.engine.util.JRSingletonCache.getCachedInstance(JRSingletonCache.java:78)
at net.sf.jasperreports.engine.util.JRTextMeasurerUtil.getTextMeasurerFactory(JRTextMeasurerUtil.java:118)
at net.sf.jasperreports.engine.util.JRTextMeasurerUtil.createTextMeasurer(JRTextMeasurerUtil.java:103)
at net.sf.jasperreports.engine.util.JRTextMeasurerUtil.createTextMeasurer(JRTextMeasurerUtil.java:90)
Thanks in advance for any help
Fraser Williams
Would be very much appeciative if someone could point me in the right direction
try {
if (conn != null) {
File f = new File(reportFile);
InputStream is = new FileInputStream(f);
JasperReport jasperReport = JasperCompileManager.compileReport(
is);
jasperPrint = JasperFillManager.fillReport(jasperReport, params, conn);
}
} catch (JRException ejr) {
ejr.printStackTrace();
}catch (Exception __ex) {
__ex.printStackTrace();
}
it gives me the following exception :
java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:161)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:119)
at net.sf.jasperreports.engine.util.JRSingletonCache.createInstance(JRSingletonCache.java:88)
at net.sf.jasperreports.engine.util.JRSingletonCache.getCachedInstance(JRSingletonCache.java:78)
at net.sf.jasperreports.engine.util.JRTextMeasurerUtil.getTextMeasurerFactory(JRTextMeasurerUtil.java:118)
at net.sf.jasperreports.engine.util.JRTextMeasurerUtil.createTextMeasurer(JRTextMeasurerUtil.java:103)
at net.sf.jasperreports.engine.util.JRTextMeasurerUtil.createTextMeasurer(JRTextMeasurerUtil.java:90)
Thanks in advance for any help
Fraser Williams
12 Answers:
Posted on January 31, 2008 at 5:43pm
Thanks for your response. My classpath has no other versions of the jasperreports jars.
I have a directory where I have put the iReport program. I have put a small application in the same directory which offers a menu system for the user to view a report. The user double clicks the report and the report is supposed to show in the JRViewer however I am getting the error as described above. IReport works like a charm from the same folder so it puzzles me as to why my program doesn't. Hmmmm!
I code with Netbeans the jasperreports jars are referenced in the libraries and no other classpath information is specified.
Fraser
I have a directory where I have put the iReport program. I have put a small application in the same directory which offers a menu system for the user to view a report. The user double clicks the report and the report is supposed to show in the JRViewer however I am getting the error as described above. IReport works like a charm from the same folder so it puzzles me as to why my program doesn't. Hmmmm!
I code with Netbeans the jasperreports jars are referenced in the libraries and no other classpath information is specified.
Fraser
Posted on April 18, 2008 at 6:25am
Hi,
For information, I solved this problem modifying the default.jasperreports.properties file as follow :
Replace
For information, I solved this problem modifying the default.jasperreports.properties file as follow :
Replace
Code: |
<br /> #Default text measurer<br /> net.sf.jasperreports.text.measurer.factory=default<br /> net.sf.jasperreports.text.measurer.factory.default=net.sf.jasperreports.engine.fill.TextMeasurerFactory</td></tr></tbody></table><br /> <br /> by<br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><br /> #Text measurer (overridden because of a NullPointerException in JRClassLoader...)<br /> net.sf.jasperreports.text.measurer.factory=net.sf.jasperreports.engine.fill.TextMeasurerFactory</td></tr></tbody></table><br /> <br /> I hope this will help...<br /> JB |
Posted on June 19, 2008 at 8:42pm
I got the same problem as this when moving from Jasper 2.0.1 to 3.0.0, and I tracked it down. To repeat, this is the stack trace:
Code: |
<br /> java.lang.NullPointerException<br /> at java.lang.Class.forName0(Native Method)<br /> at java.lang.Class.forName(Unknown Source)<br /> at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:161)<br /> at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:119)<br /> at net.sf.jasperreports.engine.util.JRSingletonCache.createInstance(JRSingletonCache.java:88)<br /> at net.sf.jasperreports.engine.util.JRSingletonCache.getCachedInstance(JRSingletonCache.java:78)<br /> at net.sf.jasperreports.engine.util.JRTextMeasurerUtil.getTextMeasurerFactory(JRTextMeasurerUtil.java:118)<br /> at net.sf.jasperreports.engine.util.JRTextMeasurerUtil.createTextMeasurer(JRTextMeasurerUtil.java:103)<br /> at net.sf.jasperreports.engine.util.JRTextMeasurerUtil.createTextMeasurer(JRTextMeasurerUtil.java:90)<br /> at net.sf.jasperreports.engine.fill.JRFillTextElement.createTextMeasurer(JRFillTextElement.java:115)<br /> at net.sf.jasperreports.engine.fill.JRFillTextElement.ensureTextMeasurer(JRFillTextElement.java:122)<br /> at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:972)<br /> at net.sf.jasperreports.engine.fill.JRFillStaticText.prepare(JRFillStaticText.java:193)<br /> at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:344)<br /> at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:346)<br /> at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:305)<br /> at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:313)<br /> at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:247)<br /> at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:113)<br /> at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:879)<br /> at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:801)<br /> at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)<br /> at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)<br /> at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:492)<br /> at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:448)<br /> </td></tr></tbody></table><br /> <br /> I am not fluent with the Jasper source enough to propose a fix, but I now where the problem occurs. In net.sf.jasperreports.engine.util.JRTextMeasurerUtil line 86 there is this function:<br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><br /> public static JRTextMeasurer createTextMeasurer(JRCommonText text)<br /> {<br /> JRPropertiesHolder propertiesHolder =<br /> text instanceof JRPropertiesHolder ? (JRPropertiesHolder) text : null;<br /> return createTextMeasurer(text, <br /> propertiesHolder);<br /> }<br /> </td></tr></tbody></table><br /> As you can see, if the input is not an instance of JRPropertiesHolder then the function ends with a call to createTextMeasurer(text, null).<br /> <br /> createTextMeasurer calls other functions to load a class based upon its second input parameter, and naturally this throws a NullPointerException. |
Posted on June 20, 2008 at 3:12pm
EsauCairn wrote:
I am not fluent with the Jasper source enough to propose a fix, but I now where the problem occurs. In net.sf.jasperreports.engine.util.JRTextMeasurerUtil line 86 there is this function:
|
Posted on June 20, 2008 at 9:10pm
lucianc,
You were correct and I was wrong. I apologize for posting unhelpful data.
All I can see is that if you replace
net.sf.jasperreports.text.measurer.factory=default
net.sf.jasperreports.text.measurer.factory.default=net.sf.jasperreports.engine.fill.TextMeasurerFactory
with
net.sf.jasperreports.text.measurer.factory=net.sf.jasperreports.engine.fill.TextMeasurerFactory
The null pointer exception goes away.
The problem baffles me. To reproduce the problem, I simply need to run:
You were correct and I was wrong. I apologize for posting unhelpful data.
All I can see is that if you replace
net.sf.jasperreports.text.measurer.factory=default
net.sf.jasperreports.text.measurer.factory.default=net.sf.jasperreports.engine.fill.TextMeasurerFactory
with
net.sf.jasperreports.text.measurer.factory=net.sf.jasperreports.engine.fill.TextMeasurerFactory
The null pointer exception goes away.
The problem baffles me. To reproduce the problem, I simply need to run:
Code: |
<br /> String path = getPath(); <br /> String fileName = getReportFileName();<br /> Map parameters = new HashMap(); <br /> populate(parameters); <br /> <br /> JasperCompileManager.compileReportToFile(path + filename + ".jrxml"«»);<br /> JasperFillManager.fillReportToFile(path+filename+".jasper", parameters, new JREmptyDataSource()); <br /> </td></tr></tbody></table><br /> <br /> It runs without errors with the change to the default.jasperreports.properties configuration file above, and gives the noted nullpointerexception otherwise.<br /> <br /> I'll try to take another stab at this over the weekend, see if I can't lock it down. Thanks for your help. |
Posted on June 23, 2008 at 4:11pm
This baffles me as well. That's why I want to understand what happens.
In any case, this occurred several times, so it's a real problem. Please log it as a bug [url=http://jasperforge.org/sf/tracker/do/listArtifacts/projects.jasperreport....
In the worst case, if we don't understand why this happens, we could still apply the fix suggested here. We don't usually fix things without understanding where the problem is, but since the described fix would not make any harm, we could consider applying it.
Regards,
Lucian
In any case, this occurred several times, so it's a real problem. Please log it as a bug [url=http://jasperforge.org/sf/tracker/do/listArtifacts/projects.jasperreport....
In the worst case, if we don't understand why this happens, we could still apply the fix suggested here. We don't usually fix things without understanding where the problem is, but since the described fix would not make any harm, we could consider applying it.
Regards,
Lucian
Posted on June 23, 2008 at 5:13pm
I would prefer to wait to file the report until I can pinpoint the problem and possibly recommend a solution.
I took the jar file out of my project. Instead, I included the source code from Jasper 3.0.0 into my project, built it, and ran it. The bug did not appear. This is, naturally, puzzling. When the bug appears in the .jar, the stack trace line numbers match the source code line numbers exactly, so I consider the possibility that the official .jar has separate code from the source tree to be very small.
Next I am going to use the .jar and replace the affected class files with ones compiled from source one at a time to pinpoint the problem.
I took the jar file out of my project. Instead, I included the source code from Jasper 3.0.0 into my project, built it, and ran it. The bug did not appear. This is, naturally, puzzling. When the bug appears in the .jar, the stack trace line numbers match the source code line numbers exactly, so I consider the possibility that the official .jar has separate code from the source tree to be very small.
Next I am going to use the .jar and replace the affected class files with ones compiled from source one at a time to pinpoint the problem.
Posted on June 29, 2011 at 10:23pm
hi,
I have tried to edit the default.jasperreports.prop in jasper.jar, but still got the NullPointer exceptions, such as:
java.lang.NullPointerException
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:628)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:544)
What I am trying to do is: user jasper 3.5.3 with spring 3.0.2 on glassfish 2.1.
The next line is causing the trouble:
jasperPrint = JasperFillManager.fillReport(myFile.getPath(),parameters, jasperDs);
All of these parameters are not null, and has valid and good values in it.
Any ideas Guys?
thx