Java.io.StreamCorruptedException: invalid stream header

I am having a problem with sending two objects (over a socket). I have read in other posts that this could be due to trying to receive incompatible data types but my applications work fine if I send my objects synchronously rather than asynchronously.
I will try my best to describe what my problem is as my code is very long.
I have a server and a client application (2 apps). Multiple clients connect to the server and send their details (as an object) to the server. The server then amends the object (adds some more data) and sends it back to the clients. Both the SendObject and ReceiveObject class are threads and I have created a Listener (within the client) that activates when an object is received (asynchronous communication). The Listener method looks to see if the event is an instance of a particular class and casts is as appropriate (as per below).
public void receivedObject(ReceivedObjectEvent e) {
     ReceiveObjectThread obj = (ReceiveObjectThread) e.getObject();
     if(obj.getObject() instanceof Player) {
          thePlayer = (Player) obj.getObject();
          theTable.setHandData(thePlayer.getHand());
     if(obj.getObject() instanceof GameData) {
          gameData = (GameData) obj.getObject();
          theTable.setPlayerList(gameData.getOpponents());
}The objects that are passed between applications both implement Serializable.
This all works fine synchronously object passing. However, if I try and spawn two sendObject threads within the server and the corresponding two receive threads within the client and wait for the Listener to activate (asynchronously) I get the following error:
java.io.StreamCorruptedException: invalid stream header: 00057372
     at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
     at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
     at ReceiveObjectThread.run(ReceiveObjectThread.java:84)
java.io.StreamCorruptedException: invalid stream header: ACED0006
     at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
     at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
     at ReceiveObjectThread.run(ReceiveObjectThread.java:84)
I am sure that this problem is due to my limited knowledge on socket and data transfer. Therefore any help on this one will be gratefully received.

Hello ejp, your reply is very much appreciated.
If I explain how I have implemented my sockets you may be able to see where I wrong.
When a player connects, the client sends the server a �player� object. The server receives the �player� object and passes the socket from which it connected (within the server) to a socket property within the �player� class. Whenever the server needs to send an object to that client (player), it sends the output stream from the socket property within that �player� object. ( player.getSocket().getOutputStream() ).
Below is the code from the �SendObjectThread� class.
* This class allows an object to be passed over a Socket
* @author Harold Clements
* @version 1.0.1 12-Jun-2007 (12-Jul-2007)
//http://www.seasite.niu.edu/cs580java/Object_Serialization.html
public class SendObjectThread extends Thread {
     private OutputStream out;
     private Object obj;
      * This constructor allows the user to passes the two parameters for transmitting.
      * @param out The data stream that the object is going to be sent to.
      * @param obj The object to be sent.
     public SendObjectThread(OutputStream out, Object obj) {
          this.out = out;
          this.obj = obj;
      * The main thread
     public void run() {
          try {
               ObjectOutputStream objOut = new ObjectOutputStream(out);
               objOut.writeObject(obj);
               objOut.flush();
          } catch (IOException e) {
               e.printStackTrace();
}The client only has one socket which is defined when the client first makes a connection with the server. The �getOutputStream()� and �getInputStream()� are used for all communication from the client.
Is this what you described in your first option?
The funny thing about it all is if I create a new �receiveObjectTread� and wait for that to finish, then create another �receiveObjectTread� both objects in question (Player and GameData) are received correctly and the application works. I only have the problem when I set both threads off and leave it for the �ReceivedObjectEvent� listener to pick them up and cast them (as per my first post).
Thanks again for your help,
Harold Clements

Similar Messages

  • Getting "java.io.StreamCorruptedException: invalid stream header"

    When creating a self made Stream (MacInputStream) and then using an ObjectInputStream over it to read Objects from a socket, I get this error:
    java.io.StreamCorruptedException: invalid stream header
         at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:764)
         at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277)
         at TServidor.run(TServidor.java:32)
    Is there any special feature that the "self-made" streams have to implement to be possible to use ObjectInput streams over them :P ?
    Here is the MacInputStream.java code:
    import java.io.Closeable;
    import java.io.FilterInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Arrays;
    import javax.crypto.Mac;
    public class MacInputStream extends FilterInputStream implements Closeable{
         private Mac mac; // algorithm
         private byte [] mmac; //message MAC
         private boolean FIRST_TIME;
         public MacInputStream(InputStream is,Mac mac) {
              super(is);
              this.mac=mac;
              FIRST_TIME=true;
    public int read() throws IOException{
              if(FIRST_TIME){
                   mmac = new byte [mac.getMacLength()];
                   super.read(mmac);
              if(super.in.available()==0){
                   FIRST_TIME=true;
                   return -1;
              int rbyte = super.in.read();
              FIRST_TIME=false;
              mac.update((byte)rbyte);
              System.out.println("available: "+super.in.available());          
              if(super.in.available()==0){
                   byte [] macres =mac.doFinal();
                   System.out.println("message MAC: "+new String(mmac));
                   System.out.println("calculated MAC: "+new String(macres));
                   if(!Arrays.equals(macres, mmac)){
                        throw new IOException("violated integrity");
              return rbyte;
    public int read(byte [] b) throws IOException{
         if(FIRST_TIME){
              mmac = new byte [mac.getMacLength()];
              super.in.read(mmac);          
         if(super.available()==0){
              FIRST_TIME=true;
              return -1;
         int rbytes = super.in.read(b);
         FIRST_TIME=false;
         mac.update(b);
         if(super.available()==0){
              byte [] macres =mac.doFinal();
              if(!Arrays.equals(macres, mmac)){
                   throw new IOException("violated integrity");
         return rbytes;
    }And here is the "main" function where the exception gets thrown:
    public void run() {
         try {
              ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());
              Mac mac = Mac.getInstance("HmacMD5");
              Key key = KeyGenerator.getInstance("HmacMD5").generateKey();          
              oos.writeObject(key);
              oos.flush();
              mac.init(key);          
              ObjectInputStream cis = new ObjectInputStream(new MacInputStream(s.getInputStream(),mac));
             String test;
             try {
                   while (true) {
                        test = (String)cis.readObject();
                        System.out.println(ct + " : " + test);
              } catch (EOFException e) {
                   System.out.println("["+ct + "]");
              } finally {
              if (cis!=null) cis.close();
              if (oos!=null) oos.close();
         } catch (Exception e) {
             e.printStackTrace();
        }It's exactly in the line: ObjectInputStream cis = new ObjectInputStream(new MacInputStream(s.getInputStream(),mac));Any ideas?
    I'm starting to desperate :P

    (a) I still don't see where you are writing the MAC that you're reading. You're reading something, but it's all or part of the Object stream header I described above, which is why ObjectInputStream' constructor is throwing that exception.
    (b) You don't need to override read(byte[] b) when you extend FilterInputStream, but you do need to override read(byte[] b, int offset, int length), and you need to do it like this:
    public int read(byte[] buffer, int offset, int length) throws IOException
      int count = 0;
      do
        int c = read();
        if (c < 0)
            break;
        buffer[offset+count++] = (byte)c;
      } while (count < length && available() > 0);
      return count > 0 ? count : -1;
    }This way the read() method gets to see every byte that's read and to do its MAC thing or whatever it does. The above is one of only two correct uses of available() in existence: it ensures that you only block once while reading, which is the correct behaviour e.g. on a network.

  • Need Help With: java.io StreamCorruptedException invalid stream header

    All:
    1. 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)

    Be sure that you are not seeing a secondary problem.
    In my case, with serialized objects back to the client, the client will see this expection when any of the following occurs:
    1) The server has timed out the session and instead of sending back an object, the object stream is seeing the login page.
    2) An error is occured somewhere inside of the jsp code and instead of getting a the expected serailized object in the stream, I'm getting the 500 status page...
    So...
    In your case you are going from one server to tomcat but I wouldn't be surprised if something similar is going on.
    -Dennis

  • Problem with StreamCorruptedException: invalid stream header: 3C68746D

    Hi
    I am attempting to code a project in Java which involves the user of object serialization to send a String via serialization from an applet embedded in a JSP tp a servlet all files are running on the same machine for testing purposes.
    However I seem to be getting StreamCorruptedException: invalid stream header: 3C68746D whenever I attempt to read the inputstream once I have written to it.
    My code is as follows below (I apologise for the lack of details I have attempted to comment and simplify my code as much as possible for improved readability)
    ////////////////////////APPLET CODE////////////////
    import java.io.*;
    import java.io.Serializable;
    import javax.servlet.http.*;
    import java.applet.*;
    import javax.swing.*;
    import java.net.*;
    *Compiled using netbeans 5.1
    *Uses Apache server embedded with netbeans
    *JSP address http://localhost:8084/TestServ
    *Applet is embedded within this page
    *Servlet address http://localhost:8084/TestServ/TServ
    public class Main extends javax.swing.JApplet {
    JFrame jf;//frame for the test applet
    JTextArea jt;//result text box
    public Main() {
    jt=new JTextArea();//set up applet
    this.add(jt);
    URL servletURL;
    HttpURLConnection servletConnection;
    InputStream iStream=null;
    try
    {   //this address as far as is known is correct
    servletURL = new URL( "http://localhost:8084/TestServ/TServ" );
    //open connection to servlet
    servletConnection = (HttpURLConnection)servletURL.openConnection();
    //set up connection
    servletConnection.setDoInput(true);
    servletConnection.setDoOutput(true);
    servletConnection.setUseCaches(false);
    servletConnection.setDefaultUseCaches(false);
    //have tried "GET" and "POST" and "PUT"(PUT not directly compatible with apache servers)
    servletConnection.setRequestMethod("POST");
    servletConnection.setRequestProperty("Content-type","application/octet-stream");
    /*Have also tried application/x-java-serialized-object*/
    //set object output stream
    ObjectOutputStream outStream =
    new ObjectOutputStream(servletConnection.getOutputStream());
    //write a string for test purposes (As far as I am aware String implements Serializable)
    outStream.writeObject("h");
    //flush and close connection
    //have tried a combination of flush and/or close
    outStream.flush();
    outStream.close();
    //get input stream rdy for objectinput stream
    iStream = servletConnection.getInputStream();
    catch(IOException e)
    jt.setText("Error in output "+e);
    ObjectInputStream oInStream=null;
    String str = iStream.toString();
    //iStream at this point equals ""sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@6754d6
    try
    //this is where the error occurs
    //upon even trying to create a objectinputstream using iStream IOException occurs
    oInStream = new ObjectInputStream(iStream);
    //program does not get any further
    oInStream.close();
    catch(IOException e)
    //this error has been driving me crazy :(
    jt.setText("Error in input "+e);
    Servlet code is below however it does not even reach this point
    (If reading input stream is removed from the applet the servlet provides the same error message)
    /////////////////////Servlet code (however does not reach this point)///////////////
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class TServ extends HttpServlet {
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    ObjectInputStream inputFromApplet = null;
    InputStream in = request.getInputStream();
    BufferedReader inTest = null;
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet TServ</title>");
    out.println("</head>");
    out.println("<body>");
    try
    inputFromApplet = new ObjectInputStream(in);
    out.println("<h2>Sucess </h1>");
    catch(EOFException e)
    out.println("<h3>ERROR: " e " Error</h3>");
    out.println("<h3>End Servlet</h3>");
    out.println("</body>");
    out.println("</html>");
    out.close();
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    public String getServletInfo() {
    return "Short description";
    Thank you for your time I have searched for an answer for some time now and how found people in similar situations however no solution has been found
    Any help is appreciated
    Az

    The servlet isn't writing any objects back in reply. It is writing text. Not the same thing. If you want to read using an ObjectInputStream you have to write using an ObjectOutputStream.

  • Invalid stream header exception

    hi all
    I have a program to encrypt/decrypt a file using existing secret key
    which is generated by my java code and it works fine. I got a key from a friend and an encrypted file to decrypt it but the program throws this exception:
    java.io.StreamCorruptedException: invalid stream header: 87449FAA
    Exception in thread "main" java.security.InvalidKeyException: No
    installed provider supports this key: (null) this is my code:
    try
        //throws exception here
        ObjectInputStream in = new ObjectInputStream(new
    FileInputStream("key.dat"));
        key = (SecretKey)in.readObject();
        byte[] raw = key.getEncoded();
        skeySpec = new SecretKeySpec(raw, "AES");
        in.close();
    catch (Exception e)
        System.out.println(e);
    Cipher cipher = Cipher.getInstance("AES");
    cipher.init(Cipher.DECRYPT_MODE, skeySpec); Honestly i don't know how my friend creates the secret key but i think he uses some key generation tools. I suppose the key file is not corrupted because he used it to encrypt/decrypt other files.

    Looks like your friend did not use Java serialization to save the key in the file.
    Edited by: sabre150 on Apr 13, 2008 5:27 PM

  • Invalid stream header Exception - AES PBE with SealedObject

    I am trying to do an PBE encryption with AES algorithm and SunJCE provider, using the SealedObject class to encrypt/decrypt the data...
    And Im still getting the "invalid stream header" exception. Ive searched this forum, readed lots of posts, examples etc...
    Here is my code for encryption (i collected it from more classes, so hopefully I didnt forget anything...):
        //assume that INPUT_STREAM is the source of plaintext
        //and OUTPUT_STREAM is the stream to save the ciphertext data to
        char[] pass; //assume initialized password
        SecureRandom r = new SecureRandom();
        byte[] salt = new byte[20];
        r.nextBytes(salt);
        SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        KeySpec keySpec = new PBEKeySpec(pass, salt, 1536, 128);
        SecretKey pbKey = factory.generateSecret(keySpec);
        SecretKeySpec key = new SecretKeySpec(pbKey.getEncoded(), "AES");
        Cipher ciph = Cipher.getInstance("AES/CTR/NoPadding");
        ciph.init(Cipher.ENCRYPT_MODE, key);
        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        int ch;
        while ((ch = INPUT_STREAM.read()) >= 0) {
          byteOut.write(ch);
        SealedObject sealed = new SealedObject(byteOut.toByteArray(), ciph);
        BufferedOutputStream bufOut = new BufferedOutputStream(OUTPUTSTREAM);
        ObjectOutputStream objOut = new ObjectOutputStream(bufOut);   
        objOut.writeObject(sealed);
        objOut.close();
      }And here is my code for decrypting:
        //assume that INPUT_STREAM is the source of ciphertext
        //and OUTPUT_STREAM is the stream to save the plaintext data to
        char[] pass; //assume initialized password
        SecureRandom r = new SecureRandom();
        byte[] salt = new byte[20];
        r.nextBytes(salt);
        SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        KeySpec keySpec = new PBEKeySpec(pass, salt, 1536, 128);
        SecretKey pbKey = factory.generateSecret(keySpec);
        SecretKeySpec key = new SecretKeySpec(pbKey.getEncoded(), "AES");
        BufferedInputStream bufIn = new BufferedInputStream(INPUT_STREAM);    //MARK #1
        ObjectInputStream objIn = new ObjectInputStream(bufIn);   
        SealedObject sealed = (SealedObject) objIn.readObject();   
        byte[] unsealed = (byte[]) sealed.getObject(key);          //MARK #2
        ByteArrayInputStream byteIn = new ByteArrayInputStream(unsealed);
        int ch;
        while ((ch = byteIn.read()) >= 0) {
          OUTPUT_STREAM.write(ch);
        OUTPUT_STREAM.close();Everytime I run it, it gives me this exception:
    Exception in thread "main" java.io.StreamCorruptedException: invalid stream header: B559ADBE
         at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
         at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
         at javax.crypto.SunJCE_i.<init>(DashoA13*..)
         at javax.crypto.SealedObject.unseal(DashoA13*..)
         at javax.crypto.SealedObject.getObject(DashoA13*..)
         at oopsifrovanie.engine.ItemToCrypt.decrypt(ItemToCrypt.java:91)  //MARKED AS #2
         at oopsifrovanie.Main.main(Main.java:37)    //The class with all code below MARK #1I've also found out that the hashCode of the generated "key" object in the decrypting routine is not the same as the hashCode of the "key" object in the ecrypting routine. Can this be a problem? I assume that maybe yes... but don't know what to do...
    When I delete the r.nextBytes(salt); from both routines, the hashCodes are the same, but that's not the thing I want to do...
    I think, that the source of problem can be this part of code (generating the key):
        SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        KeySpec keySpec = new PBEKeySpec(pass, salt, 1536, 128);
        SecretKey pbKey = factory.generateSecret(keySpec);
        SecretKeySpec key = new SecretKeySpec(pbKey.getEncoded(), "AES");But I derived it from posts like: [http://forums.sun.com/thread.jspa?threadID=5307763] and [http://stackoverflow.com/questions/992019/java-256bit-aes-encryption] and they claimed it's working there...
    Is there anyone that can help me?
    Btw, I don't want to use any other providers like Bouncycastle etc. and I want to use PBE with AES and also SealedObject to store the parameters of encryption...

    Yes, it really uses only one Cipher object, but it does decoding in a little nonstandard (not often used) way, by using the SealedObject class and its getObject(Key key) method. You can check these links for documentation: [http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#SealedObject] and [http://java.sun.com/javase/6/docs/api/javax/crypto/SealedObject.html] So the question is, why it doesn't work also with the AES routines, because it should.
    Btw, according to [http://java.sun.com/javase/6/docs/technotes/guides/security/SunProviders.html#SunJCEProvider] PBEWithSHA1AndDESede/CBC/PKCS5Padding is a valid JCE algorithm for the Cipher class.
    Firstly, I was generating the key for AES enc./decryption this way and it was working:
    char[] pass; //assume initialized password
    byte[] bpass = new byte[pass.length];
        for (int i = 0; i < pass.length; i++) {
          bpass[i] = (byte) pass;
    SecretKeySpec key = new SecretKeySpec(bpass, "AES");
    But I think, that it really wasn't secure, so I wanted to build a key from the password using the PBE.
    Maybe there's also a way how to do this part of my AES PBE algorithm: *KeySpec keySpec = new PBEKeySpec(pass, salt, 1536, 128);* manually (with my own algorithm), but I dont know how to do it and I'd like it to be really secure.
    Btw, thanks for your will to help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Hi,I'm Chinese.java.io.StreamCorruptedException: invalid type code: 6A?

    Hello! please help me, thanks! I'm Chinese.first to the sun forums.My English is bad,so sorry!
    &#20320;&#22909;&#65281;&#24863;&#35874;&#20320;&#30340;&#24110;&#21161;&#65281;&#31532;&#19968;&#27425;&#26469;&#21040;sun &#35770;&#22363;&#26469;&#25552;&#38382;&#65292;&#24456;&#28608;&#21160;&#21834;&#65292;&#21621;&#21621;&#12290;
    java.io.StreamCorruptedException: invalid type code: 6A
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at controller.NetController$Receiver.run(NetController.java:88)
    at java.lang.Thread.run(Thread.java:619)
    java.io.StreamCorruptedException: invalid type code: 6A
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at controller.NetController$Receiver.run(NetController.java:88)
    at java.lang.Thread.run(Thread.java:619)
    Exception in thread "Thread-3" java.lang.NullPointerException
    at controller.DoubleModeController.updateYourCtrl(DoubleModeController.java:127)
    at controller.DoubleModeController.receiveObj(DoubleModeController.java:123)
    at controller.NetController$Receiver.run(NetController.java:92)
    at java.lang.Thread.run(Thread.java:619)
    &#19979;&#38754;&#26159;NetCotroller&#31867;&#30340;&#19968;&#20010;&#20869;&#37096;&#31867;&#65292;&#36127;&#36131;&#25509;&#25910;&#25968;&#25454;&#65306;
    This is a inner class of NetCotroller class, it receive datas:
    Java code
    private class Receiver implements Runnable {
            @Override
            public void run() {
                while(isRunning) {
                    ObjectInputStream ois = null;
                    try {
                        byte[] receiveBytes = new byte[1024*2];
                        dp = new DatagramPacket(receiveBytes, receiveBytes.length);
                        ds.receive(dp);
                        System.out.println("receive ...@_@");
                        ByteArrayInputStream bais = new ByteArrayInputStream(receiveBytes);
                        ois = new ObjectInputStream(bais);
                       //&#21040;&#19979;&#38754;&#36825;&#21477;&#26102;&#65292;&#23601;&#25243;&#20986;&#20102;&#37027;&#24322;&#24120;&#65281;
               // this sentence throw the Exception
                        receiveObj = ois.readObject();
                        ois.close();
                        ncl.receiveObj((Object[])receiveObj);
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (ClassNotFoundException e) {
                        e.printStackTrace();
        }

    1.
    I changed the code to this(when datagram was fragmented, just leave it alone,and back to "ds.receive(dp);" ):
    Is it OK?
    private class Receiver implements Runnable {
    @Override
    public void run() {
    boolean isCorrupted = false;//changed
    while(isRunning) {
    isCorrupted = false;//changed
    ObjectInputStream ois = null;
    Object o = null;
    try {
    byte[] receiveBytes = new byte[1024*5];
    dp = new DatagramPacket(receiveBytes, receiveBytes.length);
    ds.receive(dp);
    ByteArrayInputStream bais = new ByteArrayInputStream(receiveBytes);
    ois = new ObjectInputStream(bais);
    o = ois.readObject();
    } catch (IOException e) {
    isCorrupted = true;//changed
    System.out.println(o);
    System.out.println("IOException---NetController--receiver");
    // e.printStackTrace();
    } catch (ClassNotFoundException e) {
    System.out.println("ClassNotFoundException---NetController--receiver");
    if(!isCorrupted) {//changed
    System.out.println("receive ...@_@..." + Arrays.toString((Object[])o));
    ncl.receiveObj((Object[])o);
    }2.Is there a src of "Russia Block of Net"?Please send it to my e-mail ([[email protected]|mailto:[email protected]]), thank you very much!
    Edited by: HolleWorld on Jan 2, 2010 1:51 AM

  • [java.nio] StreamCorruptedException when deserializing objects

    Hello everybody!
    I made a messaging (chat) program using java.io where all the client-server communication is done by serializing small objects. Now I would like to covert the server side to the NIO concept and I'm already struck. I successfully pass objects to the client and the client deserializes them, but only the first one! When it try to read the second it fails with a StreamCorruptedException.
    Here�s a sample (testing) code. In the server run() method I first serialize a string, then get its byte array from ByteArrayOutputStream and in the loop periodically send this byte array through the channel. On the client side I just read the deserialized object.
    Server run():
    public void run() {
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(baos);
                oos.writeObject("abcdefgh");
                byte[] objectArr = baos.toByteArray();
                baos.close();
                oos.close();
                ByteBuffer buff = ByteBuffer.allocate(objectArr.length);
                buff.put(objectArr);
                buff.flip();
                while(true) {
                    selector.select();
                    Set keys = selector.selectedKeys();
                    for (Object o : keys) {
                        SelectionKey key = (SelectionKey)o;
                        if (key.isAcceptable()) {
                            ServerSocketChannel server = (ServerSocketChannel) key.channel();
                            clientChannel = server.accept();
                            if (clientChannel == null)
                                continue;
                            clientChannel.configureBlocking(false);
                            SelectionKey clientKey = clientChannel.register(selector, SelectionKey.OP_WRITE);
                        } else if (key.isWritable()) {
                            SocketChannel client = (SocketChannel) key.channel();
                            if (buff.hasRemaining()) {
                                client.write(buff);
                            } else {
                                buff.clear();
                                buff.put(objectArr);
                                buff.flip();
                    try {
                        Thread.currentThread().sleep(2000);
                    } catch (InterruptedException e) {
                        return;
            } catch (IOException e) {
                e.printStackTrace();
        }Client run():
    public void run() {
            try {
                soc = new Socket("localhost", 4000);
                ObjectInputStream ois = new ObjectInputStream(soc.getInputStream());
                while(true) {
                    Object d = ois.readObject();
                    System.out.println("data = " + d.toString());
            } catch (Exception ex) {
                ex.printStackTrace();
        }At the second read I get a StreamCorruptedException.
    Apart from this I would like some hints in how to implement the application with NIO. For example how can I tell the objects apart on the client side � should I send every time a byte array before the object, which tells the length of the next coming object? This is probably not a 100% bulletproof solution and presents additional data transfer?
    Than you in advance!

    OK, I found a solution but I don't like it, because I don't understand it.
    The ObjectOutputStream adds a header (4 bytes) to the stream - if I send the array with those four bytes I get an StreamCorruptedException. If I send the array without the header I also get a StreamCorruptedException: "invalid stream header".
    If I reconstruct the object, by calling ObjectOutputStream.writeObject() and get it's byte array from ByteArrayOutputStream.toByteArray(), every time I have to fill the ByteBuffer, then it works.
    Here's the modified sending block, for the above example:
    } else if (key.isWritable()) {
                            SocketChannel client = (SocketChannel) key.channel();
                            if (buff.hasRemaining()) {
                                client.write(buff);
                            } else {
                                //* ---- added code ---------
                                baos.reset();
                                oos.writeObject("abcdefgh");
                                objectArr = baos.toByteArray();
                                buff.clear();
                                buff.put(objectArr);
                                buff.flip();
                        }   I really don't understand why I have to write the object in the object stream every time. I used ObjectOS and ByteArrayOS, to get the object byte array and then I thought I could forget about those streams and use this array to fill the ByteBuffer. What changes if I send the object through this process with every iteration (and how this harms speed - it's like sending everything twice)? If someone would explain this to me I would appreciate it much.

  • Send email by BDK API, get 500:"Invalid stream ID specified" error

    I am sending a simple email without attachment by BDK in 2.1 by following main three steps:
    1. login the server and get the anticsrf string.
    2. upload the email body content with URI:
    http://IP:Port/comb/v1/d/session/upload?uploadscope=25589676100454&content_id=25589676080060&anticsrf=zhu8nv%2BX%2FsA%3D
    3. send the mail with URI:
    http://IP:Port/comb/v1/d/emsg/send?uploadscope=25589676100454&debug=true&anticsrf=zhu8nv%2BX%2FsA%3D.
    In the third step, the server response 500 error and capture the server response package as following:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><obh:restFault xmlns:obr="http://www.oracle.com/beehive/rest" xmlns:obh="http://www.oracle.com/beehive"><obh:fault><obh:debugInformation><obh:serviceInstanceId>814dc480-dbc7-4e8f-a6fb-59808adadb4c</obh:serviceInstanceId><obh:stackTrace>java.lang.RuntimeException: Invalid stream ID specified: MjU1ODk2NzYwODAwNjA=
    at oracle.ocs.mail.csi.stream.EmailOperationContextImpl.getOutputStream(EmailOperationContextImpl.java:96)
    at oracle.beehive.platform.rest.resource.hui.stream.StreamInMethod.action(StreamInMethod.java:178)
    at oracle.beehive.platform.rest.core.Mauna.doRequest(Mauna.java:463)
    at oracle.beehive.platform.rest.servlet.LahainaServlet.doRequest(LahainaServlet.java:60)
    at weblogic.servlet.http.AbstractAsyncServlet.service.....
    My question is what steam id is used for, where to set the stream id and what kind of stream id is right?
    Thanks in advance!
    Edited by: user13304957 on May 9, 2011 12:53 AM

    find the answer,
    for sending an email, first, "upload scope" value in upload body and send msg should be the same, second, and the last, in the sending msg step, the StreamedSimpleContentUpdater.contenStreamID should be the same as content id used in uploading body.

  • StreamCorruptedException: invalid type code: AC

    I get the following error in java 6 running with tomcat 5.5.17.
    Error while deserializing the wrapped object: java.io.StreamCorruptedException: invalid type code: AC
    This does not happen in java 5 and my colleague does not get it with 5 or 6. We have checked our setups and can't see anything different.

    am having the same problem
    Edited by: prabhakar.s87 on Oct 12, 2007 2:27 PM

  • Java.util.zip.ZipException: invalid END header

    I get this error when I run the code:
    try {
    jFile = new JarFile(jarBuildFile.getAbsolutePath());
    } catch (IOException ex) {
    System.out.println("Got exception: "+ex);
    but only on very large jar files - about 2.5GB in size.
    With JDK 1.4, I get the error, jar file too large.
    With JDK 1.5, I get the above error (invalid END header).
    With JDK 1.6, it reads the file for about 5 seconds, then reports that the file cannot be opened.
    Smaller jar files work fine. This jar file has two files in it, a small XML file and a large video file.
    I'm running under windows XP.
    Doing a jar -tvf (jdk 1.5) on the large jar file works fine.
    The file was built with the jar command (jdk 1.5).
    Is this a bug in the JDK?
    Thank you!
    -Joe
    http://www.lovehorsepower.com

    Sp0ttedD0g wrote:
    I ran into this problem today too and found out it was due to the fact that I had a jar in my war that I was trying to deploy that had a file format of unicode instead of binary (it had been checked into source control system incorrectly). After updating the jar with the proper format (binary), the problem went away.The other reported problems are due to file size, not content.

  • Need help please ... ASAP  Possible attempt to access newer JMS  version then current version....java.io.StreamCorruptedException

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
              <HTML><HEAD>
              <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
              <META content="MSHTML 6.00.2900.2627" name=GENERATOR>
              <STYLE></STYLE>
              </HEAD>
              <BODY bgColor=#ffffff>
              <DIV><FONT face=Arial size=2>I am getting these error after changing table space
              size for my database ...</FONT></DIV>
              <DIV><FONT face=Arial size=2></FONT> </DIV>
              <DIV><FONT face=Arial size=2>I made changes in Database side for table space and
              restart server.. </FONT></DIV>
              <DIV><FONT face=Arial size=2></FONT> </DIV>
              <DIV><FONT face=Arial size=2></FONT> </DIV>
              <DIV><FONT face="Courier New" size=2><Jun 7, 2005 3:44:44 PM EDT>
              <Info> <JMS> <BEA-040321> <JMSServer "ss1 JMS Server" is
              resuming.><BR><Jun 7, 2005 3:44:45 PM EDT> <Alert> <JMS>
              <BEA-040052> <JMSServer "ss1 JMS Server" store failed to open
              java.io.StreamCorrup<BR>tedException: Unsupported class version 2. 
              Expected a value between 1 and 1 inclusive.  Possible attempt to access
              newer JMS<BR> version then current
              version..<BR>java.io.StreamCorruptedException: Unsupported class version
              2.  Expected a value between 1 and 1 inclusive.  Possible
              attempt<BR> to access newer JMS version then current
              version.<BR>        at
              weblogic.jms.common.JMSUtilities.versionIOException(JMSUtilities.java:111)<BR>       
              at
              weblogic.jms.store.JDBCIOStream.open(JDBCIOStream.java:438)<BR>       
              at
              weblogic.jms.store.JMSStore.open(JMSStore.java:224)<BR>       
              at
              weblogic.jms.backend.BEStore.open(BEStore.java:262)<BR>       
              at
              weblogic.jms.backend.BEStore.start(BEStore.java:151)<BR>       
              at
              weblogic.jms.backend.BackEnd.openStores(BackEnd.java:1171)<BR>       
              at
              weblogic.jms.backend.BackEnd.resume(BackEnd.java:1290)<BR>       
              at
              weblogic.jms.JMSService.addJMSServer(JMSService.java:2241)<BR>       
              at
              weblogic.jms.JMSService.addDeployment(JMSService.java:2012)<BR>       
              at
              weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(DeploymentTarget.java:330)<BR>       
              at
              weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(DeploymentTarget.java:590)<BR>       
              at
              weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeployments(DeploymentTarget.java:568)<BR>       
              at
              weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments(DeploymentTarget.java:240)<BR>       
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
              Method)<BR>        at
              sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<BR>       
              at
              sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<BR>       
              at
              java.lang.reflect.Method.invoke(Method.java:324)<BR>       
              at
              weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl.java:711)<BR>       
              at
              weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:690)<BR>       
              at
              weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBeanImpl.java:476)<BR>       
              at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1557)<BR>       
              at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)<BR>       
              at
              weblogic.management.internal.RemoteMBeanServerImpl.private_invoke(RemoteMBeanServerImpl.java:947)<BR>       
              at
              weblogic.management.internal.RemoteMBeanServerImpl.invoke(RemoteMBeanServerImpl.java:908)<BR>       
              at weblogic.management.internal.MBeanProxy.invoke</FONT></DIV></BODY></HTML>

    Hi
              I am also getting the similar error when I restart the server and my JMSSTORE table has some records, Here is the exception I am getting
              java.io.StreamCorruptedException: Unknown object stream version. 5505025
                   at weblogic.jms.store.BufferDataInputStream.readObject(BufferDataInputStream.java:167)
                   at weblogic.jms.store.JDBCIOStream.doRecoverBodies(JDBCIOStream.java:979)
                   at weblogic.jms.store.JDBCIOStream.doRecover(JDBCIOStream.java:871)
                   at weblogic.jms.store.JDBCIOStream.recover(JDBCIOStream.java:1090)
                   at weblogic.jms.store.JMSStore.recover(JMSStore.java:315)
                   at weblogic.jms.backend.BEStore.open(BEStore.java:264)
                   at weblogic.jms.backend.BEStore.start(BEStore.java:151)
                   at weblogic.jms.backend.BackEnd.openStores(BackEnd.java:1171)
                   at weblogic.jms.backend.BackEnd.resume(BackEnd.java:1290)
                   at weblogic.jms.JMSService.addJMSServer(JMSService.java:2241)
                   at weblogic.jms.JMSService.addDeployment(JMSService.java:2012)
                   at weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(DeploymentTarget.java:331)
                   at weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(DeploymentTarget.java:591)
                   at weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeployments(DeploymentTarget.java:569)
                   at weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments(DeploymentTarget.java:241)
                   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:324)
                   at weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl.java:731)
                   at weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:710)
                   at weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBeanImpl.java:484)
                   at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1557)
                   at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)
                   at weblogic.management.internal.RemoteMBeanServerImpl.private_invoke(RemoteMBeanServerImpl.java:985)
                   at weblogic.management.internal.RemoteMBeanServerImpl.invoke(RemoteMBeanServerImpl.java:943)
                   at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:946)
                   at weblogic.management.internal.MBeanProxy.invokeForCachingStub(MBeanProxy.java:481)
                   at weblogic.management.configuration.ServerMBean_Stub.updateDeployments(ServerMBean_Stub.java:7351)
                   at weblogic.management.deploy.slave.SlaveDeployer.updateServerDeployments(SlaveDeployer.java:1304)
                   at weblogic.management.deploy.slave.SlaveDeployer.resume(SlaveDeployer.java:347)
                   at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resume(DeploymentManagerServerLifeCycleImpl.java:229)
                   at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:131)
                   at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:966)
                   at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:361)
                   at weblogic.Server.main(Server.java:32)

  • Java.sql.SQLException: Invalid cursor position on saving

    Dear all
    I'm having a problem with saving components on a JSF page. The page is plit in two parts:
    1. Save report details, which are being saved correctly. Here is the code
    public String btnSaveReport_action() {
            // TODO: Process the button click action. Return value is a navigation
            // case name where null will return to the same page.
            System.out.println("Saving the report ... forsi");
            int seqNumber = SequenceNumber.getNextSequenceNo("TB_REPORTS");
            getSessionBean1().setReportFK(seqNumber);
            String reportId = "REP_" + ((String)tfReportName.getText()).replace(' ', '_').trim();
            System.out.println("ReportFK in btnSaveReport: " + getSessionBean1().getReportFK());
            //SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            System.out.println("Start Date: " + calRepStartDate.getSelectedDate());
            //error(calRepStartDate.getValue().toString());
            //System.out.println("getvalue" + calRepStartDate.getValue());
            try {
                rk = tb_reportsDataProvider.appendRow();
                tb_reportsDataProvider.setCursorRow(rk);
                System.out.println("Setting Values ...");
                tb_reportsDataProvider.setValue("REP_PK", new Integer(seqNumber));
                tb_reportsDataProvider.setValue("REP_ID", reportId);
                tb_reportsDataProvider.setValue("REP_ACTIVE", "Y");
                tb_reportsDataProvider.setValue("REP_SESSION_FK", new Integer(getSessionBean1().getSessionId()));
                tb_reportsDataProvider.setValue("REP_NAME", (String)tfReportName.getText());
                tb_reportsDataProvider.setValue("REP_START_DATE", new java.sql.Date(calRepStartDate.getSelectedDate().getTime()));
                tb_reportsDataProvider.setValue("REP_END_DATE", new java.sql.Date(calRepEndDate.getSelectedDate().getTime()));
                System.out.println("Committing Changes ...");
                tb_reportsDataProvider.commitChanges();
                System.out.println("Refreshing Row ...");
                tb_reportsDataProvider.getCachedRowSet().refreshRow();
                getSessionBean1().getTb_reportsRowSet().refreshRow();           
    //            tb_reportsDataProvider.refresh();
    //            System.out.println("Refreshing Row ...");
    //            tb_reportsDataProvider.setCursorRow(tb_reportsDataProvider.findFirst("REP_PK",new Integer(seqNumber)));
                info("Report Data Saved Successfully!");
            } catch (SQLException sqle) {
                /* error("Cannot update report (SQLException): " +
                        reportId +
                        " : " + sqle.getMessage()); */
                log("Cannot update report (SQLException): " +
                        reportId +
                        " : " + sqle);
                info("Could not save report: " + sqle.getMessage());
                sqle.printStackTrace();
            //tfReportName.setValueBinding("sourceData", getApplication().
            //    createValueBinding("#{newReport.tb_reportsDataProvider}"));
            //tfReportName.setValueBinding("text", getApplication().createValueBinding            ("#{newReport.tb_reportsDataProvider.value['REP_NAME']}"));
            // calRepStartDate.setValueBinding("sourceData", getApplication().
            //    createValueBinding("#{newReport.tb_reportsDataProvider}"));
            //calRepStartDate.setValueBinding("selectedDate", getApplication().createValueBinding            ("#{newReport.tb_reportsDataProvider.value['REP_START_DATE']}"));
            //calRepEndDate.setValueBinding("sourceData", getApplication().
            //    createValueBinding("#{newReport.tb_reportsDataProvider}"));
            //calRepEndDate.setValueBinding("selectedDate", getApplication().createValueBinding            ("#{newReport.tb_reportsDataProvider.value['REP_END_DATE']}"));
            info("Report Name: " + tb_reportsDataProvider.getValue("REP_NAME"));
            tfReportName.validate(this.getFacesContext());
            calRepStartDate.validate(this.getFacesContext());
            calRepEndDate.validate(this.getFacesContext());
            tfReportName.setDisabled(true);
            calRepStartDate.setDisabled(true);
            calRepEndDate.setDisabled(true);
            btnNewQuery.setDisabled(false);
            btnSaveReport.setDisabled(true);
            return null;
        }The problem is that the reportFK is losing its value when I submit the page the second time! I am trying to get the value from the provider or from the rowset, but none work. Here is the code I am trying ...
    public String btnSaveQuery_action() {
            // TODO: Process the button click action. Return value is a navigation
            // case name where null will return to the same page.
            int seqNumber  = 0;
            // Save the query header details to the database  
            try {
                // Start with the query - needed for the link table
                seqNumber = SequenceNumber.getNextSequenceNo("TB_QUERY");
                String queryId = "QRY_" + ((String)tfQueryName.getText()).replace(' ', '_').trim();
                tb_queryDataProvider.setCursorRow(queryRowKey);
                tb_queryDataProvider.setValue("QRY_PK", new BigDecimal(seqNumber));
                tb_queryDataProvider.setValue("QRY_CODE", queryId);
                tb_queryDataProvider.setValue("QRY_NAME", (String)tfQueryName.getText());
                tb_queryDataProvider.setValue("QRY_ACTIVE", "Y");
                tb_queryDataProvider.setValue("QRY_SESS_FK", new BigDecimal(getSessionBean1().getSessionId()));
                System.out.println("Committing Changes ...");
                tb_queryDataProvider.commitChanges();
                System.out.println("Refreshing Row ...");
                tb_queryDataProvider.setCursorRow(tb_queryDataProvider.findFirst("QRY_PK",new Integer(seqNumber)));
                getSessionBean1().getTb_queryRowSet().refreshRow();
                info("Query Data Saved Successfully!");
            } catch (Exception ex) {
                error("Error while saving query: " + ex.getMessage());
                log("Error while saving query" + ex);
                ex.printStackTrace();
            // Now save the link
            try {
                // Start with the query - needed for the link table
                String sql = "INSERT INTO TB_LINK_REPORT_QUERY ( " +
                   "LRQ_PK, LRQ_REP_FK, LRQ_QRY_FK, " +
                   "LRQ_TYPE, LRQ_START_DATE, LRQ_END_DATE, " +
                   "LRQ_ACTIVE, LRQ_SESS_FK) " +
                   "VALUES (?,?,?,?,?,?,?,?)";
                System.out.println("Trying to do the link");
                int linkSeqNumber = SequenceNumber.getNextSequenceNo("TB_LINK_REPORT_QUERY");           
                PreparedStatement pstmt = DBConnection.getConnection().prepareStatement(sql);
                if (getSessionBean1().getReportFK() == -1 || getSessionBean1().getReportFK() == 0)
                    System.out.println("reportFK = -1 or 0!!! Trying from provider.");
                    System.out.println("Report PK is: " + getSessionBean1().getTb_reportsRowSet().getBigDecimal("REP_PK"));
                    getSessionBean1().setReportFK(((Integer)tb_reportsDataProvider.getValue("REP_PK")).intValue());
                System.out.println("Report Foreign Key: " + getSessionBean1().getReportFK());
                System.out.println("Query Foreign Key: " + seqNumber);
                pstmt.setInt(1, linkSeqNumber);
                pstmt.setInt(2, getSessionBean1().getReportFK());
                pstmt.setInt(3, seqNumber);
                pstmt.setString(4, (String)dropDownQueryType.getSelected());
                pstmt.setDate(5, new java.sql.Date(calendarQueryStartDate.getSelectedDate().getTime()));
                pstmt.setDate(6, new java.sql.Date(calendarQueryEnd.getSelectedDate().getTime()));
                pstmt.setString(7, "Y");
                pstmt.setInt(8, getSessionBean1().getSessionId());
                System.out.println("Committing Changes for Link ...");
                pstmt.executeUpdate();
                DBConnection.getConnection().commit();
                System.out.println("Refreshing Row in link ...");
                getSessionBean1().getTb_link_report_queryRowSet().setObject(
                        1, new Integer(linkSeqNumber));
                getSessionBean1().getTb_link_report_queryRowSet().setObject(
                        2, new Integer(getSessionBean1().getReportFK()));
                getSessionBean1().getTb_link_report_queryRowSet().setObject(
                        3, calendarQueryStartDate.getSelectedDate());
                getSessionBean1().getTb_link_report_queryRowSet().setObject(
                        4, calendarQueryEnd.getSelectedDate());
                tb_link_report_queryDataProvider.refresh();
                info("Link Data Saved Successfully!");
            } catch (Exception ex) {
                error("Error while saving query: " + ex.getMessage());
                log("Error while saving link: " + ex);
                ex.printStackTrace();
            return null;
        }The part saving the query with the provider is working correctly. But the part with the link is not working at all (the part with the PreparedStatement). The fact is that the PreparedStatement cannot be executed because I am getting the error at the line
    System.out.println("Report PK is: " + getSessionBean1().getTb_reportsRowSet().getBigDecimal("REP_PK"));Can anyone help please?
    Thanks and Regards
    Joseph

    guys if any of you have an idea just post it. It would be of great help for me. I can't figure out my mistake and its been 2days already and still i am stuck with my problem.
    It displays the table but there is an error "java.sql.SQLException: Invalid cursor position" so i cannot put the counter to the session.

  • Java.io.StreamCorruptedException: InputStream does not contain a serialized object

              I have an applet which calls a JSP to write data object to the db and then the
              JSP sends back the updated data object. The writing part is ok but the response
              is giving the following error. The data object is in a separate class which implements
              Serialized.
              Here's the code in the applet calling the JSP and the response from the JSP
              URL server = null;
              String urlConnectionString = "http://localhost:7001/isLoginValid.jsp";
              try
              server = new URL(urlConnectionString);
              catch(MalformedURLException e)
              System.out.println("URL exception: " + e );
              // send request
              ObjectInputStream response = null;
              Object result = null;
              try
              URLConnection conn = server.openConnection();
              conn.setDoOutput(true);
              conn.setUseCaches(false);
              conn.setRequestProperty("Content-Type", "application/octet-stream");
              ObjectOutputStream request = new ObjectOutputStream(new
              BufferedOutputStream(conn.getOutputStream()));
              request.writeObject((Object)dvo);
              request.flush();
              request.close();
              // get the result input stream
              response = new ObjectInputStream(new BufferedInputStream
              (conn.getInputStream()));
              // read response back from the server
              result = response.readObject();
              if( result!=null && (result instanceof DataVO))
              dvo = (DataVO)result;
              String vo = dvo.printDataVO();
              System.out.println("*DataVO*\n"+vo);
              else
              System.out.println("not an instanceof DataVO");
              catch(IOException ignored)
              System.out.println("Error in DataVO response");
              ignored.printStackTrace();
              Here's the code in the JSP sending the response back to the applet. The 'dvo'
              object is the object which is serialized and has gets and sets for the diff. data
              elements. When I print the 'dvo' before writing the object to outputStream it
              prints the correct values for the data element.
              // send response
              response.setStatus(HttpServletResponse.SC_OK);
              ObjectOutputStream outputStream = new ObjectOutputStream (new BufferedOutputStream
              (response.getOutputStream()));
              outputStream.writeObject(dvo);
              outputStream.flush();
              ERROR is as follows:
              Error in DataVO response
              java.io.StreamCorruptedException: InputStream does not contain a serialized object
              at java/io/ObjectInputStream.readStreamHeader
              at java/io/ObjectInputStream.<init>
              What am I doing wrong?. Please respond soon. The applet is run on IIS and the
              JSP in on weblogic 6.1. I'm not sure if that makes any difference.
              

              I have an applet which calls a JSP to write data object to the db and then the
              JSP sends back the updated data object. The writing part is ok but the response
              is giving the following error. The data object is in a separate class which implements
              Serialized.
              Here's the code in the applet calling the JSP and the response from the JSP
              URL server = null;
              String urlConnectionString = "http://localhost:7001/isLoginValid.jsp";
              try
              server = new URL(urlConnectionString);
              catch(MalformedURLException e)
              System.out.println("URL exception: " + e );
              // send request
              ObjectInputStream response = null;
              Object result = null;
              try
              URLConnection conn = server.openConnection();
              conn.setDoOutput(true);
              conn.setUseCaches(false);
              conn.setRequestProperty("Content-Type", "application/octet-stream");
              ObjectOutputStream request = new ObjectOutputStream(new
              BufferedOutputStream(conn.getOutputStream()));
              request.writeObject((Object)dvo);
              request.flush();
              request.close();
              // get the result input stream
              response = new ObjectInputStream(new BufferedInputStream
              (conn.getInputStream()));
              // read response back from the server
              result = response.readObject();
              if( result!=null && (result instanceof DataVO))
              dvo = (DataVO)result;
              String vo = dvo.printDataVO();
              System.out.println("*DataVO*\n"+vo);
              else
              System.out.println("not an instanceof DataVO");
              catch(IOException ignored)
              System.out.println("Error in DataVO response");
              ignored.printStackTrace();
              Here's the code in the JSP sending the response back to the applet. The 'dvo'
              object is the object which is serialized and has gets and sets for the diff. data
              elements. When I print the 'dvo' before writing the object to outputStream it
              prints the correct values for the data element.
              // send response
              response.setStatus(HttpServletResponse.SC_OK);
              ObjectOutputStream outputStream = new ObjectOutputStream (new BufferedOutputStream
              (response.getOutputStream()));
              outputStream.writeObject(dvo);
              outputStream.flush();
              ERROR is as follows:
              Error in DataVO response
              java.io.StreamCorruptedException: InputStream does not contain a serialized object
              at java/io/ObjectInputStream.readStreamHeader
              at java/io/ObjectInputStream.<init>
              What am I doing wrong?. Please respond soon. The applet is run on IIS and the
              JSP in on weblogic 6.1. I'm not sure if that makes any difference.
              

  • XDO Log shows - java.io.UTFDataFormatException: Invalid UTF8 encoding

    We have a XDO Region in our OA Page - that calls XML Publisher Report taking as input a XML File generated from a concurrent program. The concurrent program calls a PL/SQL Program to generate the XML File.
    The XML File has the encoding fetched from
    select tag from fnd_lookup_values
      where lookup_type = 'FND_ISO_CHARACTER_SET_MAP'
      and lookup_code = ( select value from v$nls_parameters where parameter='NLS_CHARACTERSET')
      and language='US' ;
    The tag = 'UTF-8' and hence the encoding in XML File is as -
    <?xml version="1.0" encoding="UTF-8"?>
    The XML File is getting created successfully.. But XML Publisher is not able to process the report properly and is displaying the error - An error encountered either due to invalid Template details or due to null Data Input Stream.
    The XDO Log shows -
    [022113_075210160][][EXCEPTION] java.lang.reflect.InvocationTargetException
        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:597)
        at oracle.apps.xdo.common.xml.XSLT10gR1.invokeParse(XSLT10gR1.java:570)
        at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:235)
        at oracle.apps.xdo.common.xml.XSLTWrapper.transform(XSLTWrapper.java:182)
        at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:1044)
        at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:997)
        at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:212)
        at oracle.apps.xdo.template.FOProcessor.createFO(FOProcessor.java:1665)
        at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:975)
        at oracle.apps.xdo.oa.schema.server.TemplateHelper.runProcessTemplate(TemplateHelper.java:5936)
        at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3459)
        at oracle.apps.xdo.oa.schema.server.TemplateHelper.processTemplate(TemplateHelper.java:3548)
        at oracle.apps.xdo.oa.common.DocumentHelper.exportDocument(DocumentHelper.java:443)
        at oracle.apps.xdo.oa.common.webui.DocumentViewerCO.exportDocument(DocumentViewerCO.java:806)
        at oracle.apps.xdo.oa.common.webui.DocumentViewerCO.processFormRequest(DocumentViewerCO.java:744)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:819)
        at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:385)
        at oracle.apps.fnd.framework.webui.beans.layout.OAHeaderBean.processFormRequest(OAHeaderBean.java:410)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1031)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:997)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:852)
        at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:385)
        at oracle.apps.fnd.framework.webui.beans.layout.OAStackLayoutBean.processFormRequest(OAStackLayoutBean.java:370)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1031)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:997)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:852)
        at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:385)
        at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1214)
        at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1031)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:997)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:852)
        at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:385)
        at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1031)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:997)
        at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:852)
        at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:385)
        at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
        at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2974)
        at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1875)
        at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:543)
        at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:431)
        at _OA._jspService(_OA.java:212)
        at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
        at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:473)
        at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
        at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
        at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
        at oracle.apps.jtf.base.session.ReleaseResFilter.doFilter(ReleaseResFilter.java:26)
        at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
        at oracle.apps.fnd.security.AppsServletFilter.doFilter(AppsServletFilter.java:318)
        at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:642)
        at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:391)
        at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:908)
        at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:458)
        at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
        at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
        at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
        at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
        at java.lang.Thread.run(Thread.java:619)
    Caused by: java.io.UTFDataFormatException: Invalid UTF8 encoding.
        at oracle.xdo.parser.v2.XMLUTF8Reader.checkUTF8Byte(XMLUTF8Reader.java:160)
        at oracle.xdo.parser.v2.XMLUTF8Reader.readUTF8Char(XMLUTF8Reader.java:187)
        at oracle.xdo.parser.v2.XMLUTF8Reader.fillBuffer(XMLUTF8Reader.java:120)
        at oracle.xdo.parser.v2.XMLByteReader.saveBuffer(XMLByteReader.java:450)
        at oracle.xdo.parser.v2.XMLReader.fillBuffer(XMLReader.java:2294)
        at oracle.xdo.parser.v2.XMLReader.skipWhiteSpace(XMLReader.java:2039)
        at oracle.xdo.parser.v2.NonValidatingParser.parseMisc(NonValidatingParser.java:355)
        at oracle.xdo.parser.v2.NonValidatingParser.parseProlog(NonValidatingParser.java:324)
        at oracle.xdo.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:284)
        at oracle.xdo.parser.v2.XMLParser.parse(XMLParser.java:289)
        ... 65 more
    We have already tried to apply
    AP/AR Netting Report Fails With Invalid Template Or Null Data Input Stream When Run From OA Page [ID 985032.1]
    Service Charges Report: An error encountered either due to invalid Template details or due to null [Article ID 1068524.1]
    All this because one of the tag in XML has a Spanish character - Más antigua a más.
    Please advise.

    Any updates regarding this.
    Thanks

