• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't read same object multiple times

 
Darryl Failla
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working with web services, JDeveloper, and JRLoader from Jasper Reports. JRLoader uses ObjectInputStream.readObject() to read the report object. It will read in the same object once or twice, but subsequent reads will throw a ClassNotFound exception. Why could this happen?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly what are your trying to do here?

It is the nature of ObjectInputStream that objects are only read once. If you can "rewind" the underlying InputStream, you would still need to create a new ObjectInputStram to get another copy of the object.

Bill
 
Darryl Failla
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a compiled jasper report: dodimrcat1.jasper. I'm using the code below to load the object. The loadObject() method in JRLoader throws a ClassNotFoundException when I run through this code a second time to service a second request. It appears to be in the deserializing of one of the classes contained in the report such as JRBaseLine or JRBaseRectangle.

File reportFile = new File("C:\\WS_examples\\dodimrcat1.jasper");
JasperReport jasperReport = null;
try
{
jasperReport = (JasperReport) JRLoader.loadObject(reportFile.getPath());
System.out.println("Got compiled report");
}catch(JRException jrExp){
jrExp.printStackTrace();
}
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a tough one! Perhaps JRLoader is not handling the file correctly at some point - have you tried to contact the author?
Is there some reason you have to use JRLoader instead of creating a regular ObjectInputStream directly?
Where have you placed the Jasper specific library files?
Bill
 
Darryl Failla
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the problem when I updated my version of JDeveloper from 9.0.4 to 9.0.5.2. From that point on, everything worked as expected.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic