Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
NullPointer at referenced object with scripted Dataset
Simon Hanika
<p>Hi,</p>
<p> </p>
<p>I have a problem with scripted Datasets.</p>
<p> </p>
<p>I created a report with a scripted dataset which should enter a method of a class and at the result I am getting a filled POJO out. This is all going well as long as I just work with local variables.</p>
<p> </p>
<p>My application uses Spring and Dependency injection and The class I am using is a one of the Spring beans.</p>
<p> </p>
<p>All attributes and services which should be filled and initialized are empty or null. </p>
<p>I think I have to give BIRT something like a proxy or classpath variable but I am not sure how this could work?</p>
<p>I also read something about giving the IRunTask Objet a scrptable Object (maybe with addScriptableJavaObject()-Method (which is deprecated!)) </p>
<p> </p>
<p>Can anybody give me a hint what is missing?</p>
<p> </p>
<p>Thanks </p>
<p>Simon</p>
Find more posts tagged with
Comments
Simon Hanika
<p>Hi,</p>
<p> </p>
<p>I found a solution with this article:</p>
<p> </p>
<p><a data-ipb='nomediaparse' href='
http://forum.spring.io/forum/spring-projects/container/59160-loading-applicationcontext-from'>http://forum.spring.io/forum/spring-projects/container/59160-loading-applicationcontext-from</a></p>
;
<p> </p>
<p><span style="color:rgb(37,44,47);font-family:Helvetica, Arial, Verdana, sans-serif;font-size:13px;">You can create a class such as bellow:</span></p>
<div style="margin:0px;font-size:13px;font-family:Helvetica, Arial, Verdana, sans-serif;color:rgb(37,44,47);">
<div style="margin:10px 0px 0px;font-family:inherit;">Code:</div>
public class SpringApplicationContextHolder implements applicationContextAware {<br>
<br>
static ApplicationContext context;<br><br>
public void setApplicationContext(<br>
ApplicationContext applicationContext) {<br>
context = applicationContext;<br>
}<br><br>
public static void setAppContext(<br>
ApplicationContext applicationContext) {<br>
context = applicationContext;<br>
}<br><br>
public static ApplicationContext getApplicationContext() {<br>
return context;<br>
}<br><br>
public static Object getBean(String name) {<br>
return getApplicationContext().getBean(name);<br>
}<br><br>
}</div>
<p><span style="color:rgb(37,44,47);font-family:Helvetica, Arial, Verdana, sans-serif;font-size:13px;">and create a bean such as bellow:</span></p>
<div style="margin:0px;font-size:13px;font-family:Helvetica, Arial, Verdana, sans-serif;color:rgb(37,44,47);">
<div style="margin:10px 0px 0px;font-family:inherit;">Code:</div>
<bean id="springUtilInitializer"<br>
class="ir.asta.wise.core.util.SpringApplicationContextHolder" lazy-init="false" /></div>
<p><span style="color:rgb(37,44,47);font-family:Helvetica, Arial, Verdana, sans-serif;font-size:13px;">and simply use static method in pojo:</span><br>
</p>
<div style="margin:0px;font-size:13px;font-family:Helvetica, Arial, Verdana, sans-serif;color:rgb(37,44,47);">
<div style="margin:10px 0px 0px;font-family:inherit;">Code:</div>
<p>SpringApplicationContextHolder.getBean("myBean")</p>
<p> </p>
<p>this works for me but maybe there is a better solution anybody knows?</p>
</div>