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

Similar Messages

  • 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • 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

  • 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

  • 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 index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))

    I've Main Report + 5 sub report. All of this in a 1 file named _rptBorang.rpt.
    This _rptBorang.rpt consists of
    1. Main Report
    2. _spupimSPMBorang.rpt
    3. _spupimSTPMBorang.rpt
    4. _spupimSijilDiploma.rpt
    5. _spupimKoQ.rpt
    6. _spupimPilihanProg.rpt
    When I preview the report, the Enter values dialog box ask 7 parameters. It's
    1. idx
    2. tbl_MST_Pemohon_idx
    3. tbl_MST_Pemohon_idx(_spupimSPMBorang.rpt)
    4. tbl_MST_Pemohon_idx(_spupimSTPMBorang.rpt)
    5. tbl_MST_Pemohon_idx(_spupimSijilDiploma.rpt)
    6. tbl_MST_Pemohon_idx(_spupimKoQ.rpt)
    7. tbl_MST_Pemohon_idx(_spupimPilihanProg.rpt)
    My ASP.NET code as following,
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="_cetakBorang.aspx.vb" Inherits="_cetakBorang" title="SPUPIM" %>
    <%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1n" runat="server">
        <div align="center">
            <asp:Label ID="lblMsg" runat="server" ForeColor="Red"></asp:Label>
            <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
                AutoDataBind="true" />
        </div>
        </form>
    </body>
    </html>
    Imports System.configuration
    Imports System.Data.SqlClient
    Imports System.Web.Security
    Imports CrystalDecisions.Shared
    Imports CrystalDecisions.CrystalReports.Engine
    Partial Class _cetakBorang
        Inherits System.Web.UI.Page
        Private Const PARAMETER_FIELD_NAME1 As String = "idx"
        Private Const PARAMETER_FIELD_NAME2 As String = "tbl_MST_Pemohon_idx"
        Private Const PARAMETER_FIELD_NAME3 As String = "tbl_MST_Pemohon_idx(_spupimSPMBorang.rpt)"
        Private Const PARAMETER_FIELD_NAME4 As String = "tbl_MST_Pemohon_idx(_spupimSTPMBorang.rpt)"
        Private Const PARAMETER_FIELD_NAME5 As String = "tbl_MST_Pemohon_idx(_spupimSijilDiploma.rpt)"
        Private Const PARAMETER_FIELD_NAME6 As String = "tbl_MST_Pemohon_idx(_spupimKoQ.rpt)"
        Private Const PARAMETER_FIELD_NAME7 As String = "tbl_MST_Pemohon_idx(_spupimPilihanProg.rpt)"
        Dim myReport As New ReportDocument
        'rpt connection
        Public rptSvrNme As String = ConfigurationManager.AppSettings("rptSvrNme").ToString()
        Public rptUsr As String = ConfigurationManager.AppSettings("rptUsr").ToString()
        Public rptPwd As String = ConfigurationManager.AppSettings("rptPwd").ToString()
        Public rptDB As String = ConfigurationManager.AppSettings("rptDB").ToString()
        Private Sub SetCurrentValuesForParameterField(ByVal reportDocument As ReportDocument, ByVal arrayList As ArrayList, ByVal paramFieldName As String)
            Dim currentParameterValues As New ParameterValues()
            For Each submittedValue As Object In arrayList
                Dim parameterDiscreteValue As New ParameterDiscreteValue()
                parameterDiscreteValue.Value = submittedValue.ToString()
                currentParameterValues.Add(parameterDiscreteValue)
            Next
            Dim parameterFieldDefinitions As ParameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields
            Dim parameterFieldDefinition As ParameterFieldDefinition = parameterFieldDefinitions(paramFieldName)
            parameterFieldDefinition.ApplyCurrentValues(currentParameterValues)
        End Sub
        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not IsPostBack Then
                publishReport(Convert.ToInt32(Session("applicantIdx")), Convert.ToInt32(Session("applicantIdx")))
            End If
        End Sub
        Private Sub publishReport(ByVal idx As Integer, ByVal tbl_MST_Pemohon_idx As Integer)       
            Try
                Dim reportPath As String = String.Empty
                reportPath = Server.MapPath("_rptBorang.rpt")
                myReport.Load(reportPath)
                myReport.SetDatabaseLogon(rptUsr, rptPwd, rptSvrNme, rptDB)
                Dim arrayList1 As New ArrayList()
                arrayList1.Add(idx)
                SetCurrentValuesForParameterField(myReport, arrayList1, PARAMETER_FIELD_NAME1)
                Dim arrayList2 As New ArrayList()
                arrayList2.Add(tbl_MST_Pemohon_idx)
                SetCurrentValuesForParameterField(myReport, arrayList2, PARAMETER_FIELD_NAME2)
                Dim arrayList3 As New ArrayList()
                arrayList3.Add(tbl_MST_Pemohon_idx)
                SetCurrentValuesForParameterField(myReport, arrayList3, PARAMETER_FIELD_NAME3)
                Dim arrayList4 As New ArrayList()
                arrayList4.Add(tbl_MST_Pemohon_idx)
                SetCurrentValuesForParameterField(myReport, arrayList4, PARAMETER_FIELD_NAME4)
                Dim arrayList5 As New ArrayList()
                arrayList5.Add(tbl_MST_Pemohon_idx)
                SetCurrentValuesForParameterField(myReport, arrayList5, PARAMETER_FIELD_NAME5)
                Dim arrayList6 As New ArrayList()
                arrayList6.Add(tbl_MST_Pemohon_idx)
                SetCurrentValuesForParameterField(myReport, arrayList6, PARAMETER_FIELD_NAME6)
                Dim arrayList7 As New ArrayList()
                arrayList7.Add(tbl_MST_Pemohon_idx)
                SetCurrentValuesForParameterField(myReport, arrayList7, PARAMETER_FIELD_NAME7)
                Dim parameterFields As ParameterFields = CrystalReportViewer1.ParameterFieldInfo
                CrystalReportViewer1.ReportSource = myReport
            Catch ex As Exception
                lblMsg.Text = ex.Message
            End Try
        End Sub
        Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
            myReport.Close()
        End Sub
    End Class
    The result was, my ASP.NET return error --- > Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
    I'm stuck
    Really need help
    Edited by: WKM1925 on Feb 22, 2012 11:49 AM

    First off, it would really be nice to have the version of CR you are using. Then
    1) does this report work the CR designer?
    2) What CR SDK are you using?
    3) If .NET, what version?
    4) Web or Win app?
    5) What OS?
    Then, please re-read your post and see if it actually makes any sense. To me, it's just gibberish...
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • 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.

  • Invalid TCP Header Checksum?

    I'm using WireShark (http://www.wireshark.org/) to debug a network problem I'm having viewing protected Quicktime streams, and I find that nearly every packet coming out of my iMac has an invalid TCP header checksum, 0x0000, instead of the correct value. What could be wrong?

    Then, try http://discussions.apple.com/category.jspa?categoryID=122

  • Invalid CEN header ( bad signature )

    I get this reeor when I try to import .par file in NWS.
    invalid CEN header ( bad signature )
    also say that The Plugin "com.sap.portal.plugins.config-archiver" caused an exception during the unpack opreation

    Hello! experts,
    I got the same error but i manage to solve it.
    While trying to import the par file, please ensure the 'Project root folder' is giving correctly.
    In my case, when i got the error, the folder i initially selected was not there.
    Check if the Project folder you are selecting is there or folder is read / write.
    This will solve your problem.
    Thanks!
    Regards,
    Kishore
    *Please reward points if this solution works for you*

  • Invalid Cursor state Exception  -  Help required

    Hi,
    I'm having a web page(JSP), which is making use of 3 ResultSet objects. Using the first two, i'll populate two different Drop down list, with values from database(Access) while loading the page for first time.
    Now if the user select any value from any (or both) of drop down list and clicks submit, i need to display all values in database, meeting the criteria from first & second drop down list. For this selection, i'm using the third ResultSet variable. While executing the query, i'm sure that 3rd ResultSet is returning some value. But when i try to retrieve the value to a string variable, i'm getting the Invalid cursor state exception.
    Throughout the page, i haven't closed any of the ResultSet. When i closed the first and second ResultSets in the third function(where 3rd ResultSet is used), i'm not getting any value. Its returning like ResultSet closed.
    Please help me to get this solved. It's very urgent because without this, i cannot proceed further. Please share your ideas.
    Thanks in advace for your valuable help

    If you open a new resultset within the same statement, all previously opened will be closed.
    Read the API docs, luke.

  • "Invalid Block Type" exception message

    I got "Invalid Block Type" exception message in my program. I'm not sure what this is. Could somebody please advice?
    Thanks
    GZIPInputStream gzip_in_stream = null;
    BufferedOutputStream destination_out_stream = new BufferedOutputStream(
       new FileOutputStream(weatherFile), BUF_SIZE);
       byte[] input_buffer = new byte[BUF_SIZE];
    int byteLength = 0;          
    while ( (byteLength = gzip_in_stream.read(input_buffer, 0, BUF_SIZE)) > 0 )
    destination_out_stream.write(input_buffer, 0, byteLength);     
    destination_out_stream.flush(); // Ensure all the data is written to the output.
    destination_out_stream.close();
    gzip_in_stream.close();     

    ZipException, and it only says "Signals that a Zip exception of some sort has occurred."
    I forgot to include this.
    InputStream tempStream = ftpClient.retrieveFileStream(zippedFile);
    gzip_in_stream = new GZIPInputStream(
    new BufferedInputStream(tempStream));

  • While reading from the pl/sql cursor i got "Invalid column index" exception

    Hi,
    I got the "Invalid column index" exception while reading from the cursor.
    Please advice.
    Thanks in advance
    siva

    I suppose one (or more) index in your query is in a bad state.
    Possible solutions: rebuild (with 'ALTER INDEX <index> REBUILD ...')
    drop and recreate (it's the same as above, but a little more long)

  • LWAPP"invalid IP header checksum"

    Hello , i hace a problem with a wireless network based on 4 WiSM (two in two 6500) and AP1010. AP's get IP from the DHCP and associate to the controller, but after a while, they start sending a syslog message LWAPP-ERROR: "invalid IP header checksum". I have ping losses and the AP dissasociates, reloads and reassociates to the controller. Does anyone have found the same problem?
    thanks

    What code are you running on the WLC's? I know that with the AP1010, you can't be running the newer code. that is why I ask.
    Is this happening on all 4 WLC's and can you post a snip of the log from the cli.

  • HowTo Close stream on exception (FindBug)

    Hi there.
    I've just started to use the tool FindBugs which seems to work all right as far as it goes.
    But it claims, that in the following code the method may "fail to close stream on exception":
         void writeToFile(String fileName){
              System.out.print("Creating "+fileName+" ..");
              try {
                   FileOutputStream fos = new FileOutputStream(new File(fileName));
                   PrintWriter o = new PrintWriter(fos);  //this line is marked as error-prone
                   o.println("Some String");
                   o.close();
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              System.out.println(".done");
         }Whereas if I comment out the line with the o.println-call, everything's fine again for "FindBugs".
    I have absolutely no clue to what's meant by "on exception", since neither the line itself nor the following line throws an Exception.
    (BTW: adding an "finally" block or closing the stream after the try-catch-block doesn't seem to solve the problem for FindBugs).
    So, what's my problem? The code seems to work yet. But FindBugs seems to be a neat tool and since I don't like having code that might fail to close streams on exceptions,
    I'd like to hear from some of you how you'd code a simple block like that.
    (Add to that: I hate being corrected by a programme (At least as long as this fucker seems to be smarter than me ;) So now it's time for me to learn!! )
    Any suggestions about how to improve my programming technique are gratefully taken, as well as blind guessing around about what the hell FindBugs thinks I should do better.
    -T-

    Hi,
    This is the first time I am using findbugs tool. I have this piece of code
    <target if="javadoc.packages" name="findbug" >
    <!--<available file="etc/javadoc_build.inc" property="javadoc.buildinc"/>-->
    <findbugs home="D:\bin\common\_lib\build\findbugs"
    output="xml"
    outputFile="bcel-fb.xml" >
              <!--<auxClasspath path="${basedir}/lib/Regex.jar" />-->
              <sourcePath path="C:\java.zip" />
    <class location="C:\java.zip" />
    </findbugs>
    </target>
    My questions are
    1)Is the <auxClasspath> extension required.
    2)on running ant task, i get the following error
    D:\deepak\buildProcess_2\logging>ant findbug
    Buildfile: build.xml
    [taskdef] Could not load definitions from resource tasks.properties. It could not be found.
    findbug:
    findbug:
    BUILD FAILED
    file:D:/deepak/buildProcess_2/_setup/docs.xml:190: Could not create task or type of type: findbugs.
    Ant could not find the task or a class this task relies upon.
    This is common and has a number of causes; the usual
    solutions are to read the manual pages then download and
    install needed JAR files, or fix the build file:
    - You have misspelt 'findbugs'.
    Fix: check your spelling.
    - The task needs an external JAR file to execute
    and this is not found at the right place in the classpath.
    Fix: check the documentation for dependencies.
    Fix: declare the task.
    - The task is an Ant optional task and optional.jar is absent
    Fix: look for optional.jar in ANT_HOME/lib, download if needed
    - The task was not built into optional.jar as dependent
    libraries were not found at build time.
    Fix: look in the JAR to verify, then rebuild with the needed
    libraries, or download a release version from apache.org
    - The build file was written for a later version of Ant
    Fix: upgrade to at least the latest release version of Ant
    - The task is not an Ant core or optional task
    and needs to be declared using <taskdef>.
    Remember that for JAR files to be visible to Ant tasks implemented
    in ANT_HOME/lib, the files must be in the same directory or on the
    classpath
    Please neither file bug reports on this problem, nor email the
    Ant mailing lists, until all of these causes have been explored,
    as this is not an Ant bug.
    Total time: 3 seconds
    Anyone suggest me a solution.
    bye,
    with regards,
    Deepak.

Maybe you are looking for

  • How implement Auto Purchase Order in Transportation Cost Settlement

    Hi,Experts, When Settling the Transportation Cost,I must create PO manually.Can anybody tell me How implement Auto Purchase Order in Transportation Cost Settlement? Thanks for a lot. Donald Lo

  • How do I create a form that can be edited, then mailed, then edited again?

    I am trying to create a form that would be emailed to one person, they would complete part of it, email it on to a second user who would then complete another part based on the input from the first, and then forward it onto a third for their input. t

  • Opening new window when performing cut, paste and delete on Audio Files

    This is 100% reproducible: When performing one of the following actions when editing audio files (not multitrack projects), it will open a new window with the same file: - Cut - Delete - Paste This happens on new files as well as opened files. The ne

  • How to upgrade labview version 7 to version 8

    Hi, 1. I wish to know how to upgrade labview version 7 to version 8? 2. If I save my VI under labview 7, how can I run in labview 8 and back to labview 7. What are the steps needed? Ridwan

  • JDBC locking access db

    i can create the table from jframe. i can open the program and instantly insert records, but if i insert a table, then try and insert records i get sqlexception error saying database is locked by othe process and I DON'T have Access open or another i