Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » TCR BIRT Javascript failed to call java class(My java script in TCR BIRT runtime env could not find my java class. Where should I put my jar file in order to make birt happy?)
TCR BIRT Javascript failed to call java class [message #666963] Mon, 25 April 2011 06:33 Go to next message
hongping  is currently offline hongping Friend
Messages: 4
Registered: April 2011
Junior Member
Hi Experts,
Could anybody please help me out? Please tell me where I should put my jar files?(I tried location: /opt/IBM/tivoli/tip/products/tcr/lib/birt-runtime-2_2_1/Repo rtEngine/lib)
I am new to TCR BIRT report, and using TCR with birt 2.2.1. I have a headache issue about javascript call my java class. I need to write a group of java classes to access RSA as datasource, and use java script of dataset to call my java classes. All of my java classes could not be found by BIRT run-time. So, I need to figure out what's the reason by trying a simplest java class called by a javascritp of fetch function which belongs to a dataset.
I tried very smile java class. It has very simple function as below:
=============== My simple java class ==============
package com.hpshi;

public class HPTest2 {

public HPTest2(){
}

public String getValueOfString( String field ){
String ret = "HPTest2 0420:" + field;
return ret;
}

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(new HPTest2().getValueOfString("Hello2!"));
}

}

==========java class caller: Java script ==========
// Data Set Fetch function
// In dataset fetch javascript. I have script below:
importPackage( Packages.com.hpshi );
instance = new HPTest2();

row["SEX"] = "Male";
row["NAME"] = "Hongping";
row["NAME"] = instance.getValueOfString("NAME");

row["AGE"] = 29;
logToDebugWindow("age="+29);

count++;
if ( count < 3)
return true;
else
return false;
================================

It works very well in BIRT-ALL-IN-ONE designer. However, when I put it into our runtime env. It doesn' work at all. It complains my java class "HpTest2" is not defined.

Here is my envionment:
Tivoli Common Report:
birt-runtime: 2.2.1
OS: is AIX