Maybe you are looking for

  • IPhoto won't open and keeps giving me an error message.

    Hi My iPhoto won't open on my Macbook Pro. All my software is up to date (OS X Yosemite 10.10.2) and there are no programme updates in my App Store. I have deleted and reinstalled iPhoto, switched my Mac off and nothing helps. In a similar thread peo

  • Mac OS X Lion works on Macbook Air with Processor Intel dual core?

    Mac OS X Lion works on Macbook Air with Processor Intel dual core?

  • How to Set Album list view as default

    MacBook Pro 3,1 SL 10.6.7 iTunes 10.3.1 inverted-store-links if i use the »inverted-store-links« i always get the list-view instead the before used album-list. i think the same problem with playlists always shown in list-view by default. maybe there

  • Captivate 4 and SumTotal 7.2 - SCORM Template

    Hello! I'm hoping someone has what I'm looking for.  Up until last week, we had been using Andrew C's SCORM template with Captivate 3 to publish courses to our SumTotal LMS (version 7.2). Everything worked beautifully! Now, we've updated to Captivate

  • Sims game won't work!

    I have a macbook air and ever since i bought it in september 2013  i have been trying to get my sims 3 game to work. i am not sure if it is my computer or if it is the external disc drive that is the problem so i am hoping someone can help me out wit