Author |
Message
|
vickas |
Posted: Fri Oct 18, 2013 8:09 am Post subject: apache/commons/codec/binary/Base64.encodeBase64String([[B)Lj |
|
|
Centurion
Joined: 18 Aug 2013 Posts: 126
|
Hie Guys,
am getting an error
java.lang.NoSuchMethodError: org/apache/commons/codec/binary/Base64.encodeBase64String([B)Ljava/lang/String; when am calling a java method from ESQL .
i have imported the commons-codec-1.5.jar, added it to the JRE System Library and set the class path too.
why am i getting this error ? my research says i need to update java, will it work ? please explain in detail about what to do to avoid this error.
your help will be applauded. |
|
Back to top |
|
 |
Simbu |
Posted: Fri Oct 18, 2013 8:53 am Post subject: |
|
|
 Master
Joined: 17 Jun 2011 Posts: 289 Location: Tamil Nadu, India
|
There is a ESQL function called "BASE64ENCODE" which will do the Base64 encoding instead of calling a java method from ESQL to achieve the same. |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Oct 18, 2013 9:44 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Are you by any chance working with the person who posted this ?
http://www.mqseries.net/phpBB2/viewtopic.php?t=65668
If you are PLEASE do not start a separate thread. Even if you aren't the questions are so similar then there is a good chance that the results are the same.
The other question is why are you not using the BASE^$Encode function that is there in the standard JRE?
As far as I know, the ESQL function calls the Java one under the hood. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
kimbert |
Posted: Fri Oct 18, 2013 12:53 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
As far as I know, the ESQL function calls the Java one under the hood. |
Not so, actually. None of the ESQL built-in functions are implemented in Java. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Oct 18, 2013 12:58 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Oct 18, 2013 9:52 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
kimbert wrote: |
Quote: |
As far as I know, the ESQL function calls the Java one under the hood. |
Not so, actually. None of the ESQL built-in functions are implemented in Java. |
Ok. My memory might be a little better today.
I think that in V6.1 this function was missing from ESQL so a 'fix' was to simply call the Java function.
Anyway, my point still stands as to why the OP is trying to use another version of a function that is there already. This is one of my big gripes with Java. There are countless numbers of functions in all sorts of packages that implement the same thing. Many Java Devs have their favourite set of class libraries. Trying to prise them out of their hands, mice and keyboards is a next to impossible so we get all sorts of apparently random class paths and libraries to configure.
The effort in trying to rationalise them is like trying to climb Everest IMHO. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
vickas |
Posted: Fri Oct 18, 2013 10:23 pm Post subject: |
|
|
Centurion
Joined: 18 Aug 2013 Posts: 126
|
Now, i upgraded my java version from 1.6 to 1.7 but stilll i get an error,
this is how i call my java function from ESQL:
DECLARE pkey CHARACTER ;
CALL genKey(pkey);
CREATE PROCEDURE genKey( INOUT pkey CHARACTER )
LANGUAGE JAVA
EXTERNAL NAME "acces.AES.generateKey";
this is how my java method looks like :
public static void generateKey(String[] key) throws NoSuchAlgorithmException
{
KeyGenerator keyGen;
keyGen = KeyGenerator.getInstance(aesEncryptionAlgorithm);
SecureRandom random = new SecureRandom(); // cryptograph. secure random
keyGen.init(random);
SecretKey secretKey = keyGen.generateKey();
byte[] raw = secretKey.getEncoded();
key[0] = Base64.encodeBase64String(raw);
System.out.println(Base64.class.getProtectionDomain().getCodeSource().getLocation());
//return Base64.encodeBase64String(raw);
}
and i get an exception :
Insert
Type:INTEGER:5
Text:CHARACTER:genKey
RecoverableException
File:CHARACTER:F:\build\slot1\S000_P\src\DataFlowEngine\ImbRdl\ImbRdlExternalJava.cpp
Line:INTEGER:1138
Function:CHARACTER:ESQL2JavaMethodResolver::decodeReturnStatus
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2927
Text:CHARACTER:The Java method has a throws clause
Insert
Type:INTEGER:5
Text:CHARACTER:acces.AES.generateKey
How do i call a java function which throws exceptions from ESQL ? |
|
Back to top |
|
 |
dogorsy |
Posted: Fri Oct 18, 2013 11:26 pm Post subject: |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
vickas wrote: |
Now, i upgraded my java version from 1.6 to 1.7 but stilll i get an error,
this is how i call my java function from ESQL:
DECLARE pkey CHARACTER ;
CALL genKey(pkey);
CREATE PROCEDURE genKey( INOUT pkey CHARACTER )
LANGUAGE JAVA
EXTERNAL NAME "acces.AES.generateKey";
this is how my java method looks like :
public static void generateKey(String[] key) throws NoSuchAlgorithmException
{
KeyGenerator keyGen;
keyGen = KeyGenerator.getInstance(aesEncryptionAlgorithm);
SecureRandom random = new SecureRandom(); // cryptograph. secure random
keyGen.init(random);
SecretKey secretKey = keyGen.generateKey();
byte[] raw = secretKey.getEncoded();
key[0] = Base64.encodeBase64String(raw);
System.out.println(Base64.class.getProtectionDomain().getCodeSource().getLocation());
//return Base64.encodeBase64String(raw);
}
and i get an exception :
Insert
Type:INTEGER:5
Text:CHARACTER:genKey
RecoverableException
File:CHARACTER:F:\build\slot1\S000_P\src\DataFlowEngine\ImbRdl\ImbRdlExternalJava.cpp
Line:INTEGER:1138
Function:CHARACTER:ESQL2JavaMethodResolver::decodeReturnStatus
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2927
Text:CHARACTER:The Java method has a throws clause
Insert
Type:INTEGER:5
Text:CHARACTER:acces.AES.generateKey
How do i call a java function which throws exceptions from ESQL ? |
The error message is very clear. If after reading the error, you go and read the documentation, in the control center, "CREATE FUNCTION statement" and look for java routines, you will find the answer. |
|
Back to top |
|
 |
|