Here is what I did for deploying.
.I put the java class in a jar file. And I put the jar file into ReportEngine/lib (According FAQ information provided by http://wiki.eclipse.org/BIRT/FAQ/Scripting)
The jar file is ok. Because, it works in the ALL_IN_ONE design env, when I removed HPTestd2.class file as long as I added the jar file into build path as external jar.
.Restart tcr server. by stopTCRserver.sh and startTCRserver.sh

However, I found a workaround way which is ugly to make it working. Since I found the class path by using java.lang.System.getProperty( "java.class.path" ); I replaced one of jar files in the classpath , which looks like not used, with my jar file. My simple java class was called by the fetch java script successfully by this way. However, the problem is that this is only simple java class, and my real java classes have many dependant classes inside jar files. So this workaround doens't help me out of the difficulty. I have been struck in this issue 3 weeks, please help me out!!!

Many thanks,

Hongping Shi

[Updated on: Mon, 25 April 2011 14:38]

Report message to a moderator

Re: TCR BIRT Javascript failed to call java class [message #667081 is a reply to message #666963] Mon, 25 April 2011 15:15 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I assume you are using the Report Engine API?

If so did you use:
config = new EngineConfig();
HashMap hm = config.getAppContext();
hm.put( EngineConstants.APPCONTEXT_CLASSLOADER_KEY,
MyClass.class.getClassLoader());
config.setAppContext(hm);

You can specifically set the property for the classpath like:

config.setProperty( EngineConstants.WEBAPP_CLASSPATH_KEY,
classpathstring);

Jason


On 4/25/2011 2:33 AM, hongping wrote:
> Hi Experts,
> Could anybody please tell me where I should put my jar files?(I tried
> location: /opt/IBM/tivoli/tip/products/tcr/lib/birt-runtime-2_2_1/Repo
> rtEngine/lib)
> I am new developer for TCR BIRT report. I am using TCR with birt 2.2.1.
> I have a headache issue about javascript call my java class. I need to
> write a group of java classes to access RSA as datasource, and use java
> script of dataset to call my java classes. All of my java classes could
> not found by BIRT run-time. So, I need to figure out what's the reason
> by trying a simplest java class called by a javascritp of fetch function
> which belongs to a dataset.
> I tried very smile java class. It has very simple function as below:
> =============== My simple java class ==============
> package com.hpshi;
>
> public class HPTest2 {
>
> public HPTest2(){
> }
>
> public String getValueOfString( String field ){
> String ret = "HPTest2 0420:" + field;
> return ret;
> }
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> // TODO Auto-generated method stub
> System.out.println(new HPTest2().getValueOfString("Hello2!"));
> }
>
> }
>
> ==========java class caller: Java script ==========
> // Data Set Fetch function
> // In dataset fetch javascript. I have script below:
> importPackage( Packages.com.hpshi );
> instance = new HPTest2();
>
> row["SEX"] = "Male";
> row["NAME"] = "Hongping";
> row["NAME"] = instance.getValueOfString("NAME");
>
> row["AGE"] = 29;
> logToDebugWindow("age="+29);
>
> count++;
> if ( count < 3) return true;
> else
> return false;
> ================================
>
> It works very well in BIRT-ALL-IN-ONE designer. However, when I put it
> into our runtime env. It doesn' work at all. It complains my java class
> "HpTest2" is not defined.
>
> Here is my envionment:
> Tivoli Common Report:
> birt-runtime: 2.2.1
> OS: is AIX
>
> Here is what I did for deploying.
> I put the java class in a jar file. And I put the jar file into
> ReportEngine/lib (According FAQ information provided by
> http://wiki.eclipse.org/BIRT/FAQ/Scripting)
> The jar file is ok. Because, it works in the ALL_IN_ONE design env, when
> I removed HPTestd2.class file as long as I added the jar file into build
> path as external jar.
> Restart tcr server. by stopTCRserver.sh and startTCRserver.sh
>
> However, I found a workaround way which is ugly to make it working.
> Since I found the class path by using java.lang.System.getProperty(
> "java.class.path" ); I replaced one of jar files in the classpath ,
> which looks like not used, with my jar file. My simple java class was
> called by the fetch java script successfully by this way. However, the
> problem is that this is only simple java class, and my real java classes
> have many dependant classes inside jar files. So this workaround doens't
> help me out of the difficulty. I have been struck in this issue 3 weeks,
> please help me out!!!
>
> Many thanks,
>
> Hongping Shi
Re: TCR BIRT Javascript failed to call java class [message #667100 is a reply to message #667081] Tue, 26 April 2011 17:38 Go to previous messageGo to next message
hongping  is currently offline hongping Friend
Messages: 4
Registered: April 2011
Junior Member
Hi Jason,
Thank you so much for your help. It is great I found the forum backs to life again after one day maintance.

I guess I am not using Report Engine API. Since my report is imported by TCR gui through url:
https://cmobb2:16316/ibm/console/secure/securelogon.do
.Step 1:From the GUI. Import report by path below: (the imported file is a zip file of my report project directory by using winzip)
Reporing -> Common Reporting -> Report Sets ->Import Report package(in Right side panel and mouse right click).
.Step 2: Copy my jar file: "hpshi.jar" into " /opt/IBM/tivoli/tip/products/tcr/lib/birt-runtime-2_2_1/Repo rtEngine/lib "
.Step 3: Changed /opt/IBM/tivoli/tip/bin/startServer.sh to add my jar file into classpath parameter.(Please see below)
.Step 4: Stop tcr server:
Go to unix shell
cd /opt/IBM/tivoli/tip/products/tcr/bin
run stopTCRserver.sh
.Step 5: Start tcr server
cd /opt/IBM/tivoli/tip/products/tcr/bin
run: startTCRserver.sh
.Step 6:Run report by path below:
Reporing -> Common Reporting -> Report Sets -> My Report Test -> RSA_Test(in Report panel) -> view as HTML(mouse right click).

Here are some files about start tcr.
File 1: /opt/IBM/tivoli/tip/products/tcr/bin/startTCRserver.sh
...
/opt/IBM/tivoli/tip/profiles/TIPProfile/bin/startServer.sh" server1 -nowait
...

File 2: /opt/IBM/tivoli/tip/profiles/TIPProfile/bin/startServer.sh
#!/bin/sh
WAS_USER_SCRIPT=/opt/IBM/tivoli/tip/profiles/TIPProfile/bin/ setupCmdLine.sh
export WAS_USER_SCRIPT
/opt/IBM/tivoli/tip/bin/startServer.sh "$@"


File 3: /opt/IBM/tivoli/tip/bin/startServer.sh
...
"$JAVA_HOME"/bin/java \
"$OSGI_INSTALL" "$OSGI_CFG" \
$X_ARGS \
$WAS_DEBUG \
$CONSOLE_ENCODING \
$D_ARGS \
-classpath "$XWAS_CLASSPATH" :/opt/IBM/tivoli/tip/products/tcr/lib/birt-runtime-2_2_1/Rep ortEngine/lib/hpshi.jar \
$USER_INSTALL_PROP \
$JVM_EXTRA_CMD_ARGS \
com.ibm.ws.bootstrap.WSLauncher \
$SHELL "$CONFIG_ROOT" "$WAS_CELL" "$WAS_NODE" "$@" $WORKSPACE_ROOT_PROP
...


I changed parameter "-classpath"(in startServer.sh see above) to add my jar file " /opt/IBM/tivoli/tip/products/tcr/lib/birt-runtime-2_2_1/Repo rtEngine/lib/hpshi.jar " to classpath.

Here is the tcr "java" process information after I added my jar file into classpath parameter and restart tcr server.(AIX os):
/opt/IBM/tivoli/tip/java/bin/java -Declipse.security -Dosgi.install.area=/opt/IBM/tivoli/tip -Dosgi.configuration.area=/opt/IBM/tivoli/tip/profiles/TIPPr ofile/configuration -Djava.awt.headless=true -Dosgi.framework.extensions=com.ibm.cds -Xshareclasses:name=webspherev61_%g,groupAccess,nonFatal -Xscmx50M -Xbootclasspath/p:/opt/IBM/tivoli/tip/java/jre/lib/ext/ibmor b.jar:/opt/IBM/tivoli/tip/java/jre/lib/ext/ibmext.jar -classpath /opt/IBM/tivoli/tip/profiles/TIPProfile/properties:/opt/IBM/ tivoli/tip/properties:/opt/IBM/tivoli/tip/lib/startup.jar:/o pt/IBM/tivoli/tip/lib/bootstrap.jar:/opt/IBM/tivoli/tip/lib/ j2ee.jar:/opt/IBM/tivoli/tip/lib/lmproxy.jar:/opt/IBM/tivoli /tip/lib/urlprotocols.jar:/opt/IBM/tivoli/tip/deploytool/itp /batchboot.jar:/opt/IBM/tivoli/tip/deploytool/itp/batch2.jar :/opt/IBM/tivoli/tip/java/lib/tools.jar -Dibm.websphere.internalClassAccessMode=allow -Xms512m -Xmx1024m -Dws.ext.dirs=/opt/IBM/tivoli/tip/java/lib:/opt/IBM/tivoli/t ip/profiles/TIPProfile/classes:/opt/IBM/tivoli/tip/classes:/ opt/IBM/tivoli/tip/lib:/opt/IBM/tivoli/tip/installedChannels :/opt/IBM/tivoli/tip/lib/ext:/opt/IBM/tivoli/tip/web/help:/o pt/IBM/tivoli/tip/deploytool/itp/plugins/com.ibm.etools.ejbd eploy/runtime -Dderby.system.home=/opt/IBM/tivoli/tip/derby -Dcom.ibm.itp.location=/opt/IBM/tivoli/tip/bin -Djava.util.logging.configureByServer=true -Duser.install.root=/opt/IBM/tivoli/tip/profiles/TIPProfile -Djavax.management.builder.initial=com.ibm.ws.management.Pla tformMBeanServerBuilder -Dwas.install.root=/opt/IBM/tivoli/tip -Dpython.cachedir=/opt/IBM/tivoli/tip/profiles/TIPProfile/te mp/cachedir -Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogManage r -Dserver.root=/opt/IBM/tivoli/tip/profiles/TIPProfile -Dcom.ibm.tivoli.reporting.installdir=/opt/IBM/tivoli/tip/pr oducts/tcr -Djava.security.auth.login.config=/opt/IBM/tivoli/tip/profil es/TIPProfile/properties/wsjaas.conf -Djava.security.policy=/opt/IBM/tivoli/tip/profiles/TIPProfi le/properties/server.policy com.ibm.wsspi.bootstrap.WSPreLauncher -nosplash -application com.ibm.ws.bootstrap.WSLauncher com.ibm.ws.runtime.WsServer /opt/IBM/tivoli/tip/profiles/TIPProfile/config TIPCell TIPNode server1

However, after all I changed classpath and restart tcr server("startTCRserver.sh"), I found the unix processs of the "java" doesn't contain my jar file in the classpath parameter.(Please look the process infomation above the "java" process. I am sure the process is the tcr related since it disappears if I stop TCR and it appears after I start tcr). It looks like the server filtered my jar file out. Or, just because I used a wrong approach to set the classpath(the classpath value always contains space in it after I copied into the post message. My original one has no space in it.) or the wrong way to restart the server?

What is the java process? Is it a was server? I also saw a file /opt/IBM/tivoli/tip/bin/wsadmin.sh. It looks like our was server. Maybe, I should use was server to set my classpath. How can I acces the was server gui-web page? How can I or should I set the classpath through it?

Thanks again!

Hongping

[Updated on: Tue, 26 April 2011 17:48]

Report message to a moderator

Re: TCR BIRT Javascript failed to call java class [message #667119 is a reply to message #667100] Tue, 26 April 2011 20:01 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I am not sure how Tivoli is doing the integration. Have you contacted
their support?

Jason

On 4/26/2011 1:38 PM, hongping wrote:
> Hi Jason,
> Thank you so much for your help. It is great I found the forum backs to
> life again after one day maintance.
>
> I guess I am not using Report Engine API. Since my report is imported by
> TCR gui through url:
> https://cmobb2:16316/ibm/console/secure/securelogon.do
> Step 1:From the GUI. Import report by path below: (the imported file is
> a zip file of my report project directory by using winzip)
> Reporing -> Common Reporting -> Report Sets ->Import Report package(in
> Right side panel and mouse right click).
> Step 2: Copy my jar file: "hpshi.jar" into "
> /opt/IBM/tivoli/tip/products/tcr/lib/birt-runtime-2_2_1/Repo rtEngine/lib "
> Step 3: Changed /opt/IBM/tivoli/tip/bin/startServer.sh to add my jar
> file into classpath parameter.(Please see below)
> Step 4: Stop tcr server:
> Go to unix shell
> cd /opt/IBM/tivoli/tip/products/tcr/bin
> run stopTCRserver.sh
> Step 5: Start tcr server
> cd /opt/IBM/tivoli/tip/products/tcr/bin
> run: startTCRserver.sh
> Step 6:Run report by path below:
> Reporing -> Common Reporting -> Report Sets -> My Report Test ->
> RSA_Test(in Report panel) -> view as HTML(mouse right click).
>
> Here are some files about start tcr.
> File 1: /opt/IBM/tivoli/tip/products/tcr/bin/startTCRserver.sh
> ...
> /opt/IBM/tivoli/tip/profiles/TIPProfile/bin/startServer.sh" server1 -nowait
> ...
>
> File 2: /opt/IBM/tivoli/tip/profiles/TIPProfile/bin/startServer.sh
> #!/bin/sh
> WAS_USER_SCRIPT=/opt/IBM/tivoli/tip/profiles/TIPProfile/bin/
> setupCmdLine.sh
> export WAS_USER_SCRIPT
> /opt/IBM/tivoli/tip/bin/startServer.sh "$@"
>
>
> File 3: /opt/IBM/tivoli/tip/bin/startServer.sh
> ...
> "$JAVA_HOME"/bin/java \
> "$OSGI_INSTALL" "$OSGI_CFG" \
> $X_ARGS \
> $WAS_DEBUG \
> $CONSOLE_ENCODING \
> $D_ARGS \
> -classpath "$XWAS_CLASSPATH" \
> $USER_INSTALL_PROP \
> $JVM_EXTRA_CMD_ARGS \
> com.ibm.ws.bootstrap.WSLauncher \
> $SHELL "$CONFIG_ROOT" "$WAS_CELL" "$WAS_NODE" "$@" $WORKSPACE_ROOT_PROP
> ...
>
>
> I changed parameter "-classpath"(in startServer.sh see above) to add my
> jar file " /opt/IBM/tivoli/tip/products/tcr/lib/birt-runtime-2_2_1/Repo
> rtEngine/lib/hpshi.jar " to classpath.
>
> Here is the tcr "java" process information after I added my jar file
> into classpath parameter and restart tcr server.(AIX os):
> /opt/IBM/tivoli/tip/java/bin/java -Declipse.security
> -Dosgi.install.area=/opt/IBM/tivoli/tip
> -Dosgi.configuration.area=/opt/IBM/tivoli/tip/profiles/TIPPr
> ofile/configuration -Djava.awt.headless=true
> -Dosgi.framework.extensions=com.ibm.cds
> -Xshareclasses:name=webspherev61_%g,groupAccess,nonFatal -Xscmx50M
> -Xbootclasspath/p:/opt/IBM/tivoli/tip/java/jre/lib/ext/ibmor
> b.jar:/opt/IBM/tivoli/tip/java/jre/lib/ext/ibmext.jar -classpath
> /opt/IBM/tivoli/tip/profiles/TIPProfile/properties:/opt/IBM/
> tivoli/tip/properties:/opt/IBM/tivoli/tip/lib/startup.jar:/o
> pt/IBM/tivoli/tip/lib/bootstrap.jar:/opt/IBM/tivoli/tip/lib/
> j2ee.jar:/opt/IBM/tivoli/tip/lib/lmproxy.jar:/opt/IBM/tivoli
> /tip/lib/urlprotocols.jar:/opt/IBM/tivoli/tip/deploytool/itp
> /batchboot.jar:/opt/IBM/tivoli/tip/deploytool/itp/batch2.jar
> :/opt/IBM/tivoli/tip/java/lib/tools.jar
> -Dibm.websphere.internalClassAccessMode=allow -Xms512m -Xmx1024m
> -Dws.ext.dirs=/opt/IBM/tivoli/tip/java/lib:/opt/IBM/tivoli/t
> ip/profiles/TIPProfile/classes:/opt/IBM/tivoli/tip/classes:/
> opt/IBM/tivoli/tip/lib:/opt/IBM/tivoli/tip/installedChannels
> :/opt/IBM/tivoli/tip/lib/ext:/opt/IBM/tivoli/tip/web/help:/o
> pt/IBM/tivoli/tip/deploytool/itp/plugins/com.ibm.etools.ejbd
> eploy/runtime -Dderby.system.home=/opt/IBM/tivoli/tip/derby
> -Dcom.ibm.itp.location=/opt/IBM/tivoli/tip/bin
> -Djava.util.logging.configureByServer=true
> -Duser.install.root=/opt/IBM/tivoli/tip/profiles/TIPProfile
> -Djavax.management.builder.initial=com.ibm.ws.management.Pla
> tformMBeanServerBuilder -Dwas.install.root=/opt/IBM/tivoli/tip
> -Dpython.cachedir=/opt/IBM/tivoli/tip/profiles/TIPProfile/te mp/cachedir
> -Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogManage r
> -Dserver.root=/opt/IBM/tivoli/tip/profiles/TIPProfile
> -Dcom.ibm.tivoli.reporting.installdir=/opt/IBM/tivoli/tip/pr oducts/tcr
> -Djava.security.auth.login.config=/opt/IBM/tivoli/tip/profil
> es/TIPProfile/properties/wsjaas.conf
> -Djava.security.policy=/opt/IBM/tivoli/tip/profiles/TIPProfi
> le/properties/server.policy com.ibm.wsspi.bootstrap.WSPreLauncher
> -nosplash -application com.ibm.ws.bootstrap.WSLauncher
> com.ibm.ws.runtime.WsServer
> /opt/IBM/tivoli/tip/profiles/TIPProfile/config TIPCell TIPNode server1
>
> However, after all I changed classpath and restart tcr
> server("startTCRserver.sh"), I found the unix processs of the "java"
> doesn't contain my jar file in the classpath parameter.(Please look the
> process infomation above the "java" process. I am sure the process is
> the tcr related since it disappears if I stop TCR and it appears after I
> start tcr). It looks like the server filtered my jar file out. Or, just
> because I used a wrong approach to set the classpath or the wrong way to
> restart the server?
> What is the java process? Is it a was server? I also saw a file
> /opt/IBM/tivoli/tip/bin/wsadmin.sh. It looks like our was server. Maybe,
> I should use was server to set my classpath. How can I acces the was
> server gui-web page? How can I or should I set the classpath through it?
>
> Thanks again!
>
> Hongping
>
Re: TCR BIRT Javascript failed to call java class [message #667122 is a reply to message #667119] Tue, 26 April 2011 21:07 Go to previous messageGo to next message
hongping  is currently offline hongping Friend
Messages: 4
Registered: April 2011
Junior Member
Hi Jason,
You are right. We have to get some supports from IBM Tivoli team.

I appreciate your help!

Hongping
Re: TCR BIRT Javascript failed to call java class [message #667224 is a reply to message #667122] Wed, 27 April 2011 14:15 Go to previous message
hongping  is currently offline hongping Friend
Messages: 4
Registered: April 2011
Junior Member
I got help from dan krissell in another IBM forum.
He told I should put my jars in ../tcr/lib. It works.

Thank you guys so much.

Hongping
Previous Topic: Group and summarize results of a dataset
Next Topic:Convert report from 2.1 to 2.6
Goto Forum:
  


Current Time: Fri Apr 26 09:04:24 GMT 2024

Powered by FUDForum. Page generated in 0.03218 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top