Integrating reports, using java classes, in birt deployed on a tomcat server

frenchGuy
edited February 11, 2022 in Analytics #1
Hi,<br />
I've made a report using java classes (to create scripted dataset) and it's working well when I'm generating the report in eclipse environnement.<br />
But the problem is that I don't reallly know how to export the report via the birt viewer installed on my apache-tomcat server.<br />
This is how my files are structured :<br />
My local java project :<br />
Birt-Report/src/CDBConnection.java (java class for MySQL DB connection) <br />
Birt-Report/src/CVolumeUsage.java (java class for data retrieving)<br />
Birt-Report/volume-usage.rptdesign (main file instanciating java classes defined in Birt-Report/src/ folder)<br />
Birt-Report/bin/CDBConnection.class<br />
Birt-Report/bin/CVolumeUsage.class<br />
Birt-Report/bin/merethis.jar (contains CDBConnection and CVolumeUsage classes)<br />
I instanciate an objet of CDBConnection in the event Handler ReportDesign.initialize() :<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
_DBInst = new Packages.CDBConnection("jdbc:mysql://192.168.1.204/", "centreon240", "centstorage240","com.mysql.jdbc.Driver", "root", "");"centreon", "centstorage","com.mysql.jdbc.Driver", "root", "");
_VluInst = new Packages.CVolumeUsage(_DBInst);
_VluInst.setVolumeUsage(params["servicegroup"]);
</pre>
<br />
I moved the jar and rptdesign files on Tomcat server :<br />
Apache-tomcat/webapps/birt/WEB-INF/lib/merethis.jar <br />
Apache-tomcat/webapps/birt/report/volume-usage.rptdesign<br />
<br />
But I got the following message :<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>The following items have errors:

ReportDesign (id = 1):
- There are errors evaluating script "_DBInst = new Packages.CDBConnection("jdbc:mysql://192.168.1.204/", "centreon240", "centstorage240","com.mysql.jdbc.Driver", "root", "");
_VluInst = new Packages.CVolumeUsage(_DBInst);
_VluInst.setVolumeUsage(params["servicegroup"]);":{1}.

Error.ScriptEvaluationError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "_DBInst = new Packages.CDBConnection("jdbc:mysql://192.168.1.204/", "centreon240", "centstorage240","com.mysql.jdbc.Driver", "root", "");
//_DBInst = new Packages.CDBConnection("jdbc:mysql://127.0.0.1/", "centreon", "centstorage","com.mysql.jdbc.Driver", "root", "");
_VluInst = new Packages.CVolumeUsage(_DBInst);
_VluInst.setVolumeUsage(params["servicegroup"]);":{1}.
at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:582)
at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:555)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleJSInternal(ScriptExecutor.java:61)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleJS(ScriptExecutor.java:45)
at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleInitialize(ReportScriptExecutor.java:30)
at org.eclipse.birt.report.engine.api.impl.EngineTask.loadDesign(EngineTask.java:1187)
at org.eclipse.birt.report.engine.api.impl.RenderTask.render(RenderTask.java:258)
at org.eclipse.birt.report.service.ReportEngineService.renderReport(Unknown Source)
at org.eclipse.birt.report.service.ReportEngineService.renderReport(Unknown Source)
at org.eclipse.birt.report.service.BirtViewerReportService.getPage(Unknown Source)
at org.eclipse.birt.report.service.actionhandler.BirtChangeParameterActionHandler.doRenderPage(Unknown Source)
at org.eclipse.birt.report.service.actionhandler.AbstractChangeParameterActionHandler.__execute(Unknown Source)
at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(Unknown Source)
at org.eclipse.birt.report.soapengine.processor.AbstractBaseDocumentProcessor.__executeAction(Unknown Source)
at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.executeAction(Unknown Source)
at org.eclipse.birt.report.soapengine.processor.BirtDocumentProcessor.handleChangeParameter(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.process(Unknown Source)
at org.eclipse.birt.report.soapengine.endpoint.BirtSoapBindingImpl.getUpdatedObjects(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.doPost(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.eclipse.birt.report.filter.ViewerFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.mozilla.javascript.EcmaError: TypeError: [JavaPackage CDBConnection] n'est pas une fonction (<inline>#1)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3240)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3230)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3246)
at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3258)
at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3317)
at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3308)
at org.mozilla.javascript.ScriptRuntime.newObject(ScriptRuntime.java:2057)
at org.mozilla.javascript.gen.c91._c0(<inline>:1)
at org.mozilla.javascript.gen.c91.call(<inline>)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769)
at org.mozilla.javascript.gen.c91.call(<inline>)
at org.mozilla.javascript.gen.c91.exec(<inline>)
at org.eclipse.birt.core.script.ScriptContext.eval(ScriptContext.java:223)
at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:576)
... 53 more</pre>
<br />
It seems like the report cannot find CDBConnection class. Could you help me fix it?<br />
I don't know if I really have to export my java classes in a .jar file. I'm new in programming in Java but I used to code in C++ so my classes are good but I don't know how to export them to generate the report in my tomcat web viewer.<br />
Thank's for your help!
Warning No formatter is installed for the format ipb

Comments

  • Virgil Dodson
    Virgil Dodson E admin
    edited December 31, 1969 #2
    Hi frenchGuy,

    The classes should be visible to the scriptengine by simply having them in the WEB-INF/classes or JAR'd up in the WEB-INF/lib folder of your web application that contains the BIRT Viewer. You also have control of the BIRT_VIEWER_SCRIPTLIB_DIR folder by changing a property in the web.xml. By default this is the scriptlib directory at the root of the webapp.

    One other thing you may want to be watch out for. Since you are compiling classes in Eclipse and then exporting them into Tomcat, make sure you are compiling with the same Java vesion. I tracked a similar problem down myself with similar errors about classes missing and it turned out I was compiling for Java 6 and my older test Tomcat 5.0 had 1.4.2 loaded.
    Warning No formatter is installed for the format ipb
  • frenchGuy
    edited December 31, 1969 #3
    Thank's for your reply :)
    I'll do the tests right now.
    Warning No formatter is installed for the format ipb
  • frenchGuy
    edited December 31, 1969 #4
    It's working great!!!
    I've move my JAR file in the scriptlib folder of birt webapps folder.
    Thank's for your help.
    Warning No formatter is installed for the format ipb
  • frenchGuy
    edited December 31, 1969 #5
    <blockquote class='ipsBlockquote' data-author="frenchGuy"><p>
    I've move my JAR file</p></blockquote>
    OK, excuse my english, I tried to say "I moved my JAR file". Like you can read in my screen name, I'm french ^^
    Warning No formatter is installed for the format ipb