Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Missing Package in 2.6.1?
kosta
Hello BIRT community,<br />
<br />
I was trying to test something from the book "Integrating and Extending BIRT".<br />
On the page 225 there is an example how to write scripted data set in java.<br />
<br />
The example can be implemented in the 2.5.2 version. <br />
In the 2.6.1 version the package <strong class='bbc'>org.eclipse.birt.report.engine.api.script.eventadapter.ScriptedDataSetEventAdapter</strong> can not be found, that means the class <strong class='bbc'>MyScriptedDataSet </strong>can not be extended by <strong class='bbc'>ScriptedDataSetEventAdapter</strong>.<br />
<br />
Can someone else check this one.<br />
<br />
Thank you.<br />
Kosta
Find more posts tagged with
Comments
JasonW
It worked for me. Are you sure you configured your build path to point at the 2.6.1 libs?
Jason
kosta
Hello Jason,<br />
<br />
you were right. I forgot to point the 2.6.1 libs to the build path.<br />
<br />
Another question.<br />
<br />
When I choose the scripted data set in java class <strong class='bbc'>MyScriptedDataSet</strong> and want to see the preview I always get the error:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>Error.ScriptClassNotFoundError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: Class integrating.extending.birt.myscripteddataset.MyScriptedDataSet not found.
at org.eclipse.birt.report.engine.executor.EventHandlerManager.getInstance(EventHandlerManager.java:81) ...
</pre>
<br />
But when I choose the ScriptedDataSetEventAdapter I don't get errors.<br />
<br />
My java project is in the same workspace where the report project is.<br />
<br />
Any hits what I am doing wrong?<br />
<br />
Regards,<br />
Kosta
kosta
I also have the problem by "Using a Java objects to access a data source" (page 226).<br />
<br />
The error are: There are errors evaluating script and<br />
Script engine error: ReferenceError: "MyFactoryList" is not defined.<br />
<br />
It seems that the runtime I mean javascript can't find the java classes needed as event handler or data source.<br />
<br />
Here are the classes I have used for testing the data access with java in javascript:<br />
<br />
Node.java<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>package integrating.extending.birt.javadata;
public class Node {
String firstColumn;
String secondColumn;
String thirdColumn;
public String getFirstColumn() {
return firstColumn;
}
public void setFirstColumn(String firstColumn) {
this.firstColumn = firstColumn;
}
public String getSecondColumn() {
return secondColumn;
}
public void setSecondColumn(String secondColumn) {
this.secondColumn = secondColumn;
}
public String getThirdColumn() {
return thirdColumn;
}
public void setThirdColumn(String thirdColumn) {
this.thirdColumn = thirdColumn;
}
}</pre>
<br />
MyListFactory.java<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>package integrating.extending.birt.javadata;
import java.util.ArrayList;
import java.util.Iterator;
public class MyListFactory {
static ArrayList<Node> list = new ArrayList<Node>();
public static ArrayList<Node> getList() {
Node row = new Node();
row.setFirstColumn("Test10");
row.setSecondColumn("Column 1");
row.setThirdColumn("BIRT");
list.add(row);
row = new Node();
row.setFirstColumn("Test16");
row.setSecondColumn("Column 2");
row.setThirdColumn("FOR");
list.add(row);
row = new Node();
row.setFirstColumn("Test22");
row.setSecondColumn("Column 3");
row.setThirdColumn("EVERYBODY");
list.add(row);
return list;
}
public static void setList(ArrayList<Node> newlist) {
list = newlist;
}
public static void main(String args[]) {
ArrayList<Node> al = getList();
for (int i = 0; i < al.size(); i++) {
System.out.println("i: " + i);
System.out.println(((Node)al.get(i)).getFirstColumn());
System.out.println(((Node)al.get(i)).getSecondColumn());
System.out.println(((Node)al.get(i)).getThirdColumn());
}
Iterator<Node> itr = al.iterator();
while(itr.hasNext()) {
Node tempNode = itr.next();
System.out.println("itr: " + tempNode.getFirstColumn());
System.out.println("itr: " + tempNode.getSecondColumn());
System.out.println("itr: " + tempNode.getThirdColumn());
}
}
}
</pre>
<br />
Script from my Scripted Data Set<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage( Packages.integrating.extending.birt.javadata);
var myList = MyListFactory.getList();</pre>
JasonW
Where are you putting the classes? If they are in a java project in the same workspace as the birt project you can add it to birt project classpath in the window->preferences->Report Design->classpath.
Jason
kosta
Thank you for the hint Jason,<br />
<br />
maybe that could be written as note by the sample in the next edition of the book.
<br />
<br />
Would I have the same problem when using the birt-runtime instead of the report designer ?<br />
<br />
beside that, on page 226 there is code sample like:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var iterator = myList.getIterator( );</pre>
when using the word <strong class='bbc'>var</strong> means that this variable is local and can not be seen in the fetch() method. Deleting <strong class='bbc'>var</strong> makes the variable more global, at least it can be used in the fetch() method.<br />
<br />
Regards,<br />
Kosta
JasonW
You wont have the same problem in the runtime as the classpath will be the scriptlib dir and the web-inf/lib /classes dir. Thanks for the note on the book. The var keyword should be dropped from the example.
Jason
kosta
Hello Jason,
I also have problems with the classpath in the runtime. From the log file I can see that my Java Object can not be found.
I have created "classes" folder with the class files in the following folders:
birt-runtime-2_6_1\ReportEngine\lib
birt-runtime-2_6_1\WebViewerExample\scriptlib and
birt-runtime-2_6_1\WebViewerExample\WEB-INF\lib
but the object can not be found. I also created jar and than copied into the folders. And nothing new happens.
After I have added the "java data set"-project to my "report engine"-project over "Required projects on the build path" the java data set Object could be found.
How can I use the Java Data Set as your description?
Regards,
Kosta
JasonW
Are you using the API or the WebViewer in the runtime?
Jason
kosta
Hello Jason,
I am using the API similar like the example on:
http://wiki.eclipse.org/Simple_Execute_(BIRT)_2.1
(BIRT 2.2 on that page, the second example there)
Regards,
Kosta
JasonW
If you are using the api then you need to setup your classpath like:
config.getAppContext().put(EngineConstants.WEBAPP_CLASSPATH_KEY, "C:/myjars/myimage.jar");
Also set the parent classloader for your codel like:
config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, YourClass.class.getClassLoader());
Jason
kosta
Using <br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, YourClass.class.getClassLoader());</pre>
means that the class "YourClass" must be visible in the engine project i.e. imported as external class or jar or project.<br />
<br />
If I import the "YourClass" from somewhere, everything works fine and I don't need to set EngineConstants.<br />
<br />
I thought there is some BIRT specific solution but it seems that that was plain java classpath issue. :blink: <br />
<br />
My Data Set Java Handler used in Scripted JS and the engine start class are now in the same project. I hope I am not making something wrong.<br />
<br />
Kosta
JasonW
Kosta,
By yourclass I mean the class that starts the engine not an imported class.
Jason