NoClassDefFoundError javax.crypto.spec.secretkeyspec from console
Hello, I have done a program in eclipse, using the JCE to encrypt and decrypt some messages using AES. In the eclipse graphical interface it works perfect, but if i run it from console, i mean like this
java -jar org.eclipse.osgi_3.6.0.v20100517.jar -console -configuration config_path -clean -dev file:dev.properties_path
It works but throw the exception
NoClassDefFoundError javax.crypto.spec.secretkeyspec
I think there must be something wrong with the java path because JCE is already inside the jre environment. I need to know how can i indicate in the command line, the right path to the JCE
I am working on windows
Thank you!
yes, i mean
NoClassDefFoundError javax.crypto.spec.SecretKeySpec
but i wrote it fast and i didn't realize....
My output for java -version is
java version "1.6.0_21"
Java (TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)
So i think that outside eclipse i am using the good one, then i don't know why it doesn't work. Actually, i forgot to say that in the log file, i get this exception message:
!ENTRY org.eclipse.osgi 4 0 2010-10-15 11:35:12.273
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:150)
So maybe this is the real problem. I am sorry but i am not really used to launch java applications from console (i always do it with eclipse) so, i don't really know if i need some more parameters or what happen.
My config.ini file is the same that eclipse uses when it launches the application, and the dev.properties file is also the same.
Similar Messages
-
Javax.crypto.spec.SecretKeySpec seems to ignore the last bit in every byte
Hi All,
I am having a problem with the SecretKeySpec class in JCE 1.2.2. I am using DES as algorithm, and a 8 byte long key. I am passing a hex array of 16 characters (each 2 representing a byte) and create a byte array of length 8 from that hex array. For example, the following "A12C3D4E5F6A7B8E" is equivalent to a byte array, having the values of the bytes (in signed byte) [-95, 44, 61, 78, 95, 106, 123, -114]. It works perfectly but what I observed is, if one of the bytes looks like "5E" and I change it to "5F," the code still works, the encrypted text using the key created with "5E" key is decrypted correctly using the "5F" key. It doesn't work if the byte is "E5" and I change it to "F5," and this led me to think that the SecretKeySpec implementation ignores the last bit of every byte (uses just the high 7 bits.)
Anybody came accross this before? Any help appreciated.
THanks,
MariusAs I said, "every implementation I'm aware of ignores them". They're not used during en/decryption, they exist only to provide (marginal) evidence that the key might have been mangled in-transit. Many implementations just skip that step. Note that i'm not saying this is a good thing - it's just been my experience.
The 64-bit quntity you're playing with is NOT "the key" - the DES key is the 56 bits that do not include the parity bits. Ignoring the parity-bits doesn't yield more keys that will do the same decryption, since the parity bits aren't used by DES itself.
The net? Don't worry about it. It's the 56 bits that are the important ones.
Grant -
Hello to everyone, I started to program in MHP 1.0.2 on a MHP receiver and now i'm practicing in encrypting and decrypting. I load from the smart card in the MHP receiver an X509Certificate object (I have it both in byte[] form, called certArray, and X509Certificate object, called "certificate"). What i'd like to do is to :
1)calculate digest of the certificate (line 1 and 2 of the following code)
2) encrypt the digest using the same algorithm of the certificate (see line 3 and 4)
The problem is generated at line 3 : the receiver, probably, doesn't find the class of the algorithm of encrypting. It is important to notice that the instruments to encrypt/decrypt are included in javax.crypto and javax.crypto.spec packages.
MessageDigest md = MessageDigest.getInstance("SHA");
byte[] digest = md.digest(certArray);
Cipher encrypt = Cipher.getInstance(certificate.getSigAlgName());
encrypt.init(Cipher.ENCRYPT_MODE, certificate.getPublicKey());
The error message, in the log file, is the following :
[0#1:2] java.security.NoSuchAlgorithmException: SHA1withRSA not found
[0#1:2] at javax.crypto.Cipher.getInstance(Ljava/lang/String;)Ljavax/crypto/Cipher;(Unknown Source)
[0#1:2] at it.csp.SecurelabXlet.encrypt()V(Unknown Source)
[0#1:2] at it.csp.SecurelabXlet.cardInserted(Lopencard/core/event/CardTerminalEvent;)V(Unknown Source)
[0#1:2] at opencard.core.event.EventGenerator.createEventsForPresentCards(Lopencard/core/event/CTListener;)V(Unknown Source)
[0#1:2] at it.csp.SecurelabXlet.register()V(Unknown Source)
[0#1:2] at it.csp.SecurelabXlet.startXlet()V(Unknown Source)
[0#1:2] at java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown Source)
[0#1:2] at tv.osmosys.application.AppManager$XletApp.xletStart()Z(Unknown Source)
[0#1:2] at tv.osmosys.application.AppManager$XletApp.loop0(Ltv/osmosys/application/AppManager$XletAction;)V(Unknown Source)
[0#1:2] at tv.osmosys.application.AppManager$XletApp.run()V(Unknown Source)
[0#1:2] at java.lang.Thread.run()V(Unknown Source)
[0#1:2] at java.lang.Thread.startup(Z)V(Unknown Source)
My question(s) is : how can I include javax.crypto and javax.crypto.spec in the Xlet application to upload it onto the MHP receiver?? Is it possibile to do so?
Eventually, do other libraries exist to use encrypting algorithms, included in MHP? The version I use of MHP is 1.0.2. Thank you! Bye!Hello to everyone, I started to program in MHP 1.0.2 on a MHP receiver and now i'm practicing in encrypting and decrypting. I load from the smart card in the MHP receiver an X509Certificate object (I have it both in byte[] form, called certArray, and X509Certificate object, called "certificate"). What i'd like to do is to :
1)calculate digest of the certificate (line 1 and 2 of the following code)
2) encrypt the digest using the same algorithm of the certificate (see line 3 and 4)
The problem is generated at line 3 : the receiver, probably, doesn't find the class of the algorithm of encrypting. It is important to notice that the instruments to encrypt/decrypt are included in javax.crypto and javax.crypto.spec packages.
MessageDigest md = MessageDigest.getInstance("SHA");
byte[] digest = md.digest(certArray);
Cipher encrypt = Cipher.getInstance(certificate.getSigAlgName());
encrypt.init(Cipher.ENCRYPT_MODE, certificate.getPublicKey());
The error message, in the log file, is the following :
[0#1:2] java.security.NoSuchAlgorithmException: SHA1withRSA not found
[0#1:2] at javax.crypto.Cipher.getInstance(Ljava/lang/String;)Ljavax/crypto/Cipher;(Unknown Source)
[0#1:2] at it.csp.SecurelabXlet.encrypt()V(Unknown Source)
[0#1:2] at it.csp.SecurelabXlet.cardInserted(Lopencard/core/event/CardTerminalEvent;)V(Unknown Source)
[0#1:2] at opencard.core.event.EventGenerator.createEventsForPresentCards(Lopencard/core/event/CTListener;)V(Unknown Source)
[0#1:2] at it.csp.SecurelabXlet.register()V(Unknown Source)
[0#1:2] at it.csp.SecurelabXlet.startXlet()V(Unknown Source)
[0#1:2] at java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown Source)
[0#1:2] at tv.osmosys.application.AppManager$XletApp.xletStart()Z(Unknown Source)
[0#1:2] at tv.osmosys.application.AppManager$XletApp.loop0(Ltv/osmosys/application/AppManager$XletAction;)V(Unknown Source)
[0#1:2] at tv.osmosys.application.AppManager$XletApp.run()V(Unknown Source)
[0#1:2] at java.lang.Thread.run()V(Unknown Source)
[0#1:2] at java.lang.Thread.startup(Z)V(Unknown Source)
My question(s) is : how can I include javax.crypto and javax.crypto.spec in the Xlet application to upload it onto the MHP receiver?? Is it possibile to do so?
Eventually, do other libraries exist to use encrypting algorithms, included in MHP? The version I use of MHP is 1.0.2. Thank you! Bye! -
Javax.crypto.spec.*
I am trying to encrypt passwords and have been given a code snipper which tries to import "javax.crypto.spec.*". Can you tell me what jar this is in and where to get it.
Thanks.It appears to be new in 1.4.0.
-
Unable to Decrypt the data properly using javax.crypto class and SunJCE
Hello all,
I am not new to Java but new to this forums
but and JCE and i wanted to write a program that Encrypts a file and also another program that decrypts it. As far Encryption is concerned i have been successful but When it comes to Decryption things aren't looking bright i have some or the other Problem with it. plz help me out .
Here is the Code for my Programs
Encryption
Code:
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import java.security.*;
import javax.swing.*;
class MyJCE
public static void main(String args[])throws Exception
Provider sunjce = new com.sun.crypto.provider.SunJCE();
Security.addProvider(sunjce);
JFileChooser jfc = new JFileChooser();
int selection= jfc.showOpenDialog(null);
if(selection==JFileChooser.APPROVE_OPTION)
FileInputStream fis = new FileInputStream(jfc.getSelectedFile());
System.out.println("Selected file " + jfc.getSelectedFile());
try{
KeyGenerator kg = KeyGenerator.getInstance("DESede");
SecretKey key= kg.generateKey();
byte[] mkey=key.getEncoded();
System.out.println(key);
SecretKeySpec skey = new SecretKeySpec(mkey, "DESede");
Cipher cipher=Cipher.getInstance("DESede/ECB/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE,skey);
byte[] data= new byte[fis.available()];
//reading the file into data byte array
byte[] result= cipher.update(data);
byte[] enc= new byte [fis.read(result)];
System.out.println("Encrypted =" + result);
File fi= new File("/home/srikar/Encrypted");
FileOutputStream fos= new FileOutputStream(fi);
fos.write(enc);
fos.close();
byte[] encodedSpeckey = skey.getEncoded();
FileOutputStream ks= new FileOutputStream("./key.txt");
ks.write(encodedSpeckey);
System.out.println("Key written to a file");
}//try
catch(Exception ex)
ex.printStackTrace();
}//catch
}This Creates a Encrypted File. and a Encrypted key.txt
Code:
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import java.security.*;
import javax.swing.*;
class Decrypt
public static void main(String[] args)
try
JFileChooser jfc = new JFileChooser();
int selection= jfc.showOpenDialog(null);
if(selection==JFileChooser.APPROVE_OPTION)
FileInputStream fis = new FileInputStream(jfc.getSelectedFile());
System.out.println("Selected file " + jfc.getSelectedFile());
//Read from the Encrypted Data
int ll= (int)jfc.getSelectedFile().length();
byte[] buffer = new byte[ll];
int bytesRead=fis.read(buffer);
byte[] data= new byte[bytesRead];
System.arraycopy(buffer,0,data,0,bytesRead);
//Read the Cipher Settings
FileInputStream rkey= new FileInputStream("./key.txt");
bytesRead = rkey.read(buffer);
byte[] encodedKeySpec=new byte[bytesRead];
System.arraycopy(buffer,0,encodedKeySpec,0,bytesRead);
//Recreate the Secret Symmetric Key
SecretKeySpec skeySpec= new SecretKeySpec(encodedKeySpec,"DESede");
//create the cipher for Decrypting
Cipher cipher = Cipher.getInstance("DESede/ECB/NoPadding");
cipher.init(Cipher.DECRYPT_MODE,skeySpec);
byte[] decrypted= cipher.update(data);
FileOutputStream fos= new FileOutputStream("/home/srikar/Decrypted");
fos.write(decrypted);
}//if
}//try
catch(Exception e)
e.printStackTrace();
}//catch
}//main
}//classthis Decrypt.java is expected to decrypt the above encrypted file but this simply creates a plaintext file of the same size as the Encrypted file but its contents are unreadable.
Or I endup with Exceptions like BadPadding or IllegalBlockSize Exception if i use any other Algorithm .
Please help out
thanx in advanceSrikar2871 wrote:
Well thanx for ur reply but
As i said there are No issues with ENCRYPTION and am getting an Encrypted file exactly of the same size as that of the original file and NOT as null bytes and Even am able to get a Decrypted file of again the same size of the Encrypted File but this time that data inside is in unreadable format.I ran your code EXACTLY* as posted and the contents of the file when viewed in a Hex editor was
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00So unless you are running different code to what you have posted, your file will look the same.
Cheers,
Shane -
Javax.crypto.IllegalBlockSizeException help?
I am making a plain text encrypt/decrypt program for personal use.
It will compile just fine, but if I try to run the decryption part, it freaks out on me.
It keeps on saying:
javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher
This is my code. I cannot figure out what is wrong...
import java.io.*;
import java.util.*;
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.spec.IvParameterSpec;
import static methods.methods.*;
public class Base
public static void main()
Scanner kbReader = new Scanner(System.in);
clear("Method > ");
String s = kbReader.next();
if(s.equals("output"))
try{output();}
catch(Exception e){e.printStackTrace();}
if(s.equals("input"))
try{input();}
catch(Exception e){e.printStackTrace();}
if(s.equals("genKey"))
genKey();
if(s.equals("x"))
clear("Well it stopped.");
else
main();
public static void output()
throws IOException,
NoSuchAlgorithmException,
NoSuchPaddingException,
InvalidKeyException,
IllegalBlockSizeException,
BadPaddingException,
InvalidAlgorithmParameterException
Scanner kbReader = new Scanner(System.in);
Scanner kbr = new Scanner(System.in);
clear("What is the name of the file?\nName > ");
fileName = kbReader.next();
String s2 = "/Users/ewsmith/base/" + fileName;
FileWriter fw = new FileWriter(s2, true);
PrintWriter output = new PrintWriter(fw, true);
clear("Key > ");
byte key[] = new byte[16];
for(int j=0; j<16; j++)
key[j] = kbReader.nextByte();
clear("IV > ");
byte ivBytes[] = new byte[16];
for(int j=0; j<16; j++)
ivBytes[j] = kbReader.nextByte();
IvParameterSpec iv = new IvParameterSpec(ivBytes);
String s = new String("");
String ss = new String("");
clear("Enter what you want output to a file.\nType 'x' to finish writing.\n\n");
while(true)
s = kbReader.nextLine();
if(s.equalsIgnoreCase("x"))
break;
ss = ss + s + "\n";
byte data[] = ss.getBytes("UTF-8");
Cipher c = Cipher.getInstance("AES/CBC/PKCS5PADDING");
SecretKeySpec k = new SecretKeySpec(key, "AES");
c.init(Cipher.ENCRYPT_MODE, k, iv);
c.doFinal(data);
for(int j=0; j<data.length; j++)
output.print(data[j] + " ");
clear("This is your key.\n\n");
for(int j=0; j<key.length; j++)
System.out.print(key[j] + " ");
println("\n\nType in 'x' and press enter to continue.");
boolean alive = true;
while(alive)
String s3 = kbr.nextLine();
if(s3.equalsIgnoreCase("x"))
alive = false;
byte[] IV = c.getIV();
clear("This is your IV:\n\n");
for(int j=0; j<IV.length; j++)
print(IV[j] + " ");
println("\n\nType x to continue.\n");
String ew = "";
while(true)
ew = kbReader.nextLine();
if(ew.equalsIgnoreCase("x"))
break;
output.close();
fw.close();
public static void input()
throws IOException,
NoSuchAlgorithmException,
NoSuchPaddingException,
InvalidKeyException,
IllegalBlockSizeException,
BadPaddingException,
InvalidAlgorithmParameterException
Scanner kbReader = new Scanner(System.in);
Scanner kbr = new Scanner(System.in);
Cipher c = Cipher.getInstance("AES/CBC/PKCS5PADDING");
clear("What is the name of the file?\nName > ");
fileName = kbr.next();
String s2 = "/Users/ewsmith/base/" + fileName;
Scanner sf = new Scanner(new File(s2));
int num = 1;
clear("Key > ");
byte key[] = new byte[16];
for(int j=0; j<16; j++)
key[j] = kbReader.nextByte();
clear("IV > ");
byte ivBytes[] = new byte[16];
for(int j=0; j<16; j++)
ivBytes[j] = kbReader.nextByte();
IvParameterSpec iv = new IvParameterSpec(ivBytes);
SecretKeySpec k = new SecretKeySpec(key, "AES");
c.init(Cipher.DECRYPT_MODE, k, iv);
clear("This text was stored inside the file.\n\n\n");
int j = 0;
ArrayList<Byte> ip = new ArrayList<Byte>();
while(sf.hasNext())
ip.add(sf.nextByte());
byte input[] = new byte[ip.size()];
for(j=0; j<ip.size(); j++)
input[j] = ip.get(j);
String recovered = new String(c.doFinal(input));
println(recovered);
sf.close();
ip.clear();
input = null;
println("\n\nType in 'x' and press enter to continue.");
boolean alive = true;
while(alive)
String s = kbReader.nextLine();
if(s.equalsIgnoreCase("x"))
alive = false;
public static void genKey()
Scanner kbReader = new Scanner(System.in);
clear();
Random ranGen = new SecureRandom();
byte[] aesKey = new byte[16];
ranGen.nextBytes(aesKey);
for(int j=0; j<aesKey.length; j++)
System.out.print(aesKey[j] + " ");
println("\n\nType in 'x' and press enter to continue.");
boolean alive = true;
while(alive)
String s = kbReader.nextLine();
if(s.equalsIgnoreCase("x"))
alive = false;
public static String fileName = "";
}Thank you in advance for answering.
EDIT:
It now says:
+ at com.sun.crypto.provider.SunJCE_h.b(DashoA12275)+
+ at com.sun.crypto.provider.SunJCE_h.b(DashoA12275)+
+ at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA12275)+
+ at javax.crypto.Cipher.doFinal(DashoA12275)+
+ at Base.input(Base.java:184)+
+ at Base.main(Base.java:23)+
+ at __SHELL3.run(__SHELL3.java:6)+
+ 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:585)+
+ at bluej.runtime.ExecServer$3.run(ExecServer.java:819)+
Could this be an IV error?
Can negative IV's be used?
Edited by: eric_smith on Jan 6, 2010 9:25 PM
Edited by: eric_smith on Jan 7, 2010 9:51 AMI turned this:
String recovered = new String(c.doFinal(input));into this:
String recovered = new String(input);and used 0's for the key and iv and the text was 'decrypted'.
Something tells me the problem is in the output and input cipher.init()
Can someone enlighten me as to what I am doing wrong?
EDIT: btw, the code came from the input method.
Edited by: eric_smith on Jan 7, 2010 9:28 PM -
Cannot find javax.crypto.KeyGeneratorSpi
The following code compiles but
I get a runtime error as follows.
NoClassDefFoundError for javax.crypto.KeyGeneratorSpi
I did a jar tf on the sunjce_provider.jar file and
this class is not contained?
It is in the jce1_2_1.jar file and is abstract.
When at runtime the factory tries to create an instance
of the keyGeneratorSpi I think it tries to get a concrete
implementation of the class from the SunJCE implementation and cant find it?
Is this correct.
Obviously the classpath is set correct as I am able to
import all of the SunJCE classes.
Heres the code.
import java.io.*;
import java.util.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import com.sun.crypto.provider.*;
import java.security.*;
public class CryptoTest {
public static void main(String[] args)
KeyGenerator keygen = null;
SecretKey desKey = null;
Cipher desCipher = null;
Security.addProvider( new com.sun.crypto.provider.SunJCE() );
byte[] ciphertext;
try
keygen = KeyGenerator.getInstance("DES","SunJCE");
catch(Exception e){
System.out.println("Exception getting keygenerator");
e.printStackTrace();
}What jdk version do you use?
I use the J2SDK 1.4.0-beta(contains the jce and the Sun JCE provider).
And the following code works fine to me:
KeyGenerator keygen = null;
try {
keygen = KeyGenerator.getInstance("DES","SunJCE");
} catch(Exception e) {
System.out.println("Exception getting keygenerator");
e.printStackTrace();
} -
hi friends
iam writing and reading an encryted text to a file . this code executes well on windows xp o.s but does not executes on Macintosh ,solaris and linux systems.
when executed it throws javax.crypto.IllegalBlockSizeException and javax.crypto.BadPaddingException .
pls i am damp urgent need of it so kindly resolve my problem
Below is the code.
Thanks in advance.
--------------------------------------------------code----------------------------------------
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.Cipher;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
public class EncryptionExample
static SecretKey key = null;
static String text="A=1,B=2,C=3";
static String xform = "Blowfish/CFB/PKCS5Padding";
private static byte[] iv =
{ 0x0a, 0x01, 0x02, 0x03, 0x04, 0x0b, 0x0c, 0x0d };
public EncryptionExample() throws Exception
key=EncryptionExample.getGeneratedKey();
public static void writeToFile() throws Exception
FileWriter file = null;
BufferedWriter fileOutput = null;
byte[] dataBytes = null;
byte[] encBytes = null;
try {
file = new FileWriter("C:\\Test.txt");
fileOutput= new BufferedWriter(file);
dataBytes = text.getBytes("UTF8");
encBytes = encrypt(dataBytes, key, xform);
String encStr = Base64.encode(encBytes);
fileOutput.write(encStr);
fileOutput.close();
} catch (Exception e) {
e.printStackTrace();
// reading encryted text from file
public static void readFromFile() throws Exception
FileReader filerdr = null;
BufferedReader fileInput = null;
byte[] decBytes = null;
String decrystr = null;
String enText = null;
try {
filerdr = new FileReader("C:\\Test.txt");
fileInput = new BufferedReader(filerdr);
while ((enText = fileInput.readLine())!=null)
byte[] decrypted = Base64.decode(enText);
decBytes = decrypt(decrypted, key, xform);
decrystr=new String(decBytes,"UTF8");
System.out.println("decrypted string token , "+decrystr);
fileInput.close();
}catch (Exception e) {
e.printStackTrace();
private static byte[] encrypt(byte[] inpBytes,SecretKey key, String xform) throws Exception {
Cipher cipher = Cipher.getInstance(xform);
IvParameterSpec dps = new IvParameterSpec(iv);
cipher.init(Cipher.ENCRYPT_MODE, key,dps);
return cipher.doFinal(inpBytes);
private static byte[] decrypt(byte[] inpBytes,SecretKey key, String xform) throws Exception
Cipher cipher = Cipher.getInstance(xform);
IvParameterSpec dps = new IvParameterSpec(iv);
cipher.init(Cipher.DECRYPT_MODE, key,dps);
return cipher.doFinal(inpBytes);
private static SecretKey getGeneratedKey() throws Exception
// Generate a secret key
KeyGenerator kg = KeyGenerator.getInstance("Blowfish");
kg.init(128); // 56 is the keysize. Fixed for DES
SecretKey key = kg.generateKey();
return key ;
public static void main(String[] unused) throws Exception {
new EncryptionExample();
EncryptionExample.writeToFile();
EncryptionExample.readFromFile();
}You are very lucky to get this working at all, even on Windows! You encrypt the whole of your string at one go and write it to a file using
fileOutput= new BufferedWriter(file);
dataBytes = text.getBytes("UTF8");
encBytes = encrypt(dataBytes, key, xform);
String encStr = Base64.encode(encBytes);
fileOutput.write(encStr);
fileOutput.close();but you then try to decrypt it a line at a time using
while ((enText = fileInput.readLine())!=null)
byte[] decrypted = Base64.decode(enText);
decBytes = decrypt(decrypted, key, xform);
decrystr=new String(decBytes,"UTF8");
System.out.println("decrypted string token , "+decrystr);
fileInput.close();This just does not make sense. If you encrypt all at one time you must decrypt all at one time.
Your code happens to work because the Base64 encoding puts everything on one line. The fact that this seems to work does not make it correct.
P.S. Your code works on my Linux FC5 so I have no idea why you get the exceptions! -
Javax.crypto and Perl module Crypt::CBC
Hi,
My problem is when I encrypt on the JAVA side with :
String inkey = "123456781234567812345678";
final byte[] ivBytes = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
byte[] rawkey = inkey.getBytes();
DESedeKeySpec keyspec = new DESedeKeySpec(rawkey);
SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("DESede");
SecretKey key = keyfactory.generateSecret(keyspec);
encryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding", "SunJCE");
encryptCipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key, iv);
synchronized public String encrypt(String Entry) throws Exception {
byte[] EntryBytes = Entry.getBytes(characterEncoding);
byte[] encryptedEntryBytes = this.encryptCipher.doFinal(EntryBytes);
String encodedEncryptedEntry = this.base64Encoder.encode(encryptedEntryBytes);
return encodedEncryptedEntry;
and try to decrypt on the Perl side with :
$cbc_encrypt_key = "123456781234567812345678";
$cbc_iv = "12345678";
$css_cipher = Crypt::CBC->new(
-cipher => DES_EDE3,
-key => $cbc_encrypt_key,
-iv => $cbc_iv,
-header => 'none'
$info = decode_base64($info);
$info = $css_cipher->decrypt($info);
it doesn't work at all, Perl can't decrypt. Is there any compatibilty problem ? or is my code wrong (i suppose so)
Please help me
Edwhat readme file ?
here my java class :
package sso;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.*;
import sun.misc.*;
public class DESedeEntryEncrypt
public DESedeEntryEncrypt(byte[] keyBytes, byte[] ivBytes, String characterEncoding) throws Exception
try {
SecretKey key = new SecretKeySpec(keyBytes, "DESede");
IvParameterSpec iv = new IvParameterSpec(ivBytes);
this.characterEncoding = characterEncoding;
this.encryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding", "SunJCE");
this.encryptCipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key, iv);
this.decryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding", "SunJCE");
this.decryptCipher.init(javax.crypto.Cipher.DECRYPT_MODE, key, iv);
catch (Exception e)
System.err.println(e);
synchronized public String encrypt(String Entry) throws Exception
byte[] EntryBytes = Entry.getBytes(characterEncoding);
byte[] encryptedEntryBytes = this.encryptCipher.doFinal(EntryBytes);
String encodedEncryptedEntry = this.base64Encoder.encode(encryptedEntryBytes);
return encodedEncryptedEntry;
synchronized public String decrypt(String encodedEncryptedEntry) throws Exception
byte[] encryptedEntryBytes = this.base64Decoder.decodeBuffer(encodedEncryptedEntry);
byte[] EntryBytes = this.decryptCipher.doFinal(encryptedEntryBytes);
String recoveredEntry = new String(EntryBytes, characterEncoding);
return recoveredEntry;
private String characterEncoding;
private Cipher encryptCipher;
private Cipher decryptCipher;
private BASE64Encoder base64Encoder = new BASE64Encoder();
private BASE64Decoder base64Decoder = new BASE64Decoder();
here is the main class :
final byte[] myKey = "123456781234567812345678".getBytes("ASCII");
final byte[] ivBytes = "12345678".getBytes("ASCII");
// Entry encrypt agent that assumes the Entry is only ASCII characters
DESedeEntryEncrypt EntryEncryptAgent = new DESedeEntryEncrypt(myKey, ivBytes, "ASCII");
String Entry = "test test test";
String encodedEncryptedEntry = EntryEncryptAgent.encrypt(Entry); -
NoSuchMethodError at javax.crypto.SunJCE_b
Please help new to security.
JDK Version: j2sdk1.4.1_02
OS: windows
I am getting NoSuchMethodError on the line that has
KeyGenerator kg = KeyGenerator.getInstance("DES");
I have used the -Djava.security.debug=all feature and that is the only exception thrown.
java.lang.NoSuchMethodError
at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
at javax.crypto.KeyGenerator.getInstance(DashoA6275)
at CipherData.main(CipherData.java:13)
Exception in thread "main"
Code sniplet
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;
public class CipherData {
public static void main(String[] argv) {
try {
// ******* ERROR HERE ********* //
KeyGenerator kg = KeyGenerator.getInstance("DES");
Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
Key key = kg.generateKey();
cipher.init(Cipher.ENCRYPT_MODE, key);Please check current version of java,and sure wondows path refer right
%JAVA_HOME%\bin. -
Javax.crypto.Cipher.a noClassDefFoundError
We have been encrypting a string using the JCE on our desktop weblogic environment. It works fine there (Windows)
when we try it on our server (Unix), it blows up with the following error:
java.lang.NoClassDefFoundError
at javax.crypto.Cipher.a(DashoA6275)
at javax.crypto.Cipher.getInstance(DashoA6275)
here is the code:
String key = PropertyReader.getProperty("key");
BASE64Decoder decoder = new BASE64Decoder();
byte[] rawKey = decoder.decodeBuffer(key);
SecretKeySpec skeySpec = new SecretKeySpec(rawKey, "AES");
Provider p = Security.getProvider("SunJCE");
Cipher cipher = Cipher.getInstance("AES",p); // We also tried Cipher.getInstance(“AESâ€) but got the same exception
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(participantId.getBytes());
BASE64Encoder encoder = new BASE64Encoder();
encryptedString = encoder.encodeBuffer(encrypted);
the server is weblogic 8.1.5 with ssl enabled.
if anyone had any tests to try or fixes, it would be great.Check the permissions on the jar files on your Unix server, particularly the JCE jar files if they were upgraded to support unlimited encryption.
If the JVM finds a jar file, but cannot open it, the first exception thrown will be related to permissions on the JAR and it will complain the the ZIP cannot be opened. Subsequent attempts to access classes that are expected to be in that JAR file will result in a noClassDefFoundError. -
Web Start Console :NoClassDefFoundError: javax/jms/JMSException
HI all,
am using JBoss server, J2SE1.4 ,windows XP
This my JNLP file :
<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://172.25.186.50:8080/JMSClient" href="JmsClient.jnlp">
<information>
<title>My JMS Consumer</title>
<vendor> System</vendor>
<icon href="icon.png"/>
<icon href="splash.png" kind="splash"/>
</information>
<security>
<j2ee-application-client-permissions/>
</security>
<resources>
<j2se version="1.4+"/>
<jar href="JMSconsumer.jar" main="true" download="eager"/>
<jar href="WEB-INF/lib/jboss-j2ee.jar"/>
<jar href="WEB-INF/lib/concurrent.jar"/>
<jar href="WEB-INF/lib/jboss-common.jar"/>
<jar href="WEB-INF/lib/jbossmq.jar"/>
<jar href="WEB-INF/lib/jnlp-servlet.jar"/>
<jar href="WEB-INF/lib/jardiff.jar"/>
<jar href="WEB-INF/lib/jnlp.jar"/>
<jar href="WEB-INF/lib/jnpserver.jar"/>
</resources>
<application-desc main-class="TafConsumer"/>
</jnlp>
Console Error message :
Java Web Start 1.4.2_06 Console, started Fri May 05 15:51:29 IST 2006 Java 2
Runtime Environment: Version 1.4.2_06 by Sun Microsystems Inc. Logging to
file: C:\Documents and Settings\2210\Desktop\tafClient.log
java.lang.NoClassDefFoundError: javax/jms/JMSException at
java.lang.Class.getDeclaredMethods0(Native Method) at
java.lang.Class.privateGetDeclaredMethods(Unknown Source) at
java.lang.Class.getMethod0(Unknown Source) at
java.lang.Class.getMethod(Unknown Source) at
com.sun.javaws.Launcher.executeApplication(Unknown Source) at
com.sun.javaws.Launcher.executeMainClass(Unknown Source) at
com.sun.javaws.Launcher.continueLaunch(Unknown Source) at
com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source) at
com.sun.javaws.Launcher.handleLaunchFile(Unknown Source) at
com.sun.javaws.Launcher.run(Unknown Source) at java.lang.Thread.run(Unknown
Source)
this is for my JMSconsumer.jar which has all my Classes(.class files)
MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.4.2_04 (Sun Microsystems Inc.)
Main-Class: TafConsumer
This is for my WAR file..
MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.4.2_04 (Sun Microsystems Inc.)
Main-Class: TafConsumer
Class-Path: WEB-INF/lib/concurrent.jar WEB-INF/lib/jardiff.jar WEB-INF/lib/jboss-common.jar WEB-INF/lib/jboss-j2ee.jar WEB-INF/lib/jbossmq.jar WEB-INF/lib/jnlp.jar WEB-INF/lib/jnlp-servlet.jar WEB-INF/lib/jnpserver.jar JMSconsumer.jar
while am running application it looks for JBoss-j2ee.jar file .. i have mention all the jar files which are required to run my application .... in JNLP file..
it was executing in my command prompt
like D:\java -jar applicationname.war
Am getting out put properly... ( I have mention in MAIFEST.MF file .. that this is my main class and class path also(for Jar files).. )
am missing some where around Jar file config..
pls. any one can give me the solution..
Thanks
DhanaHave you signed your jars ?
-
Java.lang.NoClassDefFoundError: javax/el/CompositeELResolver error
Hi to everyone.
i'm searching for help.
I'm working with a web project under WebShere and for working and compatibility reason I have to migrate from version 7.0 of WAS to older 6.1 version.
My project under version 7 run perfectly but now I not even can start correctly the WAS.
I receive the error about topic title: java.lang.NoClassDefFoundError: javax/el/CompositeELResolver error
The project was born to work with JSF 1.2 and RichFaces 3.3.2 but I know they are not supported under WAS 6.1 and so I've:
- first tried to imported in project older version of jsf and richfaces (jsf 1.1.02, rich 3.1.6);
- then tried to installed them as shared libraries;
suddenly i've tried to reinstall entire WAS... same result.
can someone help me?
PS: the content of console after start attempt is:
java.lang.NoClassDefFoundError: javax.el.CompositeELResolver
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:68)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:129)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:163)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.<init>(AbstractJSPExtensionProcessor.java:183)
at com.ibm.ws.jsp.webcontainerext.ws.WASJSPExtensionProcessor.<init>(WASJSPExtensionProcessor.java:65)
at com.ibm.ws.jsp.webcontainerext.ws.WASJSPExtensionFactory.createProcessor(WASJSPExtensionFactory.java:188)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionFactory.createExtensionProcessor(AbstractJSPExtensionFactory.java:75)
at com.ibm.ws.webcontainer.webapp.WebApp.initializeExtensionProcessors(WebApp.java:1186)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:340)
at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:337)
at com.ibm.ws.wswebcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:92)
at com.ibm.ws.wswebcontainer.VirtualHost.addWebApplication(VirtualHost.java:157)
at com.ibm.ws.wswebcontainer.WebContainer.addWebApp(WebContainer.java:666)
at com.ibm.ws.wswebcontainer.WebContainer.addWebApplication(WebContainer.java:619)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:395)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:611)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1304)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1165)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:587)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:832)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:950)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2131)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:342)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
Caused by: java.lang.ClassNotFoundException: javax.el.CompositeELResolver
at java.net.URLClassLoader.findClass(URLClassLoader.java:496)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:150)
at java.lang.ClassLoader.loadClass(ClassLoader.java:631)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:597)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:54)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:429)
at java.lang.ClassLoader.loadClass(ClassLoader.java:597)
... 26 moreLooks like you need an implementation of the EL language.
-
Hi,
The software's I used are:
1. Oracle Database (Oracle Database 11g Release 2 (11.2.0.1.0))
2. Repository Creation Utility (ofm_rcu_win32_11.1.1.2.1_disk1_1of1)
3. WebLogic (wls1033_oepe111150_win32)
4. WebCenter (ofm_wc_generic_11.1.1.2.0_disk1_1of1)
5. Content Management (ofm_ucm_generic_10.1.3.5.1_disk1_1of1)
When I try to run the Administration Server and the three Managed Servers (WLS_Portlet, WLS_Services and WLS_Spaces in Weblogic Server), it is throwing exception in WLS_Spaces and WLS_Portlet servers and completing to Running Mode.
Attaching the Log Details below for one of the server.
C:\Oracle\Middleware\user_projects\domains\base_domain\bin>startManagedWebLogic
.cmd WLS_Portlet http://dpdb:7001
JAVA Memory arguments: -Xms512m -Xmx1024m -XX:CompileThreshold=8000 -XX:PermSiz
e=128m -XX:MaxPermSize=256m
WLS Start Mode=Development
CLASSPATH=C:\Oracle\MIDDLE~1\patch_wls1033\profiles\default\sys_manifest_classp
ath\weblogic_patch.jar;C:\Oracle\MIDDLE~1\patch_oepe1033\profiles\default\sys_m
anifest_classpath\weblogic_patch.jar;C:\Oracle\MIDDLE~1\patch_ocp353\profiles\d
efault\sys_manifest_classpath\weblogic_patch.jar;C:\Oracle\MIDDLE~1\JDK160~1\li
b\tools.jar;C:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\weblogic_sp.jar;C:\Oracle\
MIDDLE~1\WLSERV~1.3\server\lib\weblogic.jar;C:\Oracle\MIDDLE~1\modules\features
\weblogic.server.modules_10.3.3.0.jar;C:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\
webservices.jar;C:\Oracle\MIDDLE~1\modules\ORGAPA~1.1/lib/ant-all.jar;C:\Oracle
\MIDDLE~1\modules\NETSFA~1.0_1/lib/ant-contrib.jar;C:\Oracle\MIDDLE~1\ORACLE~1\
soa\modules\commons-cli-1.1.jar;C:\Oracle\MIDDLE~1\ORACLE~1\soa\modules\oracle.
soa.mgmt_11.1.1\soa-infra-mgmt.jar;C:\Oracle\Middleware\Oracle_WC1\webcenter\mo
dules\oracle.portlet.server_11.1.1\oracle-portlet-api.jar;C:\Oracle\MIDDLE~1\OR
ACLE~1\modules\oracle.jrf_11.1.1\jrf.jar;C:\Oracle\MIDDLE~1\WLSERV~1.3\common\d
erby\lib\derbyclient.jar;C:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\xqrl.jar
PATH=C:\Oracle\MIDDLE~1\patch_wls1033\profiles\default\native;C:\Oracle\MIDDLE~
1\patch_oepe1033\profiles\default\native;C:\Oracle\MIDDLE~1\patch_ocp353\profil
es\default\native;C:\Oracle\MIDDLE~1\WLSERV~1.3\server\native\win\32;C:\Oracle\
MIDDLE~1\WLSERV~1.3\server\bin;C:\Oracle\MIDDLE~1\modules\ORGAPA~1.1\bin;C:\Ora
cle\MIDDLE~1\JDK160~1\jre\bin;C:\Oracle\MIDDLE~1\JDK160~1\bin;C:\app\Administra
tor\product\11.2.0\dbhome_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\Syste
m32\Wbem;C:\Oracle\MIDDLE~1\WLSERV~1.3\server\native\win\32\oci920_8
* To start WebLogic Server, use a username and *
* password assigned to an admin-level user. For *
* server administration, use the WebLogic Server *
* console at http:\\hostname:port\console *
starting weblogic with Java version:
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode)
Starting WLS with line:
C:\Oracle\MIDDLE~1\JDK160~1\bin\java -client -Xms512m -Xmx1024m -XX:CompileTh
reshold=8000 -XX:PermSize=128m -XX:MaxPermSize=256m -Dweblogic.Name=WLS_Portle
t -Djava.security.policy=C:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\weblogic.poli
cy -Dweblogic.security.SSL.trustedCAKeyStore="C:\Oracle\Middleware\wlserver_10.
3\server\lib\cacerts" -Xverify:none -da -Dplatform.home=C:\Oracle\MIDDLE~1\WL
SERV~1.3 -Dwls.home=C:\Oracle\MIDDLE~1\WLSERV~1.3\server -Dweblogic.home=C:\Ora
cle\MIDDLE~1\WLSERV~1.3\server -Ddomain.home=C:\Oracle\MIDDLE~1\USER_P~1\domai
ns\BASE_D~1 -Dcommon.components.home=C:\Oracle\MIDDLE~1\ORACLE~1 -Djrf.version=
11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Lo
gger -Djrockit.optfile=C:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.jrf_11.1.1\jr
ocket_optfile.txt -Doracle.domain.config.dir=C:\Oracle\MIDDLE~1\USER_P~1\domain
s\BASE_D~1\config\FMWCON~1 -Doracle.server.config.dir=C:\Oracle\MIDDLE~1\USER_P
~1\domains\BASE_D~1\config\FMWCON~1\servers\WLS_Portlet -Doracle.security.jps.c
onfig=C:\Oracle\MIDDLE~1\USER_P~1\domains\BASE_D~1\config\fmwconfig\jps-config.
xml -Djava.protocol.handler.pkgs=oracle.mds.net.protocol -Digf.arisidbeans.car
mlloc=C:\Oracle\MIDDLE~1\USER_P~1\domains\BASE_D~1\config\FMWCON~1\carml -Digf
.arisidstack.home=C:\Oracle\MIDDLE~1\USER_P~1\domains\BASE_D~1\config\FMWCON~1\
arisidprovider -Dweblogic.alternateTypesDirectory=\modules\oracle.ossoiap_11.1.
1,\modules\oracle.oamprovider_11.1.1 -Dweblogic.jdbc.remoteEnabled=false -Dtan
gosol.coherence.log=jdk -DjiveHome=C:\Oracle\MIDDLE~1\USER_P~1\domains\BASE_D~1
\config\fmwconfig\servers\WLS_Portlet\owc_discussions_11.1.1.2.0 -Doracle.wc.op
enusage.clustername=localhost -Doracle.wc.openusage.collectorport=31314 -Doracl
e.wc.openusage.timeout=30 -Doracle.wc.openusage.unicast=true -Doracle.wc.openus
age.enabled=false -Doracle.core.ojdl.logging.usercontextprovider=oracle.core.oj
dl.logging.impl.UserContextImpl -DUSE_JAAS=false -Djps.policystore.hybrid.mode=
false -Djps.combiner.optimize.lazyeval=true -Djps.combiner.optimize=true -Djps.
auth=ACC -Doracle.core.ojdl.logging.usercontextprovider=oracle.core.ojdl.loggin
g.impl.UserContextImpl -Doracle.wc.openusage.clustername=localhost -Doracle.wc.
openusage.collectorport=31314 -Doracle.wc.openusage.timeout=30 -Doracle.wc.open
usage.unicast=true -Doracle.wc.openusage.enabled=false -Doracle.webcenter.taggi
ng.scopeTags=false -Doracle.mds.bypassCustRestrict=true -Djava.awt.headless=tru
e -Doracle.webcenter.tagging.scopeTags=false -XX:+UseParallelGC -XX:+DisableExp
licitGC -Dwc.oracle.home=C:\Oracle\Middleware\Oracle_WC1 -Dem.oracle.home=C:\
Oracle\Middleware\oracle_common -Djava.awt.headless=true -Dweblogic.management.
discover=false -Dweblogic.management.server=http://dpdb:7001 -Dwlw.iterativeDe
v=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.d
irs=C:\Oracle\MIDDLE~1\patch_wls1033\profiles\default\sysext_manifest_classpath
;C:\Oracle\MIDDLE~1\patch_oepe1033\profiles\default\sysext_manifest_classpath;C
:\Oracle\MIDDLE~1\patch_ocp353\profiles\default\sysext_manifest_classpath webl
ogic.Server
<Jul 16, 2010 11:01:55 AM IST> <Notice> <WebLogicServer> <BEA-000395> <Followin
g extensions directory contents added to the end of the classpath:
C:\Oracle\Middleware\user_projects\domains\base_domain\lib\mbeantypes\csp-id-as
serter.jar>
<Jul 16, 2010 11:01:55 AM IST> <Info> <WebLogicServer> <BEA-000377> <Starting W
ebLogic Server with Java HotSpot(TM) Client VM Version 16.0-b13 from Sun Micros
ystems Inc.>
<Jul 16, 2010 11:01:57 AM IST> <Info> <Security> <BEA-090065> <Getting boot ide
ntity from user.>
Enter username to boot WebLogic server:weblogic
Enter password to boot WebLogic server:
<Jul 16, 2010 11:02:12 AM IST> <Info> <Management> <BEA-141107> <Version: WebLo
gic Server 10.3.3.0 Fri Apr 9 00:05:28 PDT 2010 1321401 >
<Jul 16, 2010 11:02:14 AM IST> <Notice> <WebLogicServer> <BEA-000365> <Server s
tate changed to STARTING>
<Jul 16, 2010 11:02:14 AM IST> <Info> <WorkManager> <BEA-002900> <Initializing
self-tuning thread pool>
<Jul 16, 2010 11:02:14 AM IST> <Notice> <LoggingService> <BEA-320400> <The log
file C:\Oracle\Middleware\user_projects\domains\base_domain\servers\WLS_Portlet
\logs\WLS_Portlet.log will be rotated. Reopen the log file if tailing has stopp
ed. This can happen on some platforms like Windows.>
<Jul 16, 2010 11:02:14 AM IST> <Notice> <LoggingService> <BEA-320401> <The log
file has been rotated to C:\Oracle\Middleware\user_projects\domains\base_domain
\servers\WLS_Portlet\logs\WLS_Portlet.log00001. Log messages will continue to b
e logged in C:\Oracle\Middleware\user_projects\domains\base_domain\servers\WLS_
Portlet\logs\WLS_Portlet.log.>
<Jul 16, 2010 11:02:14 AM IST> <Notice> <Log Management> <BEA-170019> <The serv
er log file C:\Oracle\Middleware\user_projects\domains\base_domain\servers\WLS_
Portlet\logs\WLS_Portlet.log is opened. All server side log events will be writ
ten to this file.>
<Jul 16, 2010 11:02:19 AM IST> <Notice> <Security> <BEA-090082> <Security initi
alizing using security realm myrealm.>
<Jul 16, 2010 11:02:20 AM IST> <Notice> <LoggingService> <BEA-320400> <The log
file C:\Oracle\Middleware\user_projects\domains\base_domain\servers\WLS_Portlet
\logs\access.log will be rotated. Reopen the log file if tailing has stopped. T
his can happen on some platforms like Windows.>
<Jul 16, 2010 11:02:20 AM IST> <Notice> <LoggingService> <BEA-320401> <The log
file has been rotated to C:\Oracle\Middleware\user_projects\domains\base_domain
\servers\WLS_Portlet\logs\access.log00001. Log messages will continue to be log
ged in C:\Oracle\Middleware\user_projects\domains\base_domain\servers\WLS_Portl
et\logs\access.log.>
<Jul 16, 2010 11:02:24 AM IST> <Notice> <WebLogicServer> <BEA-000365> <Server s
tate changed to STANDBY>
<Jul 16, 2010 11:02:24 AM IST> <Notice> <WebLogicServer> <BEA-000365> <Server s
tate changed to STARTING>
java.lang.NoClassDefFoundError: javax/wsdl/Definition
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.privateGetPublicMethods(Class.java:2547)
at java.lang.Class.privateGetPublicMethods(Class.java:2557)
at java.lang.Class.getMethods(Class.java:1410)
at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.getImplementedI
nterfaces(EjbAnnotationProcessor.java:1687)
at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processSessionA
nnotations(EjbAnnotationProcessor.java:447)
at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotati
ons(EjbAnnotationProcessor.java:310)
at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotati
ons(EjbAnnotationProcessor.java:180)
at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.processStandar
dAnnotations(EjbDescriptorReaderImpl.java:344)
at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnly
DescriptorFromJarFile(EjbDescriptorReaderImpl.java:204)
at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJa
rFile(EjbDescriptorFactory.java:93)
at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModul
e.java:1242)
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:395
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(Mod
uleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(Dep
loymentCallbackFlow.java:507)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachine
Driver.java:41)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(De
ploymentCallbackFlow.java:149)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(De
ploymentCallbackFlow.java:45)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.j
ava:1221)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachine
Driver.java:41)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.
java:367)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.ja
va:58)
at weblogic.application.internal.DeploymentStateChecker.prepare(Deploym
entStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(Ap
pContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeplo
yment.java:141)
at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(De
ploymentAdapter.java:39)
at weblogic.management.deploy.internal.DeploymentAdapter.prepare(Deploy
mentAdapter.java:191)
at weblogic.management.deploy.internal.AppTransition$1.transitionApp(Ap
pTransition.java:21)
at weblogic.management.deploy.internal.ConfiguredDeployments.transition
Apps(ConfiguredDeployments.java:240)
at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(Co
nfiguredDeployments.java:165)
at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(Con
figuredDeployments.java:122)
at weblogic.management.deploy.internal.DeploymentServerService.resume(D
eploymentServerService.java:180)
at weblogic.management.deploy.internal.DeploymentServerService.start(De
ploymentServerService.java:96)
at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: java.lang.ClassNotFoundException: javax.wsdl.Definition
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 37 more
<Jul 16, 2010 11:02:32 AM IST> <Error> <Deployer> <BEA-149205> <Failed to initi
alize the application 'wsm-pm' due to error weblogic.application.ModuleExceptio
n: Exception preparing module: EJBModule(wsm-pmserver.jar)
[EJB:011023]An error occurred while reading the deployment descriptor. The erro
r was:
javax/wsdl/Definition..
weblogic.application.ModuleException: Exception preparing module: EJBModule(wsm
-pmserver.jar)
[EJB:011023]An error occurred while reading the deployment descriptor. The erro
r was:
javax/wsdl/Definition.
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:467
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(Mod
uleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(Dep
loymentCallbackFlow.java:507)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachine
Driver.java:41)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(De
ploymentCallbackFlow.java:149)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: javax.wsdl.Definition
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
Truncated. see log file for complete stacktrace
>
<Jul 16, 2010 11:02:38 AM IST> <Error> <Deployer> <BEA-149205> <Failed to initi
alize the application 'wsrp-tools [Version=11.1.1.2.0]' due to error java.lang.
ClassNotFoundException: javax.wsdl.WSDLException.
java.lang.ClassNotFoundException: javax.wsdl.WSDLException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: javax.wsdl.WSDLException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
Truncated. see log file for complete stacktrace
>
<Jul 16, 2010 11:02:41 AM IST> <Notice> <Log Management> <BEA-170027> <The Serv
er has established connection with the Domain level Diagnostic Service successf
ully.>
<Jul 16, 2010 11:02:42 AM IST> <Error> <oracle.wsm.resources.policymanager> <WS
M-02054> <Failure in looking up EJB component QueryService#oracle.wsm.policyman
ager.ejb.IStringQueryServiceRemote.>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <WebLogicServer> <BEA-000365> <Server s
tate changed to ADMIN>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <WebLogicServer> <BEA-000365> <Server s
tate changed to RESUMING>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <Security> <BEA-090171> <Loading the id
entity certificate and private key stored under the alias DemoIdentity from the
jks keystore file C:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\DemoIdentity.jks.>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <Security> <BEA-090169> <Loading truste
d certificates from the jks keystore file C:\Oracle\MIDDLE~1\WLSERV~1.3\server\
lib\DemoTrust.jks.>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <Security> <BEA-090169> <Loading truste
d certificates from the jks keystore file C:\Oracle\MIDDLE~1\JDK160~1\jre\lib\s
ecurity\cacerts.>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <Security> <BEA-090898> <Ignoring the t
rusted CA certificate "CN=T-TeleSec GlobalRoot Class 3,OU=T-Systems Trust Cente
r,O=T-Systems Enterprise Services GmbH,C=DE". The loading of the trusted certif
icate list raised a certificate parsing exception PKIX: Unsupported OID in the
AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <Security> <BEA-090898> <Ignoring the t
rusted CA certificate "CN=T-TeleSec GlobalRoot Class 2,OU=T-Systems Trust Cente
r,O=T-Systems Enterprise Services GmbH,C=DE". The loading of the trusted certif
icate list raised a certificate parsing exception PKIX: Unsupported OID in the
AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <Security> <BEA-090898> <Ignoring the t
rusted CA certificate "CN=GlobalSign,O=GlobalSign,OU=GlobalSign Root CA - R3".
The loading of the trusted certificate list raised a certificate parsing except
ion PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1
.11.>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <Security> <BEA-090898> <Ignoring the t
rusted CA certificate "OU=Security Communication RootCA2,O=SECOM Trust Systems
CO.\,LTD.,C=JP". The loading of the trusted certificate list raised a certifica
te parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1
.2.840.113549.1.1.11.>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <Security> <BEA-090898> <Ignoring the t
rusted CA certificate "CN=KEYNECTIS ROOT CA,OU=ROOT,O=KEYNECTIS,C=FR". The load
ing of the trusted certificate list raised a certificate parsing exception PKIX
: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <Server> <BEA-002613> <Channel "Default
" is now listening on 10.0.4.126:8889 for protocols iiop, t3, ldap, snmp, http.
>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <Server> <BEA-002613> <Channel "Default
Secure" is now listening on 10.0.4.126:8789 for protocols iiops, t3s, ldaps, ht
tps.>
<Jul 16, 2010 11:02:42 AM IST> <Notice> <WebLogicServer> <BEA-000332> <Started
WebLogic Managed Server "WLS_Portlet" for domain "base_domain" running in Devel
opment Mode>
<Jul 16, 2010 11:02:45 AM IST> <Notice> <WebLogicServer> <BEA-000365> <Server s
tate changed to RUNNING>
<Jul 16, 2010 11:02:45 AM IST> <Notice> <WebLogicServer> <BEA-000360> <Server s
tarted in RUNNING mode>
I'm stuck on this since a long and time and not able to resolve it. Please post the solution if any.
Thanks and advance,
Surender ReddyAt first sight it seems your webcenter installation does not match the version of your WLS.
Your WLS installations seems to be 10.33 and not 10.3.2
If you are using WLS 10.3.3 you MUST also install webcenter 11.1.3
That could be the cause of your problems. -
AES -javax.crypto.BadPaddingException: Given final block notproperly padded
I have an Encrypt Util class to encrypt and decrypt CLOB content in the database(Oracle). During encryption there is no error/exception thrown., But while decryption it throws the exception javax.crypto.BadPaddingException: Given final block notproperly padded.
The error is thrown only for selected records, not for all. For most of them it works fine. I use 256 bit AES Encryption.The sequence of steps to generate and retrieve the key is as follows:
(Generating and Storing the Key)
Generate original Key Using JCE --> Then XOR it with a known String (Key) --> Write to a file in DB Server (Solaris 10) using a Stored Procedure.
(Retrieving the Key)
Read the key file using s Stored Procedure --> XOR it with known String(Key) --> Retrieve the original Key
The decryption works fine for most of the records (70%) but failing 30% of the time. There is no exception in the way the encrypted content gets stored in the db
The key is generated as a one time step in the application and stored in the file. It is retrieved and cached in the application once, everytime the appserver is restarted.
Could someone pls. help?
Attaching below (1) code snippet for generating the key and (2) The code snipped to retrieve the key (3) the class which does the encryption and decryption of data
(1) code snippet for generating the key
String xorRefKey = "*&^%$#@!AiMsKey!*&^%$#@!AiMsKey!";
KeyGenerator kg = KeyGenerator.getInstance("AES");
kg.init(256);
String initialKey = new String (kg.generateKey().getEncoded());
char[] refArr = xorRefKey.toCharArray();
char[] initKeyArr = initialKey.toCharArray();
char[] finalKeyArr = new char[refArr.length];
for(int i=0;i<initKeyArr.length;i++){
finalKeyArr= (char)(initKeyArr[i] ^ refArr[i]);
String finalKey = new String(finalKeyArr);----------------------
(2) The code snipped to retrieve the keyString xorRefKey = "*&^%$#@!AiMsKey!*&^%$#@!AiMsKey!";
char[] refArr = xorRefKey.toCharArray();
//initialKey is the key read from the file using a db call
char[] initKeyArr = initialKey.toCharArray();
char[] finalKeyArr = new char[refArr.length];
for(int i=0;i<initKeyArr.length;i++){
finalKeyArr[i]= (char)(initKeyArr[i] ^ refArr[i]);
String finalKey= new String(finalKeyArr);
Class to encrypt/decrypt
(3) EncryptUtil classpublic class EncryptUtil {
private static SecretKeySpec skeySpec = null;
private static final String encryptionAlgorithm = "AES";
private static IGOLogger logger = IGOLogger.getInstance(IGOLogger.ENCRYPTION);
private static final String UNICODE_FORMAT = "UTF8";
private Cipher cipher = null;
public EncryptUtil(String key){
String lFuncName = "EncryptUtil :: EncryptUtil(): ";
try{
cipher = Cipher.getInstance(encryptionAlgorithm);
skeySpec = new SecretKeySpec(key.getBytes(), encryptionAlgorithm);
} catch (NoSuchAlgorithmException e) {
logger.error(lFuncName + "No Such Algorithm Error while creating Cipher and KeySpec ",e);
} catch (NoSuchPaddingException e) {
logger.error(lFuncName + "No Such Padding Error while creating Cipher and KeySpec ",e);
* Encrypts the data based on the key and algorithm
* @param data
* @return encrypted data
public String encrypt(String data){
String lFuncName = "EncryptUil :: encrypt(): ";
byte[] encryptedData = null;
String encryptedFinal = "";
try{
if(data!=null && data.length()>0){
cipher.init(Cipher.ENCRYPT_MODE, skeySpec,cipher.getParameters());
encryptedData = (cipher.doFinal(data.getBytes(UNICODE_FORMAT)));
encryptedFinal = new BASE64Encoder().encode(encryptedData);
} catch (InvalidKeyException e) {
logger.error(lFuncName + "Invalid Key Error while Encrypting Data ",e);
} catch (BadPaddingException e) {
logger.error(lFuncName + "Bad Padding Error while Encrypting Data ",e);
} catch (IllegalBlockSizeException e) {
logger.error(lFuncName + " Illegal Block Size Error while Encrypting Data ",e);
} catch (InvalidAlgorithmParameterException e) {
logger.error(lFuncName + " Invalid Alogirthm Parameter Error while Encrypting Data ",e);
} catch (UnsupportedEncodingException e) {
logger.error(lFuncName + " Unsupported Encoding Exception Error while Encrypting Data ",e);
}catch(Exception e){
logger.error(lFuncName + " Error while Encrypting Data ",e);
return encryptedFinal;
* Decrypts the encrypted data based on the key and algorithm
* @param data
* @return
public String decrypt (String data){
String lFuncName = "EncryptUil :: decrypt(): ";
byte[] decrypted = null;
byte[] decryptedFinal = null;
String decryptedData = "";
try{
if(data!=null && data.length()>0){
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
decrypted = new BASE64Decoder().decodeBuffer(data);
decryptedFinal = (cipher.doFinal(decrypted));
decryptedData = this.bytes2String(decryptedFinal);
} catch (InvalidKeyException e) {
logger.error(lFuncName + "Invalid Key Error while Decrypting Data ",e);
} catch (BadPaddingException e) {
logger.error(lFuncName + "Bad Padding Error while Decrypting Data ",e);
} catch (IllegalBlockSizeException e) {
logger.error(lFuncName + " Illegal Block Size Error while Decrypting Data ",e);
} catch (IOException e) {
logger.error(lFuncName + " IO Exception while Decrypting Data ",e);
}catch (Exception e){
logger.error(lFuncName + " Error while Decrypting Data ",e);
return decryptedData;
private String bytes2String( byte[] bytes )
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < bytes.length; i++)
stringBuffer.append( (char) bytes[i] );
return stringBuffer.toString();
}The EncryptUtil is invoked as follows:EncryptUtil encryptUtil = new EncryptUtil("finalKey retrieved when application starts");
encryptUtil.encrypt(unencryptedData);shannara wrote:
thanks for your reply.
I am sorry but I am not able to get you exactly. Every time I invoke the Utility class, I do a
EncryptUtil eUtil = new EncryptUtil() Good. You seem to be using it in a thread safe manner since you create a new instance each time you need to use one.
>
and then invoke the decrypt() or encrypt() method, which gets the key from the cache (it is a read only object, so no problems of concurrent modification or any thing of that sort). And also these methods are called from a normal java class only, which inturn may be called from a jsp/servlet, but no scenarios of any concurrent access as such, so based on what you said, I am not able to figure out where exactly the thread safety could come as an issue.Each instance of a jsp or servlet can be being processed by many threads at the same time. Your statement above hints at a possible lack of understand on this point though I could be just reading it wrong. It indicates to me that your problem may be nothing to do with the encryption and everything to do with 'concurrent access' .
Make sure you have no instance variables or class variables in your jsp(s) and servlet(s).
Edit: The more I think about this the more I believe you have a thread safety problem in the code that reads the key. I would concentrate on that.
Edited by: sabre150 on Dec 18, 2007 10:10 AM
Maybe you are looking for
-
Hello, I'm trying to load a bank statement to the application by defining a new testing template and populating it with the BAI2 template. I have redefined the testing template with sample lines information. I ftp the dat file as ASCII to the server
-
How do I stop firefox from suggesting my log in details when i enter a website
Since downloading firefox, every time I go to a website and start to enter my user name firefox immediately suggests my details for all to see. How do I stop this
-
Networking - same IP address on 2 computers
Somehow my 2 macs have the same IP address and so I cannot access internet from both at the same time (via Airport wireless) - how can I reset one of the computers to get rid of the IP address and start over with an automatically assigned IP? I have
-
Does anyone know the thickness of the rubber around the bezel of the screen?
I am trying to determine how think the rubber around the bezel is because I am interested in purchasing a Shaggymac Screen/keyboard cover for my 13" Macbook Air. The thickness of the cloth reported on the sight is .6mm. More or less, my question is w
-
Best software to print greeting cards
I need a software recommendation to print greeting type cards, messages or notes on card stock ~ 4x5 in. I've used Publisher in the past and was wondering it there's an alternative?