Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » ReferenceError to POJO when using BIRT runtimes to produce report
ReferenceError to POJO when using BIRT runtimes to produce report [message #1032119] Tue, 02 April 2013 15:37 Go to next message
Sebastiaan Hendriks is currently offline Sebastiaan HendriksFriend
Messages: 13
Registered: March 2013
Location: Netherlands
Junior Member
I'm building a reportingsystem in Eclipse Scout which is going to use BIRT runtimes for the reporting part of things.

After succesfully constructing a report in BIRT Designer based upon a mssql connection and then producing one in my Eclipse Scout project with the BIRT runtimes, I'm currently trying to construct another report using a POJO as a scripted datasource.

To learn how to get this done using BIRT, I've created my own POJO with a function that provides a list of objects with dummy/static data.

Based upon the tutorial by Lars Vogella about BIRT and POJO's, i've build the following code in the Script:Open box of my Data Set.

count = 0;

importPackage(Packages.org.myApp.solomon.server.services.custom.reporting);

cs = new ClientService();

clients = cs.getMockClients(); 


The class ClientService is placed in the src folder of my org.MyApp.solomon.server bundle, in the org.myApp.solomon.server.services.custom.reporting package, and it runs fine when I call its getMockClients() function directly.

When I produce a version of the report via my application however, the BIRT runtimes comes up with the following error:
Error evaluating Javascript expression. Script engine error: ReferenceError: "ClientService" is not defined. (/report/data-sets/script-data-set[@id="28"]/method[@name="open"]#5)


The report itself produces just fine after this error, altho a bit empty on the dataside of things.

It seems that I'm missing something obvious, can anyone help me?

I'm using;
*Eclipse Juno SR1
*Eclipse Scout 3.8.1
*Eclipse BIRT 4.2.1
Re: ReferenceError to POJO when using BIRT runtimes to produce report [message #1032633 is a reply to message #1032119] Wed, 03 April 2013 08:32 Go to previous messageGo to next message
Sebastiaan Hendriks is currently offline Sebastiaan HendriksFriend
Messages: 13
Registered: March 2013
Location: Netherlands
Junior Member
After a good night sleep and a fresh look at things, I have managed to find the solution on my own. In order to solve the referenceError, I've modified the code to the following:
count = 0;
Packages.java.lang.System.out.println(count); //This line is being used to test the value of count.

pack = Packages.nl.rid.solomon.server.services.custom.reporting;

cs = new pack.ClientService();

clients = cs.getMockClients();


A new error popped up however, namely the following:
Error evaluating Javascript expression. Script engine error: TypeError: Cannot call property getMockClients in object [JavaPackage org.myApp.solomon.server.services.custom.reporting.ClientService]. It is not a function, it is "object". (/report/data-sets/script-data-set[@id="28"]/method[@name="open"]#6)
 


Which I managed to solve by adding my Class to the BIRT's scripting classpath. The code for that is writen in the function which calls the BIRT runtimes in my application, and the code for that looks like this:

EngineConfig conf = new EngineConfig();
HashMap map = conf.getAppContext();
map.put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, ClientService.class.getClassLoader()); 
//This line includes my Class into the BIRT classpath by adding it to the configuration for the BIRT engine

conf.setAppContext(map);
// Code omitted...
ReportEngine eng = new ReportEngine(conf);

[Updated on: Wed, 03 April 2013 08:49]

Report message to a moderator

Re: ReferenceError to POJO when using BIRT runtimes to produce report [message #1033852 is a reply to message #1032633] Thu, 04 April 2013 18:13 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Great! Glad you got it working!

Michael

Developer Evangelist, Silanis
Re: ReferenceError to POJO when using BIRT runtimes to produce report [message #1053281 is a reply to message #1033852] Fri, 03 May 2013 14:21 Go to previous messageGo to next message
Sebastiaan Hendriks is currently offline Sebastiaan HendriksFriend
Messages: 13
Registered: March 2013
Location: Netherlands
Junior Member
It seems that the planets have misaligned or something, since the problem in my second post has returned.

First, a bit of a backstory. I got a request to build a certain report in BIRT, for which I've concluded that I'm better off at constructing the data in Java then doing all sorts of magic in MSSQL2000.

Since I managed to 'succesfully' use a POJO as a resource for a BIRT testreport before, it would be possible then. So I started off with first checking if my testreport still worked from last month. The <It is not a function, it is "object".> error popped up.

So much for having a succesfull testreport.

I've spend most part of the day trying to figure out why I'm getting that error again, and I'm running out of idea's.

The situation I'm at now is more or less the same.

The class I'm trying to use in BIRT is ClientClass();
package nl.rid.solomon.server.pojo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class ClientClass {

  public static List<Client> getMockClients()
  {
    List<Client> list = new ArrayList<Client>();

    for (int i = 1; i <= 31; i++) {

      Client client = new Client();

      client.setID(new Long(i));
      client.setUnit("Arnhem");
      client.setVoornaam("FirstName");
      client.setAchternaam("LastName");
      client.setAanmeldingDatum(new Date());
      client.setStartdatumBehandeling(new Date());
      client.setSchoolNaam("My School");
      client.setProvincie("Gelderland");
      client.setGemeente("My District");
      client.setPlaats("My City");
      client.setAdres("My Adres");
      client.setPostcode("My Zipcode");
      client.setTelefoonNr("0-800-callmemaybe");

      list.add(client);
    }
    return list;
  }
}

The function which is adding that Class to the BIRT Classloader, and also creating the report, is as followed:
private byte[] _createReport(Object[][] reportData, List<ReportParameter> reportParameterList, AbstractSqlService service) {
  ReportEngine eng = _getReportEngine();

  try {
    IReportRunnable design = eng.openReportDesign(reportData[0][3].toString());
    IRunAndRenderTask task = eng.createRunAndRenderTask(design);
    ByteArrayOutputStream bytearray = new ByteArrayOutputStream();

    String reportFileType = null;
    Map<String, Object> parameters = new HashMap<String, Object>();
    for (ReportParameter reportParameter : reportParameterList)
    {
      if (reportParameter.getName().equals("ReportFileType"))
      {
        reportFileType = reportParameter.getValue().toString();
        continue;
      }
      if (reportParameter.getName().equals("Unit"))
      {
        parameters.put(reportParameter.getName(), Integer.parseInt(reportParameter.getValue().toString()));
        continue;
      }
      if (reportParameter.getDataType().equals("Date"))
      {
        java.util.Date sqlDate = new java.sql.Date(((java.util.Date) reportParameter.getValue()).getTime());
        parameters.put(reportParameter.getName(), sqlDate);
      }
      if (reportParameter.getDataType().equals("DateTime"))
      {
        parameters.put(reportParameter.getName(), ((java.util.Date) reportParameter.getValue()));
      }
    }

    //JDBC Params
    parameters.put("Driver Class", service.getJdbcDriverName());
    parameters.put("URL", service.getJdbcMappingName());
    parameters.put("User Name", service.getUsername());
    parameters.put("Password", service.getPassword());

    IRenderOption options = new RenderOption();
    options.setOutputStream(bytearray);
    if (reportFileType == null)
    {
      eng.destroy();
      return null;
    }
    options.setOutputFormat(reportFileType.toLowerCase());
    task.setRenderOption(options);

    task.setParameterValues(parameters);

    task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, ClientClass.class.getClassLoader());

    task.run();

    return bytearray.toByteArray();
  }
  catch (EngineException e) {
    e.printStackTrace();
  }
  finally {
    eng.destroy();
  }
  return null;
}

In the report itself, I got the following code set:
count = 0;
Packages.java.lang.System.out.println(count);

cs = new Packages.nl.rid.solomon.server.pojo.ClientClass();

clients = cs.getMockClients();


And this is the Stacktrace I'm getting at runtime:
0.0
mei 03, 2013 4:17:22 PM org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor handleJS
WARNING: Fail to execute script in function __bm_OPEN(). Source:
------
" + count = 0;
Packages.java.lang.System.out.println(count);

cs = new Packages.nl.rid.solomon.server.pojo.ClientClass();

clients = cs.getMockClients(); + "
-----
A BIRT exception occurred. See next exception for more information.
Error evaluating Javascript expression. Script engine error: TypeError: [JavaPackage nl.rid.solomon.server.pojo.ClientClass] is not a function, it is object. (/report/data-sets/script-data-set[@id="28"]/method[@name="open"]#4)
 Script source: /report/data-sets/script-data-set[@id="28"]/method[@name="open"], line: 0, text:
__bm_OPEN()
org.eclipse.birt.data.engine.core.DataException: Fail to execute script in function __bm_OPEN(). Source:
------
" + count = 0;
Packages.java.lang.System.out.println(count);

cs = new Packages.nl.rid.solomon.server.pojo.ClientClass();

clients = cs.getMockClients(); + "
-----
A BIRT exception occurred. See next exception for more information.
Error evaluating Javascript expression. Script engine error: TypeError: [JavaPackage nl.rid.solomon.server.pojo.ClientClass] is not a function, it is object. (/report/data-sets/script-data-set[@id="28"]/method[@name="open"]#4)
 Script source: /report/data-sets/script-data-set[@id="28"]/method[@name="open"], line: 0, text:
__bm_OPEN()
	at org.eclipse.birt.data.engine.script.JSMethodRunner.runScript(JSMethodRunner.java:147)
	at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:90)
	at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.handleJS(DataSetScriptExecutor.java:256)
	at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleOpen(ScriptDataSetScriptExecutor.java:98)
	at org.eclipse.birt.data.engine.impl.ScriptDataSetRuntime.open(ScriptDataSetRuntime.java:80)
	at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor$CustomDataSet.open(PreparedScriptDSQuery.java:247)
	at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor.executeOdiQuery(PreparedScriptDSQuery.java:223)
	at org.eclipse.birt.data.engine.impl.QueryExecutor.execute(QueryExecutor.java:1142)
	at org.eclipse.birt.data.engine.impl.ServiceForQueryResults.executeQuery(ServiceForQueryResults.java:232)
	at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:177)
	at org.eclipse.birt.report.engine.data.dte.QueryResultSet.<init>(QueryResultSet.java:98)
	at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:168)
	at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:267)
	at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1939)
	at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80)
	at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62)
	at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
	at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
	at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)
	at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)
	at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
	at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:180)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
	at nl.rid.solomon.server.services.custom.reporting.ReportService._createReport(ReportService.java:158)
	at nl.rid.solomon.server.services.custom.reporting.ReportService.createReport(ReportService.java:66)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.scout.service.ServiceUtility.invoke(ServiceUtility.java:172)
	at org.eclipse.scout.rt.server.DefaultTransactionDelegate.invokeImpl(DefaultTransactionDelegate.java:218)
	at org.eclipse.scout.rt.server.DefaultTransactionDelegate.invoke(DefaultTransactionDelegate.java:92)
	at org.eclipse.scout.rt.server.ServiceTunnelServlet.runServerJobTransactionWithDelegate(ServiceTunnelServlet.java:391)
	at org.eclipse.scout.rt.server.ServiceTunnelServlet.runServerJobTransaction(ServiceTunnelServlet.java:387)
	at org.eclipse.scout.rt.server.ServiceTunnelServlet$RemoteServiceJob.runTransaction(ServiceTunnelServlet.java:415)
	at org.eclipse.scout.rt.server.ServerJob.runTransactionWrapper(ServerJob.java:202)
	at org.eclipse.scout.rt.server.ServerJob.access$0(ServerJob.java:190)
	at org.eclipse.scout.rt.server.ServerJob$1.run(ServerJob.java:161)
	at org.eclipse.scout.rt.server.ServerJob$1.run(ServerJob.java:1)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Unknown Source)
	at org.eclipse.scout.rt.server.ServerJob.run(ServerJob.java:156)
	at org.eclipse.scout.commons.job.JobEx.runNow(JobEx.java:50)
	at org.eclipse.scout.rt.server.ServerJob.runNow(ServerJob.java:148)
	at org.eclipse.scout.rt.server.ServiceTunnelServlet.doPost(ServiceTunnelServlet.java:296)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	at org.eclipse.scout.http.servletfilter.HttpServletEx.access$0(HttpServletEx.java:1)
	at org.eclipse.scout.http.servletfilter.HttpServletEx$1.service(HttpServletEx.java:38)
	at org.eclipse.scout.http.servletfilter.internal.FilterChainImpl.doFilter(FilterChainImpl.java:44)
	at org.eclipse.scout.http.servletfilter.helper.HttpAuthJaasFilter.doFilter(HttpAuthJaasFilter.java:62)
	at org.eclipse.scout.http.servletfilter.internal.FilterChainImpl.doFilter(FilterChainImpl.java:41)
	at org.eclipse.scout.http.servletfilter.helper.DevelopmentAuthFilter.doFilter(DevelopmentAuthFilter.java:61)
	at org.eclipse.scout.http.servletfilter.internal.FilterChainImpl.doFilter(FilterChainImpl.java:41)
	at org.eclipse.scout.http.servletfilter.security.AbstractChainableSecurityFilter.doFilterInternal(AbstractChainableSecurityFilter.java:220)
	at org.eclipse.scout.http.servletfilter.security.AbstractChainableSecurityFilter.access$0(AbstractChainableSecurityFilter.java:219)
	at org.eclipse.scout.http.servletfilter.security.AbstractChainableSecurityFilter$1.run(AbstractChainableSecurityFilter.java:157)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Unknown Source)
	at org.eclipse.scout.http.servletfilter.security.AbstractChainableSecurityFilter.doFilter(AbstractChainableSecurityFilter.java:149)
	at org.eclipse.scout.http.servletfilter.internal.FilterChainImpl.doFilter(FilterChainImpl.java:41)
	at org.eclipse.scout.http.servletfilter.security.AbstractChainableSecurityFilter.doFilter(AbstractChainableSecurityFilter.java:103)
	at org.eclipse.scout.http.servletfilter.internal.FilterChainImpl.doFilter(FilterChainImpl.java:41)
	at org.eclipse.scout.http.servletfilter.ServletFilterDelegate.delegateServiceMethod(ServletFilterDelegate.java:57)
	at org.eclipse.scout.http.servletfilter.HttpServletEx.service(HttpServletEx.java:35)
	at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
	at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
	at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
	at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:384)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
	at org.eclipse.jetty.server.Server.handle(Server.java:350)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
	at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:900)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:954)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:851)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.eclipse.birt.data.engine.core.DataException: A BIRT exception occurred. See next exception for more information.
