Discussion:
Access Java Custom classes inside TDI
(too old to reply)
v***@simeiosolutions.com
2018-01-29 13:12:47 UTC
Permalink
Hi, I have a question about accessing custom java classes inside SDI

public class ClassA { // this class is under package my.api.package

public String methodA()
{
String outString=””;
Try{
//some calculation;
}
Catch (exception)
{
// catch exceptions
}
return "outString";
}

I have made a Jar and placed it inside TDI_install/jar Directory, restarted the SDI and CE.
Now I am using a script connector to instantiate my class
Classobj = new my.api.package.ClassA();
Classobj.methodA();
But it gives me the error “java.lang.Exception: my not found”
Can anyone help me where I went wrong?
I also tried to use java class function component, and I was able to access the class but the drop down for selecting the method is empty, hence I cannot select the method.
Any Suggestions?
Thanks in Advance!
--
The information in this message may contain confidential information and
may be legally privileged. It is intended solely for the individual(s)
named. Access to this email by anyone else is unauthorized. Please notify
the sender immediately if you have received this email by mistake and
delete this email from your system. If you are not the intended recipient,
any disclosure, copying, distribution or any action taken or omitted to be
taken in reliance on it, is prohibited and may be unlawful. Email
transmission cannot be guaranteed to be secure or error-free, as
information could be intercepted, corrupted, lost, destroyed, arrive late
or incomplete, or contain viruses. When addressed to our clients any
decisions or recommendations contained in this email are subject to the
terms and conditions expressed our contract and related statement of work
letter(s)
Eddie Hartman
2018-01-29 21:42:54 UTC
Permalink
Post by v***@simeiosolutions.com
Hi, I have a question about accessing custom java classes inside SDI
public class ClassA { // this class is under package my.api.package
public String methodA()
{
String outString=””;
Try{
//some calculation;
}
Catch (exception)
{
// catch exceptions
}
return "outString";
}
I have made a Jar and placed it inside TDI_install/jar Directory, restarted the SDI and CE.
Now I am using a script connector to instantiate my class
Classobj = new my.api.package.ClassA();
Classobj.methodA();
But it gives me the error “java.lang.Exception: my not found”
Can anyone help me where I went wrong?
I also tried to use java class function component, and I was able to access the class but the drop down for selecting the method is empty, hence I cannot select the method.
Any Suggestions?
Thanks in Advance!
--
The information in this message may contain confidential information and
may be legally privileged. It is intended solely for the individual(s)
named. Access to this email by anyone else is unauthorized. Please notify
the sender immediately if you have received this email by mistake and
delete this email from your system. If you are not the intended recipient,
any disclosure, copying, distribution or any action taken or omitted to be
taken in reliance on it, is prohibited and may be unlawful. Email
transmission cannot be guaranteed to be secure or error-free, as
information could be intercepted, corrupted, lost, destroyed, arrive late
or incomplete, or contain viruses. When addressed to our clients any
decisions or recommendations contained in this email are subject to the
terms and conditions expressed our contract and related statement of work
letter(s)
Placing your jar file under <TDI_INSTALLDIR>/jars should work. I always use a CustomJars folder in my Solution Directory and then have this line in solution.properties:

com.ibm.di.userjars=CustomJars

Under CustomJars I have sub-folders for the various libraries I am using. The TDI loader recursively scans for jars/zip files.

You are referencing the class correction: <package>.<class name> The 'my not found' is just a symptom of TDI not finding the jar, or that the jar is incorrect/corrupt. Btw. did you have a constructor for your class? I did not see one in the above snippet (of course, I am no Java expert, so bear with dumb observations :)
v***@simeiosolutions.com
2018-01-30 09:38:51 UTC
Permalink
Post by Eddie Hartman
Post by v***@simeiosolutions.com
Hi, I have a question about accessing custom java classes inside SDI
public class ClassA { // this class is under package my.api.package
public String methodA()
{
String outString=””;
Try{
//some calculation;
}
Catch (exception)
{
// catch exceptions
}
return "outString";
}
I have made a Jar and placed it inside TDI_install/jar Directory, restarted the SDI and CE.
Now I am using a script connector to instantiate my class
Classobj = new my.api.package.ClassA();
Classobj.methodA();
But it gives me the error “java.lang.Exception: my not found”
Can anyone help me where I went wrong?
I also tried to use java class function component, and I was able to access the class but the drop down for selecting the method is empty, hence I cannot select the method.
Any Suggestions?
Thanks in Advance!
--
The information in this message may contain confidential information and
may be legally privileged. It is intended solely for the individual(s)
named. Access to this email by anyone else is unauthorized. Please notify
the sender immediately if you have received this email by mistake and
delete this email from your system. If you are not the intended recipient,
any disclosure, copying, distribution or any action taken or omitted to be
taken in reliance on it, is prohibited and may be unlawful. Email
transmission cannot be guaranteed to be secure or error-free, as
information could be intercepted, corrupted, lost, destroyed, arrive late
or incomplete, or contain viruses. When addressed to our clients any
decisions or recommendations contained in this email are subject to the
terms and conditions expressed our contract and related statement of work
letter(s)
com.ibm.di.userjars=CustomJars
Under CustomJars I have sub-folders for the various libraries I am using. The TDI loader recursively scans for jars/zip files.
You are referencing the class correction: <package>.<class name> The 'my not found' is just a symptom of TDI not finding the jar, or that the jar is incorrect/corrupt. Btw. did you have a constructor for your class? I did not see one in the above snippet (of course, I am no Java expert, so bear with dumb observations :)
Thanks Eddie Hartman, it worked after placing the jars in a customjar sub directory inside <TDI_installDir>/jar directory :)
--
The information in this message may contain confidential information and
may be legally privileged. It is intended solely for the individual(s)
named. Access to this email by anyone else is unauthorized. Please notify
the sender immediately if you have received this email by mistake and
delete this email from your system. If you are not the intended recipient,
any disclosure, copying, distribution or any action taken or omitted to be
taken in reliance on it, is prohibited and may be unlawful. Email
transmission cannot be guaranteed to be secure or error-free, as
information could be intercepted, corrupted, lost, destroyed, arrive late
or incomplete, or contain viruses. When addressed to our clients any
decisions or recommendations contained in this email are subject to the
terms and conditions expressed our contract and related statement of work
letter(s)
Eddie Hartman
2018-01-30 17:15:54 UTC
Permalink
Great! I forgot to mention that when add/remove jars or import certs the you have to reboot the java vm - i.e. server and/or CE
Loading...