Home
Analytics
NoClassDefFoundError when creating java ReportEngine
mrbrown
Hi!<br />
<br />
I'm creating a report generator in Java and trying to launch it in eclipse with birt 2.5.<br />
This is what I have started :<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
public class test {
public test () {
try
{
System.out.println("Launching report engine");
// Lancement du moteur de génération
EngineConfig config = new EngineConfig();
config.setEngineHome("C:tempbirtReportEngine");
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
IReportEngine engine = factory.createReportEngine(config);
}
catch(BirtException ex)
{
ex.printStackTrace();
}
}
public static void main (String[] args) {
test t = new test();
}
}
</pre>
The problem is that I'm getting the following error and I don't really understand :<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/CoreException
at org.eclipse.birt.report.engine.api.impl.ReportEngine.<init>(ReportEngine.java:109)
at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory$1.run(ReportEngineFactory.java:18)
at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory$1.run(ReportEngineFactory.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.birt.report.engine.api.impl.ReportEngineFactory.createReportEngine(ReportEngineFactory.java:14)
at com.merethis.cbis.reportRunner.test.<init>(test.java:20)
at com.merethis.cbis.reportRunner.test.main(test.java:58)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.CoreException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 7 more
</pre>
<br />
The Platform starts correctly with :<br />
Platform.startup(config);<br />
<br />
But this line is generating the error :<br />
IReportEngine engine = factory.createReportEngine(config);<br />
<br />
<br />
Do you have any idea to help me fix it?<br />
Thanks.
Find more posts tagged with
Comments
Virgil Dodson
Hi mrbrown,<br />
<br />
Have you included all the jar files from the ReportEnginelib folder from the BIRT Runtime download?<br />
<br />
There are also a few Engine examples to compare against at <a class='bbc_url' href='
http://www.birt-exchange.org/devshare/deploying-birt-reports/568-execute-birt-reports-from-java-class/#description'>Execute
BIRT Reports from Java class - Designs & Code - BIRT Exchange</a>
mrbrown
Hi Virgil!
I tried to use the Engine examples you told me and I had the same problems.
So I removed all the libs included in my eclipse project and specified only the libs from ReportEngine/lib and now it's working fine.
Maybe the problem came from the fact that I had some BIRT libraries that were included several times?
Thanks for your help!!
bmac
<blockquote class='ipsBlockquote' data-author="'vdodson'" data-cid="52300" data-time="1250095563" data-date="12 August 2009 - 09:46 AM"><p>
Hi mrbrown,<br />
<br />
<br />
Have you included all the jar files from the ReportEnginelib folder from the BIRT Runtime download?<br />
<br />
<br />
There are also a few Engine examples to compare against at <a class='bbc_url' href='
http://www.birt-exchange.org/devshare/deploying-birt-reports/568-execute-birt-reports-from-java-class/#description'>Execute
BIRT Reports from Java class - Designs & Code - BIRT Exchange</a><br /></p></blockquote>
bmac
Virgil,
Please expand on this a bit. I am trying to run a report from Java and get exactly the same error. Where might org/eclipse/core/runtime/CoreException be located? I cannot find it anywhere. I'm pretty sure this used to work, but after being away from it for a few months, the code no longer works. Something must have changed but I don't know what it was. Any suggestion will be appreciated.
Bmac