Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » String index out of bound with importpackage
String index out of bound with importpackage [message #1724853] Fri, 26 February 2016 14:42 Go to next message
osuwariboy Mising name is currently offline osuwariboy Mising nameFriend
Messages: 24
Registered: December 2010
Junior Member
Hello everyone,

I have reports deployed on Tomcat 8 using the Webviewer and they all work perfectly. My version of the BIRT runtime is 4.5.0 and the application is deployed in the webapps/birt directory of Tomcat.

The problem is that now, I have a report that has an imbedded script in the beforeFactory that starts with these lines:

importPackage(Packages.org.eclipse.birt.report.item.crosstab.core.de);
importPackage( Packages.org.eclipse.birt.report.model.api );
importPackage( Packages.org.eclipse.birt.report.item.crosstab.core.util);
importPackage( Packages.org.eclipse.birt.report.item.crosstab.core);
importPackage( Packages.org.eclipse.birt.report.model.api.elements);


Now, the script itself works since if I run it through Eclipse, it works without problem. On the other hand, when I put it on the webviewer, I end up with the following error:

birt.core.JavascriptCommonError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "importPackage(Packages.org.eclipse.birt.report.item.crosstab.core.de);
importPackage( Packages.org.eclipse.birt.report.model.api );
importPackage( Packages.org.eclipse.birt.report.item.crosstab.core.util);
importPackage( Packages.org.eclipse.birt.report.item.crosstab.core);
importPackage( Packages.org.eclipse.birt.report.model.api.elements);

var eF = reportContext.getDesignHandle().getElementFactory();
var srt = eF.newSortElement();

if(params["pOrderBy"].value == "SC")
	srt.setKey("data[\"Total_GRCertificat/Certificat\"]")
else
	srt.setKey("data[\"nbfois_GRCertificat/Age\"]")
	
srt.setDirection(DesignChoiceConstants.SORT_DIRECTION_DESC);

var xtab = reportContext.getDesignHandle().findElement("tab");
var xtabhandle = xtab.getReportItem();

var rws = xtabhandle.getCrosstabView(ICrosstabConstants.ROW_AXIS_TYPE);
var lvh = rws.getDimension("GRCertificat").getLevel(0);

lvh.getModelHandle( ).add( ILevelViewConstants.SORT_PROP, srt );":
String index out of range: 3
	at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:249)
	at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleBeforeFactory(ReportScriptExecutor.java:122)
	at org.eclipse.birt.report.engine.api.impl.EngineTask.startFactory(EngineTask.java:2039)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:101)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:77)
	at org.eclipse.birt.report.service.ReportEngineService.runAndRenderReport(ReportEngineService.java:937)
	at org.eclipse.birt.report.service.BirtViewerReportService.runAndRenderReport(BirtViewerReportService.java:973)
	at org.eclipse.birt.report.service.actionhandler.BirtRunAndRenderActionHandler.__execute(BirtRunAndRenderActionHandler.java:76)
	at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90)
	at org.eclipse.birt.report.presentation.aggregation.layout.EngineFragment.doService(EngineFragment.java:318)
	at org.eclipse.birt.report.presentation.aggregation.AbstractBaseFragment.service(AbstractBaseFragment.java:76)
	at org.eclipse.birt.report.servlet.BirtEngineServlet.__doGet(BirtEngineServlet.java:116)
	at org.eclipse.birt.report.servlet.BaseReportEngineServlet.doGet(BaseReportEngineServlet.java:185)
	at org.eclipse.birt.report.servlet.BaseReportEngineServlet.doPost(BaseReportEngineServlet.java:224)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
	at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.eclipse.birt.report.servlet.BaseReportEngineServlet.service(BaseReportEngineServlet.java:116)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.eclipse.birt.report.filter.ViewerFilter.doFilter(ViewerFilter.java:68)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.eclipse.birt.core.exception.CoreException: There are errors evaluating script "importPackage(Packages.org.eclipse.birt.report.item.crosstab.core.de);
importPackage( Packages.org.eclipse.birt.report.model.api );
importPackage( Packages.org.eclipse.birt.report.item.crosstab.core.util);
importPackage( Packages.org.eclipse.birt.report.item.crosstab.core);
importPackage( Packages.org.eclipse.birt.report.model.api.elements);

var eF = reportContext.getDesignHandle().getElementFactory();
var srt = eF.newSortElement();

if(params["pOrderBy"].value == "SC")
	srt.setKey("data[\"Total_GRCertificat/Certificat\"]")
else
	srt.setKey("data[\"nbfois_GRCertificat/Age\"]")
	
srt.setDirection(DesignChoiceConstants.SORT_DIRECTION_DESC);

var xtab = reportContext.getDesignHandle().findElement("tab");
var xtabhandle = xtab.getReportItem();

var rws = xtabhandle.getCrosstabView(ICrosstabConstants.ROW_AXIS_TYPE);
var lvh = rws.getDimension("GRCertificat").getLevel(0);

