Why bad padding exception???

hi guys
here i am trying to decrypt the already encrypted string by one different encrpytion algo.
in the example i have encrypted the string by des and then i tried to decrypt it using blowfish but it gives as the output null instead of a random string...because of a bad padding exception(check line 86). help to remove the exception.
if we try to decrypt the des encrypted string by des again it give n padding exception. why with blowfish???
// CIPHER / GENERATORS
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.KeyGenerator;
// KEY SPECIFICATIONS
import java.security.spec.KeySpec;
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEParameterSpec;
// EXCEPTIONS
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyException;
import java.security.spec.InvalidKeySpecException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
public class StringEncrypter {
Cipher ecipher;
Cipher dcipher;
StringEncrypter(SecretKey key, String algorithm) {
try {
ecipher = Cipher.getInstance(algorithm);
dcipher = Cipher.getInstance(algorithm);
ecipher.init(Cipher.ENCRYPT_MODE, key);
dcipher.init(Cipher.DECRYPT_MODE, key);
} catch (NoSuchPaddingException e) {
System.out.println("EXCEPTION: NoSuchPaddingException");
} catch (NoSuchAlgorithmException e) {
System.out.println("EXCEPTION: NoSuchAlgorithmException");
} catch (InvalidKeyException e) {
System.out.println("EXCEPTION: InvalidKeyException");
public String encrypt(String str) {
try {
// Encode the string into bytes using utf-8
byte[] utf8 = str.getBytes("UTF8");
// Encrypt
byte[] enc = ecipher.doFinal(utf8);
// Encode bytes to base64 to get a string
return new sun.misc.BASE64Encoder().encode(enc);
} catch (BadPaddingException e) {
} catch (IllegalBlockSizeException e) {
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
return null;
public String decrypt(String str) {
try {
// Decode base64 to get bytes
byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);
// Decrypt
byte[] utf8 = dcipher.doFinal(dec);
// Decode using utf-8
return new String(utf8, "UTF8");
} catch (BadPaddingException e) {
System.out.println("BAd padding excception");
} catch (IllegalBlockSizeException e) {
System.out.println("IllegalBlockSizeException");
} catch (UnsupportedEncodingException e) {
System.out.println("UnsupportedEncodingException");
} catch (IOException e) {
System.out.println("IOException");
return null;
public static void testUsingSecretKey() {
try {
          String secretString = "code cant be decrypted!";
          SecretKey desKey = KeyGenerator.getInstance("DES").generateKey();
          SecretKey blowfishKey = KeyGenerator.getInstance("Blowfish").generateKey();
     StringEncrypter desEncrypter = new StringEncrypter(desKey, desKey.getAlgorithm());
          StringEncrypter blowfishEncrypter = new StringEncrypter(blowfishKey, blowfishKey.getAlgorithm());
          String desEncrypted = desEncrypter.encrypt(secretString);     
     String desDecrypted = desEncrypter.decrypt(desEncrypted);
     String blowfishDecrypted = blowfishEncrypter.decrypt(desEncrypted);      
     System.out.println(desKey.getAlgorithm() + " Encryption algorithm");
     System.out.println(" Original String : " + secretString);
     System.out.println(" Encrypted String : " + desEncrypted);
     System.out.println(" Decrypted String : " + desDecrypted);
     System.out.println();
     System.out.println(blowfishKey.getAlgorithm() + " Encryption algorithm");
     System.out.println(" Original String : " + desEncrypted);
     System.out.println(" Decrypted String : " + blowfishDecrypted);
     System.out.println();
     } catch (NoSuchAlgorithmException e) {
     public static void main(String[] args) {
     testUsingSecretKey();
}

peter_crypt wrote:
you are right but this is my question. why cant we do that?? it should be possible.by the way i am working on a project for cryptanalysis . there i need to implement it.You need to spend more time studying and less time programming -
1) Applied Cryptography, Schneier, Wiley, ISBN 0-471-11709-9
2) Practical Cryptography, Ferguson and Schneier, Wiley, ISBN 0-471-22357-3
3) Java Cryptography, Knudsen, O'Reilly, ISBN 1-56592-402-9 dated but still a good starting point
4) Beginning Cryptography with Java, written by David Hook and published by WROX .

Similar Messages

  • Bad Padding Exception

    I've got a small program to save/load passwords from a file, but the encryption is causing me a few issues, currently I'm stuck on a bad padding exception (line 120).
    The code can be found here: http://www.rafb.net/paste/results/R8NoZB78.html
    Does anyone know how I can resolve the error? Thanks.

        private String decrypt(String encrypted) {
            try {
                Cipher cipher = Cipher.getInstance("DES");
                cipher.init(Cipher.DECRYPT_MODE, key);
                return new String(Base64.decodeBase64(cipher.doFinal(encrypted.getBytes())));
            } catch (Exception e) { e.printStackTrace(); }
            return null;
        private String encrypt(String plaintext) {
            try {
                Cipher cipher = Cipher.getInstance("DES");
                cipher.init(Cipher.ENCRYPT_MODE, key);
                return new String(cipher.doFinal(Base64.encodeBase64(plaintext.getBytes())));
            } catch (Exception e) { e.printStackTrace(); }
            return null;
        }decrypt()
    string -> encrypted encoded bytes -> encoded bytes -> bytes -> string
    encrypt()
    string -> bytes -> encoded bytes -> encrypted encoded bytes -> string
    I do ask myself first. And no, I still don't get what the problem is - I really think there's something, probably very simple, that I don't know about and that's why I'm not getting this.

  • Unusual Bad Padding Exception

    I am writing a class to encrypt licencing information onto a text file in Base64 encoding. This write aspect works fine but the reading the licence back throw a Bad Padding Exception. (error and code below) Any assistance will be much appreciated
    javax.crypto.BadPaddingException: Given final block not properly padded
    at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
    at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
    at com.sun.crypto.provider.AESCipher.engineDoFinal
    (DashoA6275)
    at javax.crypto.Cipher.doFinal(DashoA6275)
    at Encryptor.encrypt(Encryptor.java:117)
    at Encryptor.loadAllEncryptedLayerLicences
    (Encryptor.java:158)
    at Encryptor.main(Encryptor.java:183)
    KeyGenerator kgen = KeyGenerator.getInstance("AES");
    kgen.init(128);
    SecretKey skey = kgen.generateKey();
    byte[] raw = skey.getEncoded();
    SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
    Cipher cipher = Cipher.getInstance("AES");
    //encrypt
    cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
    byte[] encrypted = cipher.doFinal(value.getBytes());
    //CONVERT TO BASE64 Encoding
    String s = new sun.misc.BASE64Encoder().encode(encrypted);
    //write the encrypted data to the file
    fos = new FileOutputStream("C:\\aes\\output.properties");
    new PrintStream(fos).println("layerhandle\t"+s);
    fos.flush();
    //fos.close();
    //decrypt
    byte[] buf = new sun.misc.BASE64Decoder().decodeBuffer(value);
    cipher.init(Cipher.DECRYPT_MODE, skeySpec);
    //read from file and decrypt the values
    byte[] unecrypted = cipher.doFinal(buf);
    String word = new String(unecrypted);

    String s = new
    sun.misc.BASE64Encoder().encode(encrypted);
    //write the encrypted data to the file
    fos = new
    FileOutputStream("C:\\aes\\output.properties");
    new PrintStream(fos).println("layerhandle\t"+s);
    fos.flush();
    //fos.close();This looks suspicious. You should close the PrintStream and not just flush 'fos'. Closing the PrintSteam will close 'fos'. This failure to close the print stream could be the cause your problem.
    >
    >
    //decrypt
    byte[] buf = new
    sun.misc.BASE64Decoder().decodeBuffer(value);If there is a problem with decrypt then it may be because you have not read the 'value' or the 'key' properly.

  • Bad Padding Exception using AES/ECB/PKCS5Padding

    Hi, I need some help Tryng to crypt and decrypt a String using AES/ECB/PKCS5Padding
    I paste my code below
    Crypt
    Cipher cipher;
             byte[] pass=new byte[]{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; // just for example
            SecretKeySpec key = new SecretKeySpec(pass, "AES");
            cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
            cipher.init(Cipher.ENCRYPT_MODE, key);        
            byte[] utf8 = da_cifrare.getBytes("utf-8");
            byte[] enc = cipher.doFinal(utf8);
            String cifrata =new String (Base64.encodeBase64(enc));
            return cifrata;
    And on the other side Decrypt
    Cipher decipher;
               byte[] pass=new byte[]{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; // just for example
               SecretKeySpec key = new SecretKeySpec(pass, "AES");
               decipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
               decipher.init(Cipher.DECRYPT_MODE, key); 
               byte[] buf =Base64.decodeBase64(da_decifrare.getBytes("utf-8"));
               byte[] recoveredBytes = decipher.doFinal(buf);
               String in_chiaro = new String (recoveredBytes,"utf-8");
               return (in_chiaro);I'm getting Bad padding exception when I try to Decrypt, any ideas ??

    Nothing obviously wrong but we have no view of your Base64 encoder and decoder. You should check
    a) that the bytes of your key are the same in both methods
    b) that the bytes resulting in your decrypt methodbyte[] buf =Base64.decodeBase64(da_decifrare.getBytes("utf-8"));are exactly the same as those created in the encrypt method using  byte[] enc = cipher.doFinal(utf8);
          Note - since Base64 consists of only ASCII characters you should use String cifrata =new String (Base64.encodeBase64(enc),"ASCII");and byte[] buf =Base64.decodeBase64(da_decifrare.getBytes("ASCII"));though this flaw should not be the cause of your exception.
    Edited by: sabre150 on Dec 15, 2009 12:32 PM

  • Bad Padding exception when trying to decrypt the file

    Hi i am trying to decypt a file in java which is encrypted in c++ but i get the pad padding exception
    javax.crypto.BadPaddingException: Given final block not properly padded
         at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
         at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
    public byte[] decrypt(byte[] str) {
    try {
    // Decrypt
         System.out.println("beforedecrypt-->"+str.length);
         byte[] input = new byte[64];
              while(true) {
                        int bytesRead = fin.read(input);
                        if (bytesRead == -1) break;
                        byte[] output = dcipher.update(input, 0, bytesRead);
                   byte[] output = dcipher.doFinal();
         // byte[] utf8 = dcipher.doFinal(str);
         System.out.println("afterdecrypt-->");
    // Decode using utf-8
    return output;
    } catch (javax.crypto.BadPaddingException e) {e.printStackTrace();}
    catch (IllegalBlockSizeException e) {e.printStackTrace();}
    catch (Exception e){e.printStackTrace();}
    return null;
    }

    MuppidiJava wrote:
    Sorry man..i got the same key in java..which you got i followed everything was mentioned... but i did not get the same key using C++ But did you compensate in your Java for the C++ bug I highlighted involving the creation of the bytes from the password? I bet you didn't. Did you even talk to your C++ guys about the bug? I bet you didn't.
    as i said i was not good at it..but your sample cpp code would have fixed it easily. Did you look at the Microsoft Crypto documentation? I bet you didn't. Did you try to learn enough C++ to add in the few lines of code needed to export and print out the generated key? I bet you didn't. Did you try to get the C++ guys to help you on this?
    I runing short of timeSorry but your time management problem is your problem.
    ..thanks for your support..The BadPaddingException problem you have is almost certainly as a result of you not generating the same key bytes in your Java as are being generated by the C++. Since you get the same bytes as I do when not compensating for the C++ bug it is almost certain that the C++ bug is the root cause of your problem. If I compensate for the C++ bug I get a match between my C++ key bytes and my Java key bytes. If you don't spend effort in understanding the C++ bug and how to correct for it in your Java you are stuffed. If you don't spend time learning enough C++ to be able to export the C++ key then you will have great difficulty in proving that you C++ key bytes actually match your Java key bytes. I have explained what the bug is - the Java code to compensate for the bug is actually trivial. I have explained how to export the C++ key - the C++ code for this is small and straightforward. I'm not going to provide the C++ code nor the Java compensation code. This is a 'forum' and not a programming service.
    P.S. You still have a problem with the '.' key on your keyboard.

  • Matrix Bad Value exception in ItemCode column

    hello ,
    i faced an exception with filling itemcode column
    As u know this column is linked object and have CFL (choose from list)
    the problem i faced that on choosing from list i choose an item to add new line in matrix
    this event done and a new line added sucessfully
    but the problem was with CFL , that it didnt able to close , it still opened and you need to press ESC or click on cancel to close it
    when i tracking the exception i found "Bad value" exception, although the itemcode column filled but the
    also i bind all matrix columns with data sources and i can fill matix at first , but when i want to add new line i faced this problem
    best regards and thank you in advance ....
    Ammar

    Thanks Rasmus,
    But that's something I've already tried - it doesn't seem to make any difference.

  • I am facing a problem while deploying an Entity bean in iPlanet(sp3).I have attached the exception thrown.Why has this exception occured?

    [04/Dec/2001 10:54:00:2] error: EBFP-marshal_internal: internal exception caught in kcp skeleton, ex
    ception = java.lang.NullPointerException
    [04/Dec/2001 10:54:00:2] error: Exception Stack Trace:
    java.lang.NullPointerException
    at java.util.Hashtable.get(Hashtable.java:321)
    at com.netscape.server.ejb.SQLPersistenceManager.<init>(Unknown Source)
    at com.netscape.server.ejb.SQLPersistenceManagerFactory.newInstance(Unknown Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.getPersistenceManager(Unknown Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.doPersistentFind(Unknown Source)
    at com.netscape.server.ejb.EntityDelegateManagerImpl.find(Unknown Source)
    at com.kivasoft.eb.EBHomeBase.findSingleByParms(Unknown Source)
    at samples.test.ejb.Entity.ejb_home_samples_test_ejb_Entity_TestEntityBean.findByPrimaryKey(
    ejb_home_samples_test_ejb_Entity_TestEntityBean.java:126)
    at samples.test.ejb.Entity.ejb_kcp_skel_TestEntityHome.findByPrimaryKey__samples_test_ejb_En
    tity_TestEntity__int(ejb_kcp_skel_TestEntityHome.java:266)
    at com.kivasoft.ebfp.FPRequest.invokenative(Native Method)
    at com.kivasoft.ebfp.FPRequest.invoke(Unknown Source)
    at samples.test.ejb.Entity.ejb_kcp_stub_TestEntityHome.findByPrimaryKey(ejb_kcp_stub_TestEnt
    ityHome.java:338)
    at samples.test.ejb.Entity.ejb_stub_TestEntityHome.findByPrimaryKey(ejb_stub_TestEntityHome.
    java:85)
    at samples.test.ejb.TestEJB.getGreeting(TestEJB.java:51)

    Hi,
    I think you are trying to test the Hello world EJB example shipped with the product. As a first
    step I would recomend you to go through every line of the document on deploying this application,
    since, I too have experienced many errors while trying to deploy the sample applications, but on
    following the documentation, I subsequently overcame all the errors and have been working with the
    applications. So please follow the steps in documentation and let me know, if you still encounter any
    issues.
    Regards
    Raj
    Sandhya S wrote:
    I am facing a problem while deploying an Entity bean in iPlanet(sp3).I
    have attached the exception thrown.Why has this exception occured?
    [04/Dec/2001 10:54:00:2] error: EBFP-marshal_internal: internal
    exception caught in kcp skeleton, ex
    ception = java.lang.NullPointerException
    [04/Dec/2001 10:54:00:2] error: Exception Stack Trace:
    java.lang.NullPointerException
    at java.util.Hashtable.get(Hashtable.java:321)
    at
    com.netscape.server.ejb.SQLPersistenceManager.<init>(Unknown Source)
    at
    com.netscape.server.ejb.SQLPersistenceManagerFactory.newInstance(Unknown
    Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.getPersistenceManager(Unknown
    Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.doPersistentFind(Unknown
    Source)
    at
    com.netscape.server.ejb.EntityDelegateManagerImpl.find(Unknown Source)
    at com.kivasoft.eb.EBHomeBase.findSingleByParms(Unknown
    Source)
    at
    samples.test.ejb.Entity.ejb_home_samples_test_ejb_Entity_TestEntityBean.findByPrimaryKey(
    ejb_home_samples_test_ejb_Entity_TestEntityBean.java:126)
    at
    samples.test.ejb.Entity.ejb_kcp_skel_TestEntityHome.findByPrimaryKey__samples_test_ejb_En
    tity_TestEntity__int(ejb_kcp_skel_TestEntityHome.java:266)
    at com.kivasoft.ebfp.FPRequest.invokenative(Native Method)
    at com.kivasoft.ebfp.FPRequest.invoke(Unknown Source)
    at
    samples.test.ejb.Entity.ejb_kcp_stub_TestEntityHome.findByPrimaryKey(ejb_kcp_stub_TestEnt
    ityHome.java:338)
    at
    samples.test.ejb.Entity.ejb_stub_TestEntityHome.findByPrimaryKey(ejb_stub_TestEntityHome.
    java:85)
    at samples.test.ejb.TestEJB.getGreeting(TestEJB.java:51)
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • Why we use exception ???

    Why we use Exception ??anyone knows what are the 3 keys point below describe about..??
    There are 3 main Advantages of using Exception
    1.Separates error handling code from "regular code
    2.Propagating erros up the call stack (without tedious programming)
    3.Grouping error type and error differentiation
    TQ.

    hi,
    1) you can catch those exceptions and write extra classes for handling/log them, so you do not have to do between the lines of source
    2) if an uncaught exception happens an errorstack will be invoked. On the stack you can see, where the exception started and which classes are involved
    3) you can have very special erros, for example all errors which occurs on files (normally it is an IOException), you can define your own exceptions so you can say, i.e. line 503 doesn't contain what it should.
    With this way you can resolve very well where an exception raises and why it happens.
    hope it answers
    regards
    freak

  • Why badi HRPAD00INFTY can't work in t-code PTMW?

    hi:
    why badi HRPAD00INFTY can't work in t-code PTMW? if I want to do enhancement about PT infty in PTMW,what should i do?

    Please refer to help document for BAPI:HRPAD00INFTY which allows you to react to specific events in Personnel Administration. If you need logic in TMW, implement BADI  PT_BLP_USER. Further information can be found in section 6.a of SAP Note 447097.
    Regards
    Chetan

  • Help me,Why Null Pointer Exception!!!!

    Hi,
    I want to write a javabean to wrap some methods assosiated with database,the source code is like this:
    //ConnectToDBMS.java
    import java.sql.*;
    public class ConnectToDBMS
    private Connection conn=null;
    private Statement stmt=null;
    ResultSet rs=null;
    private String driver=null;
    public String url=null;
    public String user=null;
    public String password=null;
    public ConnectToDBMS(){}
    public void Connect()
    try
    Class.forName(driver);
    catch(Exception e)
    System.out.println("can't load driver��"+driver);
    e.printStackTrace();
    public void setDriver(String Driver)
    this.driver=driver;
    public void setUrl(String URL)
    this.url=URL;
    public void setUserPassword(String user,String password)
    this.user=user;
    this.password=password;
    public ResultSet executeQuery(String sql)
    rs=null;
    try
    conn=DriverManager.getConnection(url,user,password);
    stmt=conn.createStatement();
    rs=stmt.executeQuery(sql);
    catch(SQLException ee)
    System.out.println("error in query��"+ee.getMessage());
    return rs;
    public void closeStmt()
    try
    stmt.close();
    catch(SQLException eee)
    eee.printStackTrace();
    public void closeConn()
    try
    conn.close();
    catch(SQLException eeee)
    eeee.printStackTrace();
    compile ok,and then called in jsp,the jsp code is like this:
    <%@page contentType="text/html;charset=gb2312"%>
    <%@page import="java.sql.*"%>
    <jsp:useBean id="ConnectToDBMS" scop="page" class="ConnectToDBMS"/>
    <html>
    <title>my soft bank</title>
    <body background="gif/bk097.jpg">
    <center>
    <h1><font color='red'>software download</font></h1><hr color='green'>
    <table border="4" width="%80">
    <tr><th>name</th><th>����</th><th>comments</th>
    <%
    ConnectToDBMS.setDriver("org.gjt.mm.mysql.driver");
    ConnectToDBMS.Connect();
    ConnectToDBMS.setUrl("jdbc:mysql://localhost/mysoft");
    ConnectToDBMS.setUserPassword("root","");
    ResultSet rst=ConnectToDBMS.executeQuery("SELECT * FROM soft");
    while(rst.next())
    %><tr><td><a href="<%=rst.getString(url")%">"><%=rst.getString("soft_name")%></a></td>
    <%
    out.println("<td>"+rst.getFloat("soft_size")+"M</td>");
    out.println("<td>"+rst.getString("soft_intro")+"</td></tr>");
    ConnectToDBMS.closeStmt();
    ConnectToDBMS.closeConn();
    %>
    </body>
    </html>
    the database name is mysoft,and has a table named soft,it contains such fields:soft_name,soft_intro,soft_size,url. I found this error when visit this page:
    java.lang.NullPointerException
         at _soft__jsp._jspService(/soft.jsp:20)
         at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
         at com.caucho.jsp.Page.subservice(Page.java:506)
         at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
         at com.caucho.server.http.Invocation.service(Invocation.java:315)
         at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
         at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:246)
         at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
         at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
         at java.lang.Thread.run(Thread.java:536)
    </a>

    The error is occurring somewhere in your JSP, according to the stack trace. It would help to know which is line 20, but it's hard to figure that out for a JSP. Just another reason why it's a bad idea to put lots of Java code in a JSP. But anyway, do you think it's possible that your putting
    scop="page"
    in your bean declaration instead of
    scope="page"
    is the problem? If not, you need to put debugging code in the scriptlet to find where the exception is being thrown.

  • Why customize application exception this way?

    hi
    i found too different ways to customize a same application exception
    they actually work the same way but with a little difference that i can not figure out why
    the first one is
    public class BaseAppException extends Exception {
        static final long serialVersionUID = -5829545098534135052L;
         * the message of the BaseAppException.
        private String exceptionMessage;
         * A public constructor for BaseAppException containing no arguments.
        public BaseAppException() {
         * A public constructor for BaseAppException specifying exception message.
         * <p>
         * @param msg
         *            exception message.
        public BaseAppException(String msg) {
            this.exceptionMessage = msg;
        }it uses a private member "exceptionMessage" to store the exception message
    and here is the second piece of code
    public class BaseAppException extends Exception {
        static final long serialVersionUID = -5829545098534135052L;
         * A public constructor for BaseAppException containing no arguments.
        public BaseAppException() {
         * A public constructor for BaseAppException specifying exception message.
         * <p>
         * @param msg
         *            exception message.
        public BaseAppException(String msg) {
             super(msg);
    //        this.exceptionMessage = msg;
        }this one passes the message to the base throwable
    both works but i am wondering why define a private string memeber for message storing and not pass it to the base throwable??

    I'm not sure what you're trying to do here, but at
    first glance "TestK t = new TestK();" inside the for
    loop seemed unusual.
    If you place it before the loop it works fine.I guess what he is trying to ask is that why is that if you use the new operator in the code, you donot get the exception while if you dont use it you do get one. While in any case either you use it or not you are supposed to get a new String as per the String API.
    Well thats an interesting observation and I have no explanation as to why is this happening. I do remember that thread where somebody pointed this out as a use of the String(String original) construtor. Furtehr adding on to that the API states about this constructor the following
    Initializes a newly created String object so that it represents the same sequence of characters as the argument; in other words, the newly created string is a copy of the argument string.
    so I donot get why not using it would cause the exception to be thrown. I have tested the code though and it seems to behave as pointed in the original post.
    Interesting question though, food for thought.

  • CCM enrichment BaDI implementation - exception handling

    Hello CCM Gurus,
    We're using CCM 2.0 version. I'd like to make an upload enrichment implementation, and raise an exception if one item has some problem. Every time if in the code an exception is raised according to one item, the whole catalog upload goes wrong, and the upload of the other good items go wrong as well. If it is possible I'd like to get a warning or an error message in SLG1 from the problematic items, but the correct items should be load into the catalog.
    If you have a sample implementation like this, what is solved this issue please send me.
    Thanks and regards
    Almos

    Hello Masa,
    Thanks for the helpful advice, the debugging is working now. Do you know some documentation or material where I can find some useful detailed infomation about using CCM BAdI?
    I don't know exactly the differences between the /CCM/CTLG_ENRICHMENT and the /CCM/CHAR_VALUATION BAdI. What is the prefered BAdI when you'd like to change or append uploaded CCM catalog data?
    Thanks and regards
    Almos

  • Why User Define Exception range from -20,000 to -20,999

    Hi,
    Can any one told me why we are using user define exception as ( -) 'Negative' range from -20,000 to -20,999. Why not Positive.
    Thanks

    Hi
    Oracle error codes are negatives.
    Ott Karesz
    http://www.trendo-kft.hu

  • Why use padding in Georaster?

    Hi,
    Georaster support padding in row\col\band dimensions. this makes redundancy in storage and make troubles in mosaci etc. processes. Are there any advantages use padding? in Georaster guide, only one sentence said about it: Padding makes each block have the same BLOB size. Are this important for what? does padding makes program easy? Any other design considerations about padding mechanism ?
    thanks
    jiong

    I have no trouble in operating georaster, I'm just curious about why Georaster developers use padding mechanism to store raster? To make the program easy to write or make the performance better?
    thanks

  • Bad Position Exception

    I have posted this in the concurrency thread, as I think this is a concurrency issue, but it is hard to know because my code is throwing exceptions that are hard to understand.
    The exception I am getting is "bad position" followed by a number, eg "bad position: 111787".
    This seems to happen when I am accessing a Vector, Hashtable or ByteArrayOutputStream in a multi-threaded program, so I am assuming it is some kind of concurrency issue. However, I would have expected to get a recognisable exception message such as "ConcurrentModificationException" or something like that.
    Does anyone have any idea what this exception is? Am I barking up the wrong tree in assuming it is a concurrency exception?
    Thanks

    Searching the JDK7 source gives
    sabre@beta:~/jdk7$ find . -name "*.java" -exec grep -il "bad position" {} \;
    ./jdk/src/share/classes/javax/swing/text/DocumentFilter.java
    ./jdk/src/share/classes/javax/swing/text/Document.java
    ./jdk/src/share/classes/javax/swing/text/JTextComponent.java
    ./jdk/src/share/classes/javax/swing/text/Segment.java
    Only Segment.java and JTextComponent have that as part of an exception (IllegalArgumentException) message.
    Since these are both Swing classes, if this is a concurrency issue then I would suspect it is caused by you not updating something in the Swing event thread.

Maybe you are looking for

  • Display image into Data Grid

    Hello, I have to display into a data grid, in Flex 2, 2 columns: first column ( "Images") must contain a picture with an object and second column (" quantity") must contain the amount of that object that I want to buy. The problem is that I must take

  • Zen:M Battery death!!!!!a last hope!

    A few months ago, I bought a wall charger(Creative Switching adaptor model:tesa9g-0502400).Suddlenly when?I connected?the Mp3(vision zen:m) to the wall charger,the screen turned black! and shut down!!since that moment,each time I connect the Mp3 to t

  • Iphone4 will not sync, back up file corrupt

    During the sync process my iphone was accidentally disconncted.  After restarting my computer and trying to again sync I received an error message stating the the back-up file is corrupt.  I followed the procedure to delecte the corrupt file and have

  • How can people viewing my iWeb site print a whole slideshow?

    I have several pages of photos and captions on my iWeb site. Many of these are slideshows which are guides to repairing / modifying cars for enthusiasts. The page shows the operations in easy stages. People who use these want to print off all the pho

  • Iphoto organizing???

    In my photos section, my pictures are separated by the Month/Year, but all in one big mess of pictures. I can no longer visibly see the Month/Year?? How do I get that back on?!  I want to see "July 2013" then those pictures under it again.