Problem accessing POJO in birt Scripts [message #366629] |
Thu, 15 January 2009 16:00 |
Eclipse User |
|
|
|
Originally posted by: news.jbdb.de
Hi there,
I have used the Report Engine API Example to try and create a small
report using the command line. To do this I used a scripted data source
with the following open script:
favoritesClass = new Packages.simple.SimpleClass();
favorites = favoritesClass.readData();
totalrows = favorites.size();
currentrow = 0;
This works perfectly well. However for another project I need to access
an already existing object and am unable to simply create a new one.
Following the hints outlined in the Report Engine API document, I tried
adding my class to the report tasks application context:
//Set parent classloader for engine
task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOA DER_KEY,
SimpleClass.class.getClassLoader());
//Add my existing class to the context:
task.getAppContext().put("SimpleClass", existingSimpleClass);
My open script then looked like this:
importPackage(Packages.simple);
favoritesClass = SimpleClass;
favorites = favoritesClass.readData();
totalrows = favorites.size();
currentrow = 0;
Now whenever I try and run the project I get the following error:
Caused by: org.eclipse.birt.core.exception.CoreException: There are
errors evaluating script "__bm_OPEN()":
Java class "simple.SimpleClass" has no public instance field or method
named "readData". (<inline>#4).
at org.eclipse.birt.core.script.ScriptContext.eval(ScriptContex t.java:300)
at org.eclipse.birt.core.script.ScriptContext.eval(ScriptContex t.java:261)
at
org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJ SAsExpr(ScriptEvalUtil.java:713)
... 25 more
However, this is the very same class that I used before, only now I try
to use an existing object rather than creating a new one. Therefore it
will have the exact same methods.
What am I doing wrong? How do I access existing POJOs in a report? How
do I use the app context? Any help would be greatly appreciated!
Regards
Jan Baumann
|
|
|
Re: Problem accessing POJO in birt Scripts [message #366633 is a reply to message #366629] |
Thu, 15 January 2009 19:49 |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
Jan,
can you try to set the class loader on the EngineConfig instead of the task.
You should be able to add the object to the task, but if that does not
work try to add it to config as well.
config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSL OADER_KEY,
SimpleClass.class.getClassLoader());
Jason
Jan Baumann wrote:
> Hi there,
>
> I have used the Report Engine API Example to try and create a small
> report using the command line. To do this I used a scripted data source
> with the following open script:
>
> favoritesClass = new Packages.simple.SimpleClass();
> favorites = favoritesClass.readData();
> totalrows = favorites.size();
> currentrow = 0;
>
>
> This works perfectly well. However for another project I need to access
> an already existing object and am unable to simply create a new one.
> Following the hints outlined in the Report Engine API document, I tried
> adding my class to the report tasks application context:
>
> //Set parent classloader for engine
> task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOA DER_KEY,
> SimpleClass.class.getClassLoader());
> //Add my existing class to the context:
> task.getAppContext().put("SimpleClass", existingSimpleClass);
>
> My open script then looked like this:
>
> importPackage(Packages.simple);
> favoritesClass = SimpleClass;
> favorites = favoritesClass.readData();
> totalrows = favorites.size();
> currentrow = 0;
>
> Now whenever I try and run the project I get the following error:
>
> Caused by: org.eclipse.birt.core.exception.CoreException: There are
> errors evaluating script "__bm_OPEN()":
> Java class "simple.SimpleClass" has no public instance field or method
> named "readData". (<inline>#4).
> at
> org.eclipse.birt.core.script.ScriptContext.eval(ScriptContex t.java:300)
> at
> org.eclipse.birt.core.script.ScriptContext.eval(ScriptContex t.java:261)
> at
> org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJ SAsExpr(ScriptEvalUtil.java:713)
>
> ... 25 more
>
> However, this is the very same class that I used before, only now I try
> to use an existing object rather than creating a new one. Therefore it
> will have the exact same methods.
>
> What am I doing wrong? How do I access existing POJOs in a report? How
> do I use the app context? Any help would be greatly appreciated!
>
> Regards
>
> Jan Baumann
|
|
|
Re: Problem accessing POJO in birt Scripts [message #366646 is a reply to message #366633] |
Mon, 19 January 2009 07:33 |
Eclipse User |
|
|
|
Originally posted by: news.jbdb.de
Thanks Jason, adding the classloader as well as the object to the
configuration did solve the problem. Strange though, that the tasks
appConfig doesn't seem to be evaluated inside BIRT - at least in some
cases.
Cheers
Jan
Jason Weathersby schrieb:
> Jan,
>
> can you try to set the class loader on the EngineConfig instead of the
> task.
>
> You should be able to add the object to the task, but if that does not
> work try to add it to config as well.
>
> config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSL OADER_KEY,
> SimpleClass.class.getClassLoader());
>
> Jason
>
>
>
>
> Jan Baumann wrote:
>> Hi there,
>>
>> I have used the Report Engine API Example to try and create a small
>> report using the command line. To do this I used a scripted data
>> source with the following open script:
>>
>> favoritesClass = new Packages.simple.SimpleClass();
>> favorites = favoritesClass.readData();
>> totalrows = favorites.size();
>> currentrow = 0;
>>
>>
>> This works perfectly well. However for another project I need to
>> access an already existing object and am unable to simply create a new
>> one. Following the hints outlined in the Report Engine API document, I
>> tried adding my class to the report tasks application context:
>>
>> //Set parent classloader for engine
>> task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOA DER_KEY,
>> SimpleClass.class.getClassLoader());
>> //Add my existing class to the context:
>> task.getAppContext().put("SimpleClass", existingSimpleClass);
>>
>> My open script then looked like this:
>>
>> importPackage(Packages.simple);
>> favoritesClass = SimpleClass;
>> favorites = favoritesClass.readData();
>> totalrows = favorites.size();
>> currentrow = 0;
>>
>> Now whenever I try and run the project I get the following error:
>>
>> Caused by: org.eclipse.birt.core.exception.CoreException: There are
>> errors evaluating script "__bm_OPEN()":
>> Java class "simple.SimpleClass" has no public instance field or method
>> named "readData". (<inline>#4).
>> at
>> org.eclipse.birt.core.script.ScriptContext.eval(ScriptContex t.java:300)
>> at
>> org.eclipse.birt.core.script.ScriptContext.eval(ScriptContex t.java:261)
>> at
>> org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJ SAsExpr(ScriptEvalUtil.java:713)
>>
>> ... 25 more
>>
>> However, this is the very same class that I used before, only now I
>> try to use an existing object rather than creating a new one.
>> Therefore it will have the exact same methods.
>>
>> What am I doing wrong? How do I access existing POJOs in a report? How
>> do I use the app context? Any help would be greatly appreciated!
>>
>> Regards
>>
>> Jan Baumann
|
|
|
Re: Problem accessing POJO in birt Scripts [message #366658 is a reply to message #366646] |
Mon, 19 January 2009 23:52 |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
Jan,
I believe we changed this in the 2.3 build. You can no longer change
the class loader in the task, only in the engine config.
Jason
Jan Baumann wrote:
> Thanks Jason, adding the classloader as well as the object to the
> configuration did solve the problem. Strange though, that the tasks
> appConfig doesn't seem to be evaluated inside BIRT - at least in some
> cases.
>
> Cheers
>
> Jan
>
> Jason Weathersby schrieb:
>> Jan,
>>
>> can you try to set the class loader on the EngineConfig instead of the
>> task.
>>
>> You should be able to add the object to the task, but if that does not
>> work try to add it to config as well.
>>
>> config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSL OADER_KEY,
>> SimpleClass.class.getClassLoader());
>>
>> Jason
>>
>>
>>
>>
>> Jan Baumann wrote:
>>> Hi there,
>>>
>>> I have used the Report Engine API Example to try and create a small
>>> report using the command line. To do this I used a scripted data
>>> source with the following open script:
>>>
>>> favoritesClass = new Packages.simple.SimpleClass();
>>> favorites = favoritesClass.readData();
>>> totalrows = favorites.size();
>>> currentrow = 0;
>>>
>>>
>>> This works perfectly well. However for another project I need to
>>> access an already existing object and am unable to simply create a
>>> new one. Following the hints outlined in the Report Engine API
>>> document, I tried adding my class to the report tasks application
>>> context:
>>>
>>> //Set parent classloader for engine
>>> task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOA DER_KEY,
>>> SimpleClass.class.getClassLoader());
>>> //Add my existing class to the context:
>>> task.getAppContext().put("SimpleClass", existingSimpleClass);
>>>
>>> My open script then looked like this:
>>>
>>> importPackage(Packages.simple);
>>> favoritesClass = SimpleClass;
>>> favorites = favoritesClass.readData();
>>> totalrows = favorites.size();
>>> currentrow = 0;
>>>
>>> Now whenever I try and run the project I get the following error:
>>>
>>> Caused by: org.eclipse.birt.core.exception.CoreException: There are
>>> errors evaluating script "__bm_OPEN()":
>>> Java class "simple.SimpleClass" has no public instance field or
>>> method named "readData". (<inline>#4).
>>> at
>>> org.eclipse.birt.core.script.ScriptContext.eval(ScriptContex t.java:300)
>>> at
>>> org.eclipse.birt.core.script.ScriptContext.eval(ScriptContex t.java:261)
>>> at
>>> org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJ SAsExpr(ScriptEvalUtil.java:713)
>>>
>>> ... 25 more
>>>
>>> However, this is the very same class that I used before, only now I
>>> try to use an existing object rather than creating a new one.
>>> Therefore it will have the exact same methods.
>>>
>>> What am I doing wrong? How do I access existing POJOs in a report?
>>> How do I use the app context? Any help would be greatly appreciated!
>>>
>>> Regards
>>>
>>> Jan Baumann
|
|
|
Powered by
FUDForum. Page generated in 0.04224 seconds