commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Java Struts <>
Subject java.lang.NoClassDefFoundError: org.apache.commons.codec.binary.Hex
Date Tue, 13 Oct 2009 15:42:41 GMT
I am trying to use the Hex encoding. So when ran it as a java application
which is working fine. And whn i incorporated the same in my code and
deployed the ear.. i am getting this exception.
And i have included the jar file in the ear. I didn't understand wht's
happeining.. any help?

4 gov.ed.telework.delegate.TeleworkDelegate - got RemoteException
RemoteException occurred in server thread; nested exception is:
	java.rmi.RemoteException: ; nested exception is:
	java.lang.NoClassDefFoundError: org.apache.commons.codec.binary.Hex
10/09 12:12:49 execute 100 WebContainer : 4
gov.ed.telework.ui.EmpTeleworkAgreementAction - Unexpected Expection:
Exception occurred..

Here is the code for it..

*public* *static* String encryptString(SecretKey key, String input)
*throws* NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalStateException, IllegalBlockSizeException,
BadPaddingException, UnsupportedEncodingException {
    	Cipher cipher = Cipher.getInstance("DESede");
    	cipher.init(Cipher.ENCRYPT_MODE, key);
    	//byte[] inputBytes = input.getBytes();
    	*byte*[] inputBytes = input.getBytes("UTF-8");
    	*byte*[] encryptedBytes= cipher.doFinal(inputBytes);
    	//String encryptedString = new
    	String abc =
    	*return* abc;
    	//return URLEncoder.encode(encryptedString, "UTF-8");
    	//return encryptedString;
 *public* *static* String decryptString(SecretKey key, String
encryptedString) *throws* IOException, NoSuchAlgorithmException,
NoSuchPaddingException, InvalidKeyException,
IllegalBlockSizeException, BadPaddingException, DecoderException {
 		// TODO Auto-generated method stub
    	*byte*  abc[] =
    	//String ka = URLDecoder.decode(encryptedString, "UTF-8");
     	//byte[] encryptedBytes = new sun.misc.BASE64Decoder().decodeBuffer(ka);
     	Cipher cipher = Cipher.getInstance("DESede");
     	cipher.init(Cipher.DECRYPT_MODE, key);
     	//byte[] recoveredBytes = cipher.doFinal(encryptedBytes);
     	*byte*[] recoveredBytes = cipher.doFinal(abc);
     	//String recoveredString = new String(recoveredBytes);
     	String recoveredString = *new* String(recoveredBytes,"UTF-8");
     	*return* recoveredString;

Could you guys please help me on this?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message