lvh.getModelHandle( ).add( ILevelViewConstants.SORT_PROP, srt );":
String index out of range: 3
	at org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:295)
	at org.eclipse.birt.core.script.ScriptContext.evaluate(ScriptContext.java:159)
	at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:789)
	at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:718)
	at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScriptInternal(ScriptExecutor.java:118)
	at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScript(ScriptExecutor.java:105)
	at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleBeforeFactory(ReportScriptExecutor.java:114)
	... 40 more
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 3
	at java.lang.String.charAt(String.java:658)
	at org.apache.catalina.loader.WebappClassLoaderBase.filter(WebappClassLoaderBase.java:2780)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1253)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.eclipse.birt.report.engine.executor.ApplicationClassLoader.loadClass(ApplicationClassLoader.java:89)
	at org.mozilla.javascript.Kit.classOrNull(Kit.java:60)
	at org.mozilla.javascript.NativeJavaPackage.getPkgProperty(NativeJavaPackage.java:127)
	at org.mozilla.javascript.NativeJavaPackage.get(NativeJavaPackage.java:82)
	at org.mozilla.javascript.NativeJavaTopPackage.init(NativeJavaTopPackage.java:96)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.mozilla.javascript.ScriptableObject.buildClassCtor(ScriptableObject.java:1225)
	at org.mozilla.javascript.LazilyLoadedCtor.buildValue0(LazilyLoadedCtor.java:105)
	at org.mozilla.javascript.LazilyLoadedCtor.buildValue(LazilyLoadedCtor.java:96)
	at org.mozilla.javascript.LazilyLoadedCtor.init(LazilyLoadedCtor.java:66)
	at org.mozilla.javascript.ScriptableObject$GetterSlot.getValue(ScriptableObject.java:307)
	at org.mozilla.javascript.ScriptableObject$RelinkedSlot.getValue(ScriptableObject.java:347)
	at org.mozilla.javascript.ScriptableObject.get(ScriptableObject.java:456)
	at org.mozilla.javascript.IdScriptableObject.get(IdScriptableObject.java:329)
	at org.mozilla.javascript.ImporterTopLevel.get(ImporterTopLevel.java:96)
	at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:2184)
	at org.mozilla.javascript.ScriptRuntime.topScopeName(ScriptRuntime.java:1824)
	at org.mozilla.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1791)
	at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1733)
	at org.mozilla.javascript.gen._report_method__name__beforeFactory___222._c_script_0(/report/method[@name="beforeFactory"]:1)
	at org.mozilla.javascript.gen._report_method__name__beforeFactory___222.call(/report/method[@name="beforeFactory"])
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
	at org.mozilla.javascript.gen._report_method__name__beforeFactory___222.call(/report/method[@name="beforeFactory"])
	at org.mozilla.javascript.gen._report_method__name__beforeFactory___222.exec(/report/method[@name="beforeFactory"])
	at org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:290)
	... 46 more


I've tested and any of the import statement will generate this error. My best guess is that the webviewer can't load the BIRT packages, but I don't know how to fix this. Anyone has any idea?
Re: String index out of bound with importpackage [message #1725347 is a reply to message #1724853] Wed, 02 March 2016 21:05 Go to previous messageGo to next message
Eason Tang is currently offline Eason TangFriend
Messages: 2
Registered: March 2016
Junior Member
We're having exactly the same problem. The BIRT Runtime 4.5.0 was previously served in Tomcat 8.0.28 and everything was fine. Since we upgraded Tomcat to 8.0.32, we've been having the same errors. It seems unhappy about the "importPackage" statements.
Re: String index out of bound with importpackage [message #1725434 is a reply to message #1725347] Thu, 03 March 2016 13:21 Go to previous messageGo to next message
osuwariboy Mising name is currently offline osuwariboy Mising nameFriend
Messages: 24
Registered: December 2010
Junior Member
Thanks for the reply Eason. In my case, I was able to go around the problem since all my script really needed were a few constants defined in other packages. So I removed the "importPackages" and replaced the constants with their values and everything started working.

Now as to what Tomcat's problem actually IS, I have no idea.
Re: String index out of bound with importpackage [message #1725435 is a reply to message #1725434] Thu, 03 March 2016 13:29 Go to previous messageGo to next message
osuwariboy Mising name is currently offline osuwariboy Mising nameFriend
Messages: 24
Registered: December 2010
Junior Member
Apparently, in Tomcat 8.0.32, they "fixed" the class loader. This might be what's causing this strange bug. Here's the changelog if anyone wants to see for themselves:

https://tomcat.apache.org/tomcat-8.0-doc/changelog.html
Re: String index out of bound with importpackage [message #1725484 is a reply to message #1725435] Thu, 03 March 2016 19:34 Go to previous messageGo to next message
osuwariboy Mising name is currently offline osuwariboy Mising nameFriend
Messages: 24
Registered: December 2010
Junior Member
I can now confirm that this is actually a bug in Tomcat 8.0.32 but apparently they fixed it and the problem should not reoccur in 8.0.33 whenever they decide to release it. Here's the link to their bugtracker:

https://bz.apache.org/bugzilla/show_bug.cgi?id=58999
Re: String index out of bound with importpackage [message #1728281 is a reply to message #1725484] Fri, 01 April 2016 15:22 Go to previous message
Eason Tang is currently offline Eason TangFriend
Messages: 2
Registered: March 2016
Junior Member
Thanks! We just upgraded our Tomcat to 8.0.33, which solved the problem!
Previous Topic:Pushing group trailer to page footer ?
Next Topic:BIRT 4.3.1 compatibility with PDFBox
Goto Forum:
  


Current Time: Mon Sep 23 19:08:20 GMT 2024

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

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

Back to the top