Author |
Message
|
SANTYP |
Posted: Thu Aug 26, 2010 10:34 pm Post subject: Error occured whilst trying to locate a Java Class /method |
|
|
 Centurion
Joined: 27 Mar 2007 Posts: 142
|
Hi guys,
I am trying to call a java program from esql,
here is esql prog i written to call external java..
CREATE PROCEDURE callReadXLS ( IN data BLOB,IN sheetName CHARACTER, IN rowCount INTEGER ) RETURNS BLOB
LANGUAGE JAVA
EXTERNAL NAME "some.core.ExcelRead.getDataFromXls";
and my java prog is as below
public class ExcelRead {
public static byte[] getDataFromXls(byte[] filXpt, String sheetName,
long rowCntStartsfrom) {
byte[] bb = null;
<Some line of logic>
return bb;
}
}
Standalone java prog executed perfectly...
but trying to access from esql I am getting
Error occured whilst trying to locate a Java Class /method error
Quote: |
Text:CHARACTER:An error occured whilst trying to locate a Java Class / method
Insert
Type:INTEGER:5
Text:CHARACTER:.Flow_Compute.callReadXLS
Insert
Type:INTEGER:5
Text:CHARACTER:1.2
Insert
Type:INTEGER:5
Text:CHARACTER:pams.core.ExcelRead.getDataFromXls
Insert
Type:INTEGER:5
Text:CHARACTER:callReadXLS
RecoverableException
File:CHARACTER:F:\build\S000_P\src\DataFlowEngine\ImbRdl\ImbRdlExternalJava.cpp
Line:INTEGER:1104
Function:CHARACTER:ESQL2JavaMethodResolver::decodeReturnStatus
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2946
Text:CHARACTER:The Java method could not be found
Insert
Type:INTEGER:5
Text:CHARACTER:pams.core.ExcelRead.getDataFromXls
|
Plz help me to understand the issue..
your help is highly appreciated..
Thanks in advance
don't POST below url to refer... I already refered... and tried not workedout
http://www.mqseries.net/phpBB2/viewtopic.php?t=52601 |
|
Back to top |
|
 |
mgk |
Posted: Fri Aug 27, 2010 12:36 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
The Java method's signature that you posted does not match your ESQL procedure's signature as "long" should be "Long". Read the docs on the ESQL to Java type mappings... _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
SANTYP |
Posted: Fri Aug 27, 2010 12:41 am Post subject: |
|
|
 Centurion
Joined: 27 Mar 2007 Posts: 142
|
I changed to "Long".. but still the same issue.. not able to find java class or method.
public static byte[] getDataFromXls(byte[] filXpt, String sheetName,
Long rowCntStartsfrom) {
// some logic
} |
|
Back to top |
|
 |
SANTYP |
Posted: Fri Aug 27, 2010 12:46 am Post subject: |
|
|
 Centurion
Joined: 27 Mar 2007 Posts: 142
|
mgk wrote: |
The Java method's signature that you posted does not match your ESQL procedure's signature as "long" should be "Long". Read the docs on the ESQL to Java type mappings... |
Hey mgk.. it worked sorry.. for the previous post...
thank u very much buddy..
thanks for observing these small mistakes...  |
|
Back to top |
|
 |
cutejigs |
Posted: Mon Aug 15, 2011 10:31 pm Post subject: |
|
|
Novice
Joined: 20 Jan 2010 Posts: 20
|
hi mgk,
good day
i am also having the same problem. i checked the ESQL to Java mappings and i "think" i got it right but i am encountering the same error. i am using WMB V7. below is the java file i have created:
-------------------------------------------------------------------------------------
public class MD5Generator {
public static byte[] createChecksum(String filelocation, String filename) throws Exception
{
String targetFile = filelocation + filename;
InputStream fis = new FileInputStream(targetFile);
byte[] buffer = new byte[1024];
MessageDigest complete = MessageDigest.getInstance("MD5");
int numRead;
do {
numRead = fis.read(buffer);
if (numRead > 0) {
complete.update(buffer, 0, numRead);
}
} while (numRead != -1);
fis.close();
return complete.digest();
}
public static String getMD5Checksum(String filelocation, String filename) throws Exception {
byte[] b = createChecksum(filelocation, filename);
String result = "";
for (int i=0; i < b.length; i++) {
result +=
Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );
}
return result;
}
}
-------------------------------------------------------------------------------------
and this is the ESQL:
-------------------------------------------------------------------------------------
CREATE COMPUTE MODULE NPSS_PROTOTYPE_MD5CHECKSUM_Generate_MD5Checksum
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
/*
Declare variables
*/
DECLARE fileLocation CHARACTER InputRoot.XMLNSC.InMessage.FileLocation;
DECLARE fileName CHARACTER InputRoot.XMLNSC.InMessage.FileName;
DECLARE md5Checksum CHARACTER generateMD5Checksum(fileLocation, fileName);
/*
Create output message
*/
CALL CopyMessageHeaders();
SET OutputRoot.XMLNSC.OutMessage.MD5 = md5Checksum;
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;
CREATE PROCEDURE generateMD5Checksum(IN fileLocation CHARACTER, IN fileName CHARACTER)
RETURNS CHARACTER
LANGUAGE JAVA
EXTERNAL NAME "com.npss.no.lo.prototype.MD5Generator.getMD5Checksum";
-------------------------------------------------------------------------------------
thanks in advance! |
|
Back to top |
|
 |
jlaisbett |
Posted: Tue Aug 16, 2011 12:45 am Post subject: |
|
|
Apprentice
Joined: 27 Nov 2009 Posts: 39
|
I believe your problem is the fact that your java method throws Exception, that won't work. I don't know if it's even possible to change the ESQL to work with Java methods that throw Exception as I'm pretty sure it's just not allowed. |
|
Back to top |
|
 |
cutejigs |
Posted: Tue Aug 16, 2011 7:39 pm Post subject: |
|
|
Novice
Joined: 20 Jan 2010 Posts: 20
|
thanks jlaisbett!
my code is now working perfectly. might need to read more on ESQL calling other programming language |
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Aug 17, 2011 4:33 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
|