Home
Analytics
TypeError on ArrayList (not a function, it is object)
crowt999
All,
I have the following class to create a "BirtFieldList"
package com.bfm.app.publish.birt;
import java.util.ArrayList;
/*an arraylist that contains the fields of an array
Don't Delete (Needed by all data source classes*/
public class BirtFieldList extends ArrayList{
}
In my Open of my scripted Data set, I do the following to set "fields" to a "BirtFieldList"
importPackage (Packages.com.bfm.app.publish.birt);
fieldArray = new Array("ASSET_ID");
fields = new Packages.com.bfm.app.publish.birt.BirtFieldList(); //array list
This returns the following error when I debug the report:
>>>> Debugger exception occured:
org.mozilla.javascript.EcmaError: TypeError: [JavaPackage com.bfm.app.publish.birt.BirtFieldList] is not a function, it is object. (#6)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582)
at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3637)
at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3625)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3367)
at script.__bm_OPEN(:6)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at org.mozilla.javascript.SecurityController$1.exec(SecurityController.java:193)
at org.eclipse.birt.report.engine.javascript.ScriptUtil$1.execWithDomain(ScriptUtil.java:59)
at org.mozilla.javascript.SecurityController.callWithDomain(SecurityController.java:189)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2473)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3335)
at script()
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at org.mozilla.javascript.SecurityController$1.exec(SecurityController.java:193)
at org.eclipse.birt.report.engine.javascript.ScriptUtil$1.execWithDomain(ScriptUtil.java:59)
at org.mozilla.javascript.SecurityController.callWithDomain(SecurityController.java:189)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2473)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:173)
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateRawScript(JavascriptEvalUtil.java:95)
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateScript(JavascriptEvalUtil.java:134)
at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:737)
at org.eclipse.birt.data.engine.script.JSMethodRunner.runScript(JSMethodRunner.java:76)
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:219)
at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleOpen(ScriptDataSetScriptExecutor.java:88)
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:244)
at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor.executeOdiQuery(PreparedScriptDSQuery.java:220)
at org.eclipse.birt.data.engine.impl.QueryExecutor.execute(QueryExecutor.java:1033)
at org.eclipse.birt.data.engine.impl.ServiceForQueryResults.executeQuery(ServiceForQueryResults.java:232)
at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:158)
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:155)
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:254)
at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1818)
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:90)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:99)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:170)
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:75)
at org.eclipse.birt.report.debug.internal.core.launcher.ReportLauncher.createReport(ReportLauncher.java:594)
at org.eclipse.birt.report.debug.internal.core.launcher.ReportLauncher.renderReport(ReportLauncher.java:541)
at org.eclipse.birt.report.debug.internal.core.launcher.ReportLauncher.run(ReportLauncher.java:455)
at org.eclipse.birt.report.debug.internal.core.launcher.ReportLauncher.main(ReportLauncher.java:104)
at org.eclipse.birt.report.debug.internal.core.ReportDebugger.start(ReportDebugger.java:39)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
>>>> Exit script.
Again this is all related to an upgrade I am doing from Birt 2.12 to 2.5, and I am trying to figure out where all these errors are coming from..
Thanks
Dean
Find more posts tagged with
Comments
JasonW
Dean,
Can you try:
fields = new BirtFieldList();
instead of
fields = new Packages.com.bfm.app.publish.birt.BirtFieldList();
Jason
crowt999
When I make that change, it now returns:
org.mozilla.javascript.EcmaError: ReferenceError: "BirtFieldList" is not defined. (#6)
JasonW
I assume this is in the designer. Where is this package jar located?
com.bfm.app.publish.birt
Jason
crowt999
We have a BirtReporting project that contains these classes.
I have the project referenced by my reporting project to access this code. I was referencing the BirtReporting.jar directly, and was getting the same errors. So i switched to the source code so I could try to figure this out...
We have the BirtFieldList, which is an Array List, then we have the AbstractSimpleXMLDataSource class which uses the sax parser to parse the xml files for all of the fields in the ArrayList.
I attached a screenshot (hope that helps)
Dean
JasonW
If you have the com.bfm.app.publish.birt
package in a Java project in the same workspace as the BIRT Reporting project it should be able to locate the class. Are these two different projects? Also can you add a dummy package in your Java project that returns a hard coded array list? This would be to test if the engine is failing to locate one of the classes that BirtFieldList depends on.
Jason
crowt999
Jason -
I've stripped down my report to 1 field from my XML file at this point.
In the <open> of my data set I have the following:
importPackage (Packages.com.bfm.app.publish.birt);
fieldArray = new Array("ASSET_ID");
var fields = new BirtFieldList(); //array list
for(index in fieldArray) {
field = fieldArray[index];
fields.add(field);
}
favoritesClass = new Packages.com.bfm.app.publish.birt.AbstractSimpleXMLDataSource(fields, "FUND_set");
favorites = favoritesClass.getData(params["Ledger"]);
totalrows = favorites.size();
currentrow = 0;
In the <fetch> :
if( currentrow >= totalrows) {
return (false);
}
var favrow = favorites.get(currentrow);
for(index in fieldArray) {
var field = fieldArray[index];
row[field] = favrow[index];
}
currentrow = currentrow + 1;
return (true);
So basically - I am returning 1 field from an XML file.
When I preview the data set - it works ! I get all of my data back.
So then I dropped the column into a report table, and the data comes back there as well...
these errors I am seeing are only when I select "Run - Debug Report" from the main menu, the console then fills up with the errors previously posted...
Could this have something to do with the debugger & no necessarily with the scripted data source ? Just a thought - as I am able to get data back...
Thanks again for the help today -
Dean
JasonW
Open up the debug configuration and you will see your report und the Report icon in the list of debug configurations. Select it and then select the Classpath tab. Select User Entries and then either add your Java project using Add Projects or Add Jars and add your Jar.
Jason
JasonW
To get to debug configuration use:
Window->Open Perspective->Other then Debug
Then select Run->Debug Configurations
Jason
crowt999
Jason - That did the trick... Those errors are all gone when after I added the JAR file to the classpath of the debug config...
Thanks again & Happy Holidays!
Dean