Home
Analytics
Jar File Location in scriptable datasource tutorial
kbog
Hi,
Under Birt 4.2, I tried following the tutorial for creating a scripted data source. I created a jar file with two simple classes and I tried placing the jar file in the directory.
C:\Program Files\eclipse-jee-juno-win32-x86_64\eclipse\plugins\org.eclipse.birt.report.viewer_4.2.1.v201209071804\birt\WEB-INF\lib
**note the example/tutorial mentioned a classes directory but there was no classes directory under WEB-INF so I opted for lib. Maybe this is associated with my problem?
Say my jar file was gov.xcrt.xxxx.jar, I placed this in the above directory and then attempted an
importPackage(Packages.gov.xcrt.xxxx);
importPackage(Packages.gov.xcrt.****);
xobj = new CourtPersonDaoEngine(1);
xlist = xobj.getCourtUserList();
totalrows = xlist.size();
currentrow = 0;
But the import would not succeed. I would see an error message like this:
ReportDesign (id = 1):
+ There are errors evaluating script "importPackage(Packages.gov.xcrt.****);
xobj = new CourtPersonDaoEngine(1);
xlist = xobj.getCourtUserList();
totalrows = xlist.size();
currentrow = 0;
":
Fail to execute script in function __bm_OPEN(). Source:
As a work around, I went followed a post that I found here and from Eclipse looked at Window->Show view->Other->Report Examples and found an example for Scripted Data Source. In this example the programmer created a src directory and created a package tree under this source directory in a java project directory with a Birt Report
I copied this model in my report and my report worked.
Also I was able to create a jar file of my package and upload this jar to a Tomcat server in /opt/tomcat/webapps/birt/WEB-INF/lib
and also copy my report to the /opt/tomcat/webapss/birt/
And this worked on the server.
I also tried downloading the scriptable datasource tutorial and installing in my dev eclipse environment--same issue.
So my question is--Is the tutorial incorrect? Is
C:\Program Files\eclipse-jee-juno-win32-x86_64\eclipse\plugins\org.eclipse.birt.report.viewer_4.2.1.v201209071804\birt\WEB-INF\lib
the wrong place to put the jar file?
Find more posts tagged with
Comments
kclark
kbog,
If you want to make sure that BIRT see's the JAR you can go to window > preferences > report design > classpath. You can add your JAR there to make sure BIRT see's it.
kbog
Okay Tried that: Window->Preferences->Report Design->Classpath->Add External Jars. Added my jar from:<br />
C:\Program Files\eclipse-jee-juno-win32-x86_64\eclipse\plugins\org.eclipse.birt.report.viewer_4.2.1.v201209071804\birt\WEB-INF\lib<br />
<br />
And tried to run the report. <strong class='bbc'>And Eclipse crashed. </strong><br />
<br />
Next Removed External Jar and then Tried adding external class folder. That did not crash Eclipse. <strong class='bbc'>But the importPackage did not function. </strong> So I still have it working by building under the project a src directory and establishing the package tree under the src directory in the project--and in that project directory, I've a file<br />
.classpath file with the contents:<br />
<em class='bbc'><?xml version="1.0" encoding="UTF-8"?><br />
<classpath><br />
<classpathentry kind="src" path="src"/><br />
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/><br />
<classpathentry kind="lib" path="C:/Program Files/ibm/Informix_JDBC_Driver/lib/ifxjdbc.jar"/><br />
<classpathentry kind="lib" path="C:/Program Files/ibm/Informix_JDBC_Driver/lib/ifxjdbcx.jar"/><br />
<classpathentry kind="lib" path="C:/Program Files/ibm/Informix_JDBC_Driver/lib/ifxlang.jar"/><br />
<classpathentry kind="lib" path="C:/Program Files/ibm/Informix_JDBC_Driver/lib/ifxlsupp.jar"/><br />
<classpathentry kind="lib" path="C:/Program Files/ibm/Informix_JDBC_Driver/lib/ifxsqlj.jar"/><br />
<classpathentry kind="lib" path="C:/Program Files/ibm/Informix_JDBC_Driver/lib/ifxtools.jar"/><br />
<classpathentry kind="output" path="bin"/><br />
</classpath><br />
</em><br />
<br />
This seems to work but it's strange to me that I can not get the scriptable datasource tutorial to work with a jar file as it's described in the book unless I follow that pattern in the examples and create a src directory. Also what might be relevant to mention is in my src/package directory I do not have a jar file. I have the package directory tree and the class java files.
kclark
When you say the importPackage didn't function did it give you any different errors?
kbog
Below is the error message after adding the directory to the report design class path.
Adding the actual jar seems to crash Eclipse altogether.
But if I jar up the src/gov/uscourts/wawd/ to a gov.uscourts.wawd.jar and move that up to a linux/tomcat environment along with the report -- it works. So I think the issue is local to the Eclipse dev arena on windows?
ReportDesign (id = 1):
+ There are errors evaluating script "importPackage(Packages.gov.uscourts.wawd);
xobj = new CourtPersonDaoEngine(1);
xlist = xobj.getCourtUserList();
totalrows = xlist.size();
currentrow = 0;
":
Fail to execute script in function __bm_OPEN(). Source:
A BIRT exception occurred. See next exception for more information.
Error evaluating Javascript expression. Script engine error: ReferenceError: "CourtPersonDaoEngine" is not defined. (/report/data-sets/script-data-set[
@id="
;8"]/method[
@name="
;open"]#2)
Script source: /report/data-sets/script-data-set[
@id="
;8"]/method[
@name="
;open"], line: 0, text:
__bm_OPEN(). (Element ID:1)
Error.ScriptEvaluationError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "importPackage(Packages.gov.uscourts.wawd);
xobj = new CourtPersonDaoEngine(1);
xlist = xobj.getCourtUserList();
totalrows = xlist.size();
currentrow = 0;
":
Fail to execute script in function __bm_OPEN(). Source:
kclark
Can you start eclipse from command line in the Linux environment? It may give some output as to why Eclipse is crashing. What Linux distro are you using?
kbog
I'm using Eclipse Juno 64 on Windows 7. On my windows dev environment is where Eclipse is crashing. My linux environment is my server environment. I only mentioned my linux environment, because I used it as confirmation/rule out that the jar file is okay. After I got the report on windows by <br />
<ul class='bbc'><li>not using a jar and by mimicking the scripted datasource example/pattern of placing the class java files in a src directory under the project</li><li>not putting the jar file in the C:\Program Files\eclipse-jee-juno-win32-x86_64\eclipse\plugins\org.eclipse.birt.report.viewer_4.2.1.v201209071804\birt\WEB-INF\lib</li></ul>
<br />
I wanted to verify that I could deploy to my server. Once I verified that it worked on the server. I tried backtracking my steps and following the tutorial's advice to place the jar in C:\Program Files\eclipse-jee-juno-win32-x86_64\eclipse\plugins\org.eclipse.birt.report.viewer_4.2.1.v201209071804\birt\WEB-INF\lib<br />
<br />
**actually it said the classes directory under WEB-INF<br />
<br />
But I could not get this to work.<br />
I'm good with things as they stand. But thought that I'd post this in the case somebody else runs into it as it ate a bit of my day trying to figure out.