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)
BIRT Report using POJOs unning under tomcat
sweetas
<p>Hello,</p>
<p> </p>
<p>This is my first time when I use BIRT engine. I focused with problem using POJOs.</p>
<p> </p>
<p>I have simple POJO: </p>
<pre class="_prettyXprint">
class Parent {
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}</pre>
<p>And simple BIRT report which only prints Parent name (I print name only for 1 Parent, it means - I send a list only with 1 records).</p>
<p> </p>
<p>I successfully generate PDF with Parent name using JUnit tests, while when I try to generate it in Tomcat - BIRT doesn't insert values from POJO.</p>
<p> </p>
<p>Have you ever focused with this problem? </p>
<p> </p>
<p>I guess that the problem is with Data Source pojoClassPath value in report XML, I use relative path. </p>
Find more posts tagged with
Comments
mwilliams
Most likely, this same path just needs to be set up in your runtime from your resources folder (by default the root folder of the viewer is the home folder) OR you should make the path myJar.jar in your report XML and place the jar in the root folder. I could be wrong on this though as I've not tried deploying a POJO. I do have one that I can test, if that doesn't work for you. Let me know.
sweetas
<p>Hi Michael,</p>
<p> </p>
<p>I am still working with this problem. Maybe do you know do we really need pojo classpath's in rptdesign while rendering a document? Or this classpath is used only in rptdesign development phase?</p>
<p> </p>
<p>Because I just tried to remove classpath and left it blank - JUnit test successfully generated a PDF with provided data.</p>
<p> </p>
<p>Many thanks</p>
<p>Laurynas</p>
mwilliams
Let me try it out. What is your BIRT version?
sweetas
<p>Hi Michael,</p>
<p> </p>
<p>The problem is that I use Apache FOP library in the same web project, where I use BIRT.</p>
<p>If we will go to the details - the problem is with Apache Batik library, which is used by Apache FOP 1.0 (uses >=1.7 Batik) & BIRT 4.4.2 (uses 1.6).</p>
<p> </p>
<p>And it is really strange why BIRT Runtime Java library inside overrides Batik groupIds and artifacts.</p>
<p> </p>
<p>Do you have any suggestion how is it possible to use Apache FOP & BIRT 4.4.2 Runtime Java library in the same web project?</p>
<p> </p>
<p>It also depends on, which dependency do you specify on top. </p>
<p> </p>
<p>Using this POM.XML PDF report is generated successfully and all POJO data is binded correctly:</p>
<pre class="_prettyXprint">
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.4.2</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</pre>
<p>Using this POM.XML PDF report is rendered with empty POJO data fields:</p>
<pre class="_prettyXprint">
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.4.2</version>
</dependency>
</pre>
sweetas
<p>Ok, I found a problem.</p>
<p> </p>
<p>The problem was with Java libraries. Apache FOP uses Apache Batik, which has an artifact batik-js. This is a bottle neck, because BIRT Runtime library uses newer version.</p>
<p> </p>
<p>It was very hard to find a problem, because BIRT Runtime uses "org.mozilla.javascript-1.7.2.jar" while FOP uses "batik-js-1.7.jar". Both of them stores the same Java classes. </p>
<p> </p>
<p>So Java ClassLoader took older version (FOP version) of jar, when we specify FOP dependency on TOP.</p>
<p> </p>
<p>It's still a question - why BIRT Runtime developers created different maven artifacts with the same Java classes. </p>
<p> </p>
<p>So my new pom.xml is:</p>
<pre class="_prettyXprint">
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<artifactId>batik-js</artifactId>
<groupId>org.apache.xmlgraphics</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.4.2</version>
</dependency>
</pre>
<p>And everything works now!</p>
mwilliams
Interesting. Glad you got it working! Thanks for updating the thread with your solution!