Hi,
I'm including a number of custom attributes in a custom work item report, and was wanting to use the Commons Collections class MultiKeyMap for simplicity - I can cache the values I need with a dataset containing only stringWorkItemCustomAttributes.put(row["WI_ID"], row["STRING_KEY"], row["STRING_VAL"]) in the onFetch script, and use them in my main dataset with calculated columns of the form stringWorkItemCustomAttributes.get(row["WI_ID"], "myAttributeKey"), and no messing around with separate Maps for each attribute or Maps of Maps to store the sets of attributes for each work item.
At first I got an error when previewing the report in RAD, but I fixed that by adding commons-collections-3.2.1.jar to the Jar Files list in the report's Properties Resources tab. So everything works perfectly now when I preview it locally.
However, when I upload the report to the server and try to run it there, I get an error message
There are errors evaluating script "importPackage(Packages.org.apache.commons.collections.map);
stringWorkItemCustomAttributes = MultiKeyMap.decorate(new HashedMap());
":
ReferenceError: "MultiKeyMap" is not defined. (/report/method[
@name="initialize"]#5)
birt.core.JavascriptCommonError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "importPackage(Packages.org.apache.commons.collections.map);
// Java maps used to collect together the details from various data sets.
// This is populated by the data set's onFetch.
stringWorkItemCustomAttributes = MultiKeyMap.decorate(new HashedMap());
//workItemEnumerationLiterals = MultiKeyMap.decorate(new HashedMap());
serverURL = reportContext.getAppContext().get("SERVER_URL");
if (serverURL == null) serverURL = "";
":
ReferenceError: "MultiKeyMap" is not defined. (/report/method[@name="initialize"]#5)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:158)
at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleInitialize(ReportScriptExecutor.java:53)
at org.eclipse.birt.report.engine.api.impl.EngineTask.loadDesign(EngineTask.java:1766)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:98)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
at com.ibm.team.reports.service.birt.internal.BirtReportEngineService.internalGetRenderedReport(BirtReportEngineService.java:745)
at com.ibm.team.reports.service.birt.internal.BirtReportEngineService.getRenderedReport(BirtReportEngineService.java:335)
at sun.reflect.GeneratedMethodAccessor1311.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
at com.sun.proxy.$Proxy1451.getRenderedReport(Unknown Source)
at com.ibm.team.reports.service.internal.InternalReportService.getRenderedReport(InternalReportService.java:1274)
at sun.reflect.GeneratedMethodAccessor1299.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
at com.sun.proxy.$Proxy953.getRenderedReport(Unknown Source)
at com.ibm.team.reports.service.internal.ReportRestService$4.run(ReportRestService.java:659)
at com.ibm.team.reports.service.internal.ReportRestService.getRenderedReport(ReportRestService.java:684)
at com.ibm.team.reports.service.internal.ReportRestService.postRenderReport(ReportRestService.java:1023)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
at com.sun.proxy.$Proxy1134.postRenderReport(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.doModelledRestService(AbstractTeamServerServlet.java:555)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest2(AbstractTeamServerServlet.java:2355)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest(AbstractTeamServerServlet.java:2155)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.service(AbstractTeamServerServlet.java:1983)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
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:126)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:120)
at com.ibm.team.repository.server.servletbridge.JazzServlet.service(JazzServlet.java:68)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.ibm.team.repository.server.servletbridge.BridgeFilter.processDelegate(BridgeFilter.java:139)
at com.ibm.team.repository.server.servletbridge.BridgeFilter.doFilter(BridgeFilter.java:172)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:336)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:908)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:931)
at java.lang.Thread.run(Thread.java:738)
Caused by: org.eclipse.birt.core.exception.CoreException: There are errors evaluating script "importPackage(Packages.org.apache.commons.collections.map);
// Java maps used to collect together the details from various data sets.
// This is populated by the data set's onFetch.
stringWorkItemCustomAttributes = MultiKeyMap.decorate(new HashedMap());
//workItemEnumerationLiterals = MultiKeyMap.decorate(new HashedMap());
serverURL = reportContext.getAppContext().get("SERVER_URL");
if (serverURL == null) serverURL = "";
":
ReferenceError: "MultiKeyMap" is not defined. (/report/method[@name="initialize"]#5)
at org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:287)
at org.eclipse.birt.core.script.ScriptContext.evaluate(ScriptContext.java:154)
at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:772)
at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:701)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScriptInternal(ScriptExecutor.java:61)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScript(ScriptExecutor.java:48)
at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleInitialize(ReportScriptExecutor.java:44)
... 68 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "MultiKeyMap" is not defined. (/report/method[@name="initialize"]#5)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3717)
at org.mozilla.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1758)
at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1697)
at org.mozilla.javascript.gen.c184849._c0(/report/method[@name="initialize"]:5)
at org.mozilla.javascript.gen.c184849.call(/report/method[@name="initialize"])
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
at org.mozilla.javascript.gen.c184849.call(/report/method[@name="initialize"])
at org.mozilla.javascript.gen.c184849.exec(/report/method[@name="initialize"])
at org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:282)
... 74 more
which I figure is because the report isn't finding the commons collection jar in the classpath when it runs on the server. When uploading the report to the server I did include the jar in the Files list at the bottom of the dialog, but it seems that this isn't enough to let the report use its contents. And there's no separate "Jar Files" list when creating the new Report Resource.
Other things I've found in the forums and wiki, about using java code from reports, all talk about creating a plugin and update site and adding that to the server installation. But our RTC server's a central resource that's used globally, and the chances of me (or any single project area admin) getting anything installed server-wide are practically zero. So is there any other way to allow the report to use the jar? Or do I need to rewrite the report to use only classes in the standard java runtime, and forget about any useful 3rd party libraries?
Andy.