• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need Help With: java.io StreamCorruptedException invalid stream header

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ALL:

1. I hope this the proper forum. For some time I have tried to correct an error: "java.io StreamCorruptedException invalid stream header" , reoccuring in Jasper Reports source code.

2. Based upon requirements, The Program packages variables into a HashMap, and creates a "BLOB" object which is inserted into an Oracle database. At a later point, the BLOB object is retrieved, and the "BLOB" contents are read into a byte array. The next occurring task is to retrieve data from the receiving byte array and reconstitute the original HashMap object.
THIS IS WHEN THE PROGRAM FAILS !!!

3. I can verify the number of bytes going in/out of the "BLOB" object as being the same count. I have tried different approaches listed on diverse sites w/o success. My Source Code Follows:

************************************************************************************
// I tried to include only germane source code.

// THIS SECTION GETS THE BLOB OBJECT AND PUTS IT INTO A BYTE //ARRAY


rs = ps.executeQuery();

if (rs.next())
{
BLOB myblob =((OracleResultSet)rs).getBLOB("JASPERDATA");
int chunkSize = myblob.getChunkSize();
System.out.println("Incomming DATA size is ........." + chunkSize);
textbuffer = new byte[chunkSize];

int bytesRead;
InputStream myis = myblob.getBinaryStream();
OutputStream myout = myblob.getBinaryOutputStream();
while((bytesRead = myis.read(textbuffer) )!= -1)
{

myout.write(textbuffer);

}
myout.flush();

"" //code not germane to Discussion
""
""
return (textbuffer); //Returns Byte Array
*************************************************************************************

// I tried to include only germane source code.

byte [] textbuffer = adb.getBLOBFromQueue(dataFile); // Get Byte Array from above.

int textbufferLength = textbuffer.length;

HashMap localParamValueMap = null;
Object in = new ObjectInputStream(new ByteArrayInputStream(textbuffer ));
localParamValueMap = (HashMap) ((ObjectInputStream) in).readObject(); // THIS IS THE PROBLEM AREA EXCEPTION OCCURS AT "readObject"
***********************************************************************
// ERROR RECEIVED IN TOMCAT
//ERROR CALLSTACK
java.io.StreamCorruptedException: invalid stream header
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:737)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:253)
at com.entservlet.DisplayJasperReports.doGet(DisplayJasperReports.java:72)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)


Any help rendered would be greatly appreciated.

Thanks .............

 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chunk size is not the size of the stored object. It is a parameter that determines how the data is stored on disk (see here for more).
Also, you cannot write data with an OutputStream and read it with an ObjectInputStream. ObjectInputStream can only read data that has been written with an ObjectOutputStream. See the Java Tutorial chapter on IO.
[ May 03, 2007: Message edited by: Joe Ess ]
 
michael turner
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The source code was derived from textbook "ORACLE 9i JDBC Programming" Copyright 2002 by Jason Price "page 314" . I am looking for assistance NOT INSULTS.... If you cannot provide the former why respond at all???
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by michael turner:
I am looking for assistance NOT INSULTS.... If you cannot provide the former why respond at all???



 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ouch.

I understand your frustration, but please be nice.
It is our number one rule.
 
reply
    Bookmark Topic Watch Topic
  • New Topic