Error evaluating Javascript expression. Script engine error: TypeError: [JavaPackage nl.rid.solomon.server.pojo.ClientClass] is not a function, it is object. (/report/data-sets/script-data-set[@id="28"]/method[@name="open"]#4)
 Script source: /report/data-sets/script-data-set[@id="28"]/method[@name="open"], line: 0, text:
__bm_OPEN()
	at org.eclipse.birt.data.engine.core.DataException.wrap(DataException.java:123)
	at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:996)
	at org.eclipse.birt.data.engine.script.JSMethodRunner.runScript(JSMethodRunner.java:138)
	... 92 more
Caused by: org.eclipse.birt.core.exception.CoreException: Error evaluating Javascript expression. Script engine error: TypeError: [JavaPackage nl.rid.solomon.server.pojo.ClientClass] is not a function, it is object. (/report/data-sets/script-data-set[@id="28"]/method[@name="open"]#4)
 Script source: /report/data-sets/script-data-set[@id="28"]/method[@name="open"], line: 0, text:
__bm_OPEN()
	at org.eclipse.birt.core.script.JavascriptEvalUtil.wrapRhinoException(JavascriptEvalUtil.java:303)
	at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateRawScript(JavascriptEvalUtil.java:102)
	at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateScript(JavascriptEvalUtil.java:134)
	at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:992)
	... 93 more
