Author |
Message
|
abcnil |
Posted: Fri Jun 06, 2014 8:09 am Post subject: Error trying to locate a Java Class /method - MB8.0.0.0.3 |
|
|
Apprentice
Joined: 29 Mar 2012 Posts: 36
|
MB8 with Fix pack3.
I am trying to use java routine from my Esql
Esql:
Calling Function:
Code: |
SET outTimeChar = CAST(inputMsgRef.q1:ExecTimestamp AS CHARACTER);
CALL setDateFormat(outTimeChar) INTO returnValue; |
Declaring Function :
Code: |
CREATE FUNCTION setDateFormat( IN inDate CHARACTER) RETURNS CHARACTER
LANGUAGE JAVA
EXTERNAL NAME "com.test.GetDate.changeTimeZone"; |
Java class:
Code: |
package com.test;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
class GetDate {
public static String changeTimeZone(String inDate) throws Exception {
String outDate;
DatatypeFactory factory = DatatypeFactory.newInstance();
XMLGregorianCalendar xmlCal = factory.newXMLGregorianCalendar(inDate);
Calendar cal = xmlCal.toGregorianCalendar();
DateFormat korFormat = new SimpleDateFormat(
"yyyy-MM-dd-HH.mm.ss.SSSSSS");
// TimeZone cetTime = TimeZone.getTimeZone("CET");
korFormat.setTimeZone(TimeZone.getTimeZone("EET"));
outDate = korFormat.format(cal.getTime());
;
return outDate;
}
} |
Here is the exception:
Quote: |
ExceptionList
RecoverableException
File:CHARACTER:F:\build\slot1\S800_P\src\DataFlowEngine\ImbDataFlowNode.cpp
Line:INTEGER:1154
Function:CHARACTER:ImbDataFlowNode::createExceptionList
Type:CHARACTER:ComIbmMQInputNode
Name:CHARACTER:cam_CardHandling_Response_Flow#FCMComposite_1_1
Label:CHARACTER:cam_CardHandling_Response_Flow.MQ Input
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2230
Text:CHARACTER:Node throwing exception
RecoverableException
File:CHARACTER:F:\build\slot1\S800_P\src\DataFlowEngine\ImbComputeNode.cpp
Line:INTEGER:497
Function:CHARACTER:ImbComputeNode::evaluate
Type:CHARACTER:ComIbmComputeNode
Name:CHARACTER:cam_CardHandling_Response_Flow#FCMComposite_1_3.cam_CardHandling_NewCardOrder_Response_SF#FCMComposite_1_3
Label:CHARACTER:cam_CardHandling_Response_Flow.Compute
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2230
Text:CHARACTER:Caught exception and rethrowing
RecoverableException
File:CHARACTER:F:\build\slot1\S800_P\src\DataFlowEngine\ImbRdl\ImbRdlRoutine.cpp
Line:INTEGER:2111
Function:CHARACTER:SqlRoutine::resolveExternalJavaParameters
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:3202
Text:CHARACTER:An error occured whilst trying to locate a Java Class / method
Insert
Type:INTEGER:5
Text:CHARACTER:.NewCardOrder_Response_SubFlow_Compute.setDateFormat
Insert
Type:INTEGER:5
Text:CHARACTER:1.2
Insert
Type:INTEGER:5
Text:CHARACTER:com.test.GetDate.changeTimeZone
Insert
Type:INTEGER:5
Text:CHARACTER:setDateFormat
RecoverableException
File:CHARACTER:F:\build\slot1\S800_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:com.test.GetDate.changeTimeZone |
I have Application refering Lib
and Lib contains Esql and JavaProject with mentioned class.
Checked other post for similar issue/ checked documentation. All look fine to me..Not able to trace whats wrong...  |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jun 06, 2014 9:16 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Quote: |
Text:CHARACTER:The Java method has a throws clause |
|
|
Back to top |
|
 |
Vitor |
Posted: Fri Jun 06, 2014 9:16 am Post subject: Re: Error trying to locate a Java Class /method - MB8.0.0.0. |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Understand that me taking about Java is like a blind guy giving a lecture on Picasso and the abstract movement.
Having said that, this doesn't look good:
abcnil wrote: |
Text:CHARACTER:The Java method has a throws clause |
Which lines up with the documentation on the CREATE FUNCTION statement which says:
Quote: |
In addition, the Java method is not allowed to have exception throws clause in its signature. |
Which my seeing eye dog claims you have.
Also, why are you breaking out of ESQL to do this? Are you trying to fudge this problem?  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jun 06, 2014 1:21 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Excellent thought of fixing the date display problem with Java.
However you have a few problems here... DateFormat and SimpleDateFormat are not thread safe... nor is Date... you should use ThreadLocal for those... or synchronize your method...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
abcnil |
Posted: Sun Jun 08, 2014 8:59 pm Post subject: |
|
|
Apprentice
Joined: 29 Mar 2012 Posts: 36
|
Thanks All,
This solved the problem
Quote: |
In addition, the Java method is not allowed to have exception throws clause in its signature. |
Thanks Vitor for pointing this out
And yes, i am trying around to tackle the issue of ESQL Timestamp issue by using java function. because its problem with current MB version we are using. Management here is not ready to wait for next fix.
so need to have some workaround. Obviosly I am NOT happy with this approach  |
|
Back to top |
|
 |
abcnil |
Posted: Sun Jun 08, 2014 9:01 pm Post subject: |
|
|
Apprentice
Joined: 29 Mar 2012 Posts: 36
|
fjb_saper wrote: |
Excellent thought of fixing the date display problem with Java.
However you have a few problems here... DateFormat and SimpleDateFormat are not thread safe... nor is Date... you should use ThreadLocal for those... or synchronize your method...
Have fun  |
Thanks fjb_saper, I will improve it in my code  |
|
Back to top |
|
 |
|