Jump to content

NPE with stack trace trying to loadObject(File)


jkratz

Recommended Posts

On Windows I'm getting the follow stack trace when trying to load a compiled .jasper file (happens with any report...even very simple ones)

 

java.lang.NullPointerException
    at net.sf.jasperreports.engine.JRPropertiesMap.readObject(JRPropertiesMap.java:185)
    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:585)
    Truncated. see log file for complete stacktrace
 

I've seen this before when trying to load a compiled version of a report on a different version of JasperReports but in this case the library i'm using on Weblogic is  jasperreports-3.0.1-javaflow.jar and the report was written/comiled with iReport 3.0.0.  I have not set older compatibility, etc.

The report actually runs fine in iReport as well.   It also runs fine in the web environment when run on Linux or Mac OS X.  I am having the issue on Windows XP and Vista.  Java 1.5.0_16 running both the app server and iReport.  I do not have any older versions of Jasper on my system .... everything is version 3.  Doesn't make a difference whether I'm exporting to HTML, PDF, whatever.  It simply can't load the compiled report.

I've almost lost all my hair due to tearing it out over not being able to get around this NPE.  I'm hoping someone here has an idea of what is going on.

I've tried searching the bug tracker but, quite frankly, that tracker doesnt work worth a damn and I couldn't find anything.  Why an open source java project isn't using JIRA is beyond me but thats another post.

Thanks,

Jason

Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

Are you sure you don't have an older JR version on your application's classpath?

Because the stacktrace you posted does not correspond to JR 3.0.1 sources - in JR 3.0.1 JRPropertiesMap.java:185 does not fall in the readObject method.

You can check the JR version at runtime by doing something like

System.out.println(JRPropertiesMap.class.getPackage().getImplementationVersion());

somewhere in your code.

You can also do something like

System.out.println(JRPropertiesMap.class.getResource("/net/sf/jasperreports/engine/JRPropertiesMap.class"));

to find out where the JRPropertiesMap class is loaded from.

Regards,

Lucian

Link to comment
Share on other sites

Thanks Lucian.  I'll give that a try.  Pretty sure there arent older copies anywhere since I deleted even the copy of jasper 2.x that I had in a download directory :)   But none of this makes sense so I'll follow your suggestion and see if somehow I missed something.

 

Thanks,

Jason

Link to comment
Share on other sites

OK.  This is really odd and I'm posting this just in case someone might find themselves in the same situation with the same software. 

I'm running MyEclipse 6.5 with Weblogic 9.2 on Windows XP.   We have been using JasperReports 3.0 for several releases of one of our web applications.   I started with Jasper 2.0.5.

Weblogic, when it runs, keeps a cache of items in your domain directory in a location similar to:

C:optbeauser_projectsdomainsf58_domainserversAdminServertmp_WL_user_appsdir_rocketscienceApp_dirr6vnzfAPP-INFlib

For some reason all 4 versions of the JasperReports library are in there when we only deploy one version to APP-INF/lib.  The odd thing is that its not even the javaflow version we switched to when we moved to version 3 of the library.  We now have versions 2.0.5, 3.0 (javaflow), 3.0.1 (javaflow), 3.1.0 (javaflow).  (I had tried 3.1.0 in desperation).

So not only did Lucian solve my problem but I also learned something new about the Class class and how to find out where resources are loading from.

 

Link to comment
Share on other sites

  • 8 months later...

Hi

 

I am also facing the same problem. When I use the newer version of iReport(3.5.1) to generate the report i am getting this exception.

 

But when I use the older version of iReport(2.0.5) to generate the report I am not getting this exception.

 

Is this a bug in iReport or JasperReport?

 

The following is the exception I am getting when I use iReport 3.5.1

 

I am in the urgent need of the fix for this issue. Any help in this regard will be appreciated.

 

DNV Srikanth

Code:



Post Edited by dnvsrikanth at 06/02/2009 11:11



Post Edited by dnvsrikanth at 06/02/2009 11:29
Link to comment
Share on other sites

  • 1 year later...
  • 8 months later...

Old post but still very helpful.  It was working on Windows under SpringSource toolkit but when i went to deploy it on Linux Fedora, it failed with the same error.  In my case, it was picking up an old jasper 2.x jar that came with SpringSource.  Getting rid of that old jar fixed the problem.  I had to add a few other Apache jar dependencies as documented under Maven, but that was trivial.   SpringSource had been able to resolve those dependencies under Windows.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...