Caused by: org.mozilla.javascript.EcmaError: TypeError: [JavaPackage nl.rid.solomon.server.pojo.ClientClass] is not a function, it is object. (/report/data-sets/script-data-set[@id="28"]/method[@name="open"]#4)
	at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
	at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
	at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3660)
	at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3679)
	at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3734)
	at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3722)
	at org.mozilla.javascript.ScriptRuntime.newObject(ScriptRuntime.java:2324)
	at org.mozilla.javascript.gen.c19._c1(/report/data-sets/script-data-set[@id="28"]/method[@name="open"]:4)
	at org.mozilla.javascript.gen.c19.call(/report/data-sets/script-data-set[@id="28"]/method[@name="open"])
	at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
	at org.mozilla.javascript.gen.c6._c0(/report/data-sets/script-data-set[@id="28"]/method[@name="open"]:0)
	at org.mozilla.javascript.gen.c6.call(/report/data-sets/script-data-set[@id="28"]/method[@name="open"])
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
	at org.mozilla.javascript.gen.c6.call(/report/data-sets/script-data-set[@id="28"]/method[@name="open"])
	at org.mozilla.javascript.gen.c6.exec(/report/data-sets/script-data-set[@id="28"]/method[@name="open"])
	at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateRawScript(JavascriptEvalUtil.java:95)
	... 95 more

mei 03, 2013 4:17:22 PM org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor handleJS
WARNING: Fail to execute script in function __bm_FETCH(). Source:
------
" + if(count < clients.size()){
       row["Name"] = clients.get(count).getVoornaam();
       row["School"] = clients.get(count).getSchoolNaam();
       row["StartDate"] = clients.get(count).getAanmeldingDatum();
       count++;
       return true;
}

return false;  + "
-----
A BIRT exception occurred. See next exception for more information.
Error evaluating Javascript expression. Script engine error: ReferenceError: "clients" is not defined. (/report/data-sets/script-data-set[@id="28"]/method[@name="fetch"]#1)
 Script source: /report/data-sets/script-data-set[@id="28"]/method[@name="fetch"], line: 0, text:
__bm_FETCH()
org.eclipse.birt.data.engine.core.DataException: Fail to execute script in function __bm_FETCH(). Source:
------
" + if(count < clients.size()){
       row["Name"] = clients.get(count).getVoornaam();
       row["School"] = clients.get(count).getSchoolNaam();
       row["StartDate"] = clients.get(count).getAanmeldingDatum();
       count++;
       return true;
}

return false;  + "
-----
A BIRT exception occurred. See next exception for more information.
Error evaluating Javascript expression. Script engine error: ReferenceError: "clients" is not defined. (/report/data-sets/script-data-set[@id="28"]/method[@name="fetch"]#1)
 Script source: /report/data-sets/script-data-set[@id="28"]/method[@name="fetch"], line: 0, text:
__bm_FETCH()
	at org.eclipse.birt.data.engine.script.JSMethodRunner.runScript(JSMethodRunner.java:147)
//Log snipped



[Updated on: Mon, 06 May 2013 08:43]

Report message to a moderator

Re: ReferenceError to POJO when using BIRT runtimes to produce report [message #1053485 is a reply to message #1053281] Mon, 06 May 2013 08:42 Go to previous message
Sebastiaan Hendriks is currently offline Sebastiaan HendriksFriend
Messages: 13
Registered: March 2013
Location: Netherlands
Junior Member
Managed to get the problem solved.

In my function that was going to handle BIRT, I attempted to add my POJO to BIRT by adding it to the task's AppContext. Even tho that that operation did work, JavaScript errors still occured.

Code snippet re-qouted:
task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, ClientClass.class.getClassLoader());


Now, in that situation, I would insert my POJO right before the report would be created. So, that would be after the BIRT engine has been instantiated, along with the Report Design and any parameters.

After I moved the assignment further up the line, to the moment that the BIRT engine was instantiated, all errors dissappeared. The code for that is the following:
private ReportEngine _getReportEngine()
  {
    EngineConfig conf = new EngineConfig();
      HashMap map = conf.getAppContext();
      map.put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, ClientClass.class.getClassLoader());
      conf.setAppContext(map);
    if (BIRTRuntimesLocation != null)
    {
      conf.setEngineHome(BIRTRuntimesLocation);
    }
    return new ReportEngine(conf);
  }
Previous Topic:Unknown : Column number ?
Next Topic:PDF report with table of contents containing page number
Goto Forum:
  


Current Time: Fri Mar 29 13:20:21 GMT 2024

Powered by FUDForum. Page generated in 0.05676 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top