Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » spring and birt
spring and birt [message #146487] Tue, 21 March 2006 14:01 Go to next message
Eclipse UserFriend
Originally posted by: mishra.vaibhav.gmail.com

Hi,

Instead of accessing the database directly using jdbc datasources, I want
to use some java api. I tried the samples related to scripted datasource
using POJOs.

Now, the problem is that my application uses spring, and the objects can
not be instantiated directly. Instead they have to be accessed through the
web application context like -

///////////////////////////////////////////////
WebApplicationContext ctx =
WebApplicationContextUtils.getRequiredWebApplicationContext( servletContext);
return ctx.getBean(name);
///////////////////////////////////////////////

If I could get servletContext somehow in BIRT, this could be used.
However, I could not find the way to do this.

So, I tried another way which does not requires ServletContext -

///////////////////////////////////////////////
ClassPathXmlApplicationContext appContext = new
ClassPathXmlApplicationContext(
new String[] { "/WEB-INF/web.xml",
"/WEB-INF/applicationContext.xml",
"/WEB-INF/applicationContext-hibernate.xml" });
BeanFactory factory = (BeanFactory) appContext;
return factory.getBean(name);
///////////////////////////////////////////////

The problem is now that when I run the report, BIRT is unable to parse the
web.xml and the cause of exception is -

///////////////////////////////////////////////
Caused by: org.eclipse.birt.data.engine.core.DataException: A BIRT
exception occurred: Error evaluating Javascript expression. Script engine
error: Wrapped
org.springframework.beans.factory.BeanDefinitionStoreExcepti on:
IOException parsing XML document from class path resource
[WEB-INF/web.xml]; nested exception is java.net.ConnectException:
Connection timed out: connect (DataSet[Data Set].__bm_OPEN#2)
///////////////////////////////////////////////

Can anyone suggest something why I am getting this connection timeout?
My web.xml contains following lines in the beginning -

///////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
///////////////////////////////////////////////

Thanks
Vaibhav
Re: spring and birt [message #146497 is a reply to message #146487] Tue, 21 March 2006 14:06 Go to previous messageGo to next message
Cristian Popescu is currently offline Cristian PopescuFriend
Messages: 206
Registered: July 2009
Senior Member
Hi. You can put variables into session and then retrieve them into BIRT
report. Use the report in the same project as the servlet so they can
share the same context.

here's an example of retrieving variables session from a servlet:
/*
my session variable is testSession and is a list of objects of type
DisplayVo (a class with 4 methods get/setFirstString and
get/setSecondString)
*/

ab=reportContext.getHttpServletRequest().getSession().getAtt ribute( "testSession");
this.valueExpr="";
for(var i=0;i<ab.size();i++)
{
bc=ab.get(i);
this.valueExpr+="===== "+bc.getFirstString()+" ====";
this.valueExpr+="===== "+bc.getSecondString()+" ====";
}
Re: spring and birt [message #146703 is a reply to message #146497] Wed, 22 March 2006 06:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mishra.vaibhav.gmail.com

I am able to get servletContext through the way suggested by you, and
hence the classes which are available through servlet context. Thanks.

Now, I am getting following exception (it says '50 more' at last so I am
unable to determine the cause.

I have following code written in DataSet's methods:

open() [this is working fine]
================================================
sampleBean = Packages.sample.ApplicationContext.getBean("sampleBean",
reportContext.getHttpServletRequest().getSession().getServle tContext());

accounts = sampleBean.getAllAccounts();
iter = accounts.iterator();
count=0;

fetch() [I guess there is something wrong with this]
================================================
if(!iter.hasNext()) {
return null;
}

var node = iter.next();

row["username"] = node.getUsername();
row["firstName"] = node.getFirstName();
row["lastName"] = node.getLastName();
row["email"] = node.getEmail();
row["phone"] = node.getPhone();
row["department"] = node.getDepartment();

count++;

return row;
================================================

Following is the stack trace as printed on the browser
================================================
Error0 : Error.UnhandledScriptError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: Unhandled
exception when executing script at
org.eclipse.birt.report.engine.script.internal.ScriptExecuto r.addException(ScriptExecutor.java:210)
at
org.eclipse.birt.report.engine.script.internal.ScriptExecuto r.addException(ScriptExecutor.java:200)
at
org.eclipse.birt.report.engine.script.internal.ScriptDataSet ScriptExecutor.handleFetch(ScriptDataSetScriptExecutor.java: 119)
at
org.eclipse.birt.data.engine.impl.ScriptDataSetRuntime.fetch (ScriptDataSetRuntime.java:84)
at
org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$Scri ptDSQueryExecutor$CustomDataSet.fetch(PreparedScriptDSQuery. java:217)
at
org.eclipse.birt.data.engine.executor.cache.OdiAdapter.fetch (OdiAdapter.java:135)
at
org.eclipse.birt.data.engine.executor.cache.RowResultSet.nex t(RowResultSet.java:85)
at
org.eclipse.birt.data.engine.executor.cache.SmartCache.popul ateData(SmartCache.java:276)
at
org.eclipse.birt.data.engine.executor.cache.SmartCache.initI nstance(SmartCache.java:204)
at
org.eclipse.birt.data.engine.executor.cache.SmartCache.<init >(SmartCache.java:134)
at
org.eclipse.birt.data.engine.executor.CachedResultSet.initOd iResultSet(CachedResultSet.java:1613)
at
org.eclipse.birt.data.engine.executor.CachedResultSet.pass(C achedResultSet.java:1432)
at
org.eclipse.birt.data.engine.executor.CachedResultSet.popula teResultSet(CachedResultSet.java:234)
at
org.eclipse.birt.data.engine.executor.CachedResultSet.<init >(CachedResultSet.java:125)
at
org.eclipse.birt.data.engine.executor.CandidateQuery.execute (CandidateQuery.java:83)
at
org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$Scri ptDSQueryExecutor.executeOdiQuery(PreparedScriptDSQuery.java :183)
at
org.eclipse.birt.data.engine.impl.PreparedQuery$Executor.exe cute(PreparedQuery.java:711)
at
org.eclipse.birt.data.engine.impl.QueryResults.getResultIter ator(QueryResults.java:110)
at
org.eclipse.birt.report.engine.data.dte.DteDataEngine.execut e(DteDataEngine.java:210)
at
org.eclipse.birt.report.engine.executor.QueryItemExecutor.op enResultSet(QueryItemExecutor.java:62)
at
org.eclipse.birt.report.engine.executor.TableItemExecutor.ex ecute(TableItemExecutor.java:122)
at
org.eclipse.birt.report.engine.executor.ReportExecutorVisito r.visitTableItem(ReportExecutorVisitor.java:187)
at
org.eclipse.birt.report.engine.ir.TableItemDesign.accept(Tab leItemDesign.java:69)
at
org.eclipse.birt.report.engine.executor.ReportExecutor.execu te(ReportExecutor.java:125)
at
org.eclipse.birt.report.engine.executor.ReportExecutor.execu te(ReportExecutor.java:89)
at
org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run (RunAndRenderTask.java:175)
at
org.eclipse.birt.report.services.ReportEngineService.runAndR enderReport(Unknown
Source) at
org.eclipse.birt.report.viewer.aggregation.layout.EngineFrag ment.doService(Unknown
Source) at
org.eclipse.birt.report.viewer.aggregation.BaseFragment.serv ice(Unknown
Source) at
org.eclipse.birt.report.viewer.servlet.ViewerServlet.doGet(U nknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697) at
org.apache.axis.transport.http.AxisServletBase.service(AxisS ervletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFi lter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(App licationFilterChain.java:173)
at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(Repl yHeaderFilter.java:81)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFi lter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(App licationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(Standar dWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(Standar dContextValve.java:178)
at
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(Cu stomPrincipalValve.java:39)
at
org.jboss.web.tomcat.security.SecurityAssociationValve.invok e(SecurityAssociationValve.java:153)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(A uthenticatorBase.java:407)
at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccCo ntextValve.java:59)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHo stValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorRepo rtValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(Standard EngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAd apter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Proce ssor.java:856)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHand ler.processConnection(Http11Protocol.java:744)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(Poo lTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(Maste rSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)Caused by:
org.eclipse.birt.data.engine.core.DataException:
data.engine.BadFetchScriptReturnType at
org.eclipse.birt.report.engine.script.internal.ScriptDataSet ScriptExecutor.handleFetch(ScriptDataSetScriptExecutor.java: 109)
... 50 more
Re: spring and birt [message #146730 is a reply to message #146703] Wed, 22 March 2006 07:21 Go to previous message
Eclipse UserFriend
Originally posted by: mishra.vaibhav.gmail.com

Hey, I solved the problem. It was due to wrong return statement in fetch
method.
Now, I correct it as -

============================
if(!iter.hasNext()) {
return false;
}
node = iter.next();

row["username"] = node.getUsername();
row["firstName"] = node.getFirstName();
row["lastName"] = node.getLastName();
row["email"] = node.getEmail();
row["phone"] = node.getPhone();
row["department"] = node.getDepartment();

return true;
============================
Previous Topic:Can Chart Engine use XML chart definitions
Next Topic:deploying to tomcat - Charts not working
Goto Forum:
  


Current Time: Fri Aug 16 21:34:02 GMT 2024

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

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

Back to the top