PDA

View Full Version : Timestamp parameters for JasperReport



mdaleiden
04-13-2006, 12:45 PM
I have a JasperReport that takes two java.sql.Timestamp input parameters (a start date and an end date). I tried setting these up as input parameters of type "string" in my xaction (since there is no "java.sql.Timestamp" parameter type), but the JasperReportsComponent fails with the following error after I enter the parameters:


COMPONENT:context-15749551-1144953109183:my_report.xaction JasperReport.ERROR_0014 - Report execution failed
net.sf.jasperreports.engine.JRException: Incompatible value assigned to parameter StartDate : MyReport

Is there a way to get the parameters transformed into Timestamp objects before they are passed to the JR engine?

Please help.

mdaleiden
04-14-2006, 08:57 AM
Well, I worked around this by changing the input parameters for the report to String types, then converting the entered values to the Timestamp type inside of the JRXML file. It is a little more cumbersome to do it this way, but it gets around the issue and my reports now work with Pentaho.

sarah
10-18-2006, 10:22 AM
I am having the same issue:

net.sf.jasperreports.engine.JRException: Incompatible java.lang.String value assigned to parameter pStartDate in the InvoiceByJobByDatePT2k6 dataset.
at net.sf.jasperreports.engine.fill.JRFillDataset.setParameter(JRFillDataset.java:782)
at net.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:607)
at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:563)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:878)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:689)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:647)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234)
at org.pentaho.plugin.jasperreports.JasperReportsComponent.executeAction(JasperReportsComponent.java:490)
at org.pentaho.plugin.ComponentBase.execute(ComponentBase.java:397)
at org.pentaho.core.runtime.RuntimeContext.executeComponent(RuntimeContext.java:979)
at org.pentaho.core.runtime.RuntimeContext.executeAction(RuntimeContext.java:951)
at org.pentaho.core.runtime.RuntimeContext.performActions(RuntimeContext.java:867)
at org.pentaho.core.runtime.RuntimeContext.executeLoop(RuntimeContext.java:823)
at org.pentaho.core.runtime.RuntimeContext.executeSequence(RuntimeContext.java:729)
at org.pentaho.core.runtime.RuntimeContext.executeSequence(RuntimeContext.java:653)
at org.pentaho.core.solution.SolutionEngine.executeInternal(SolutionEngine.java:251)
at org.pentaho.core.solution.SolutionEngine.execute(SolutionEngine.java:204)
at org.pentaho.core.services.BaseRequestHandler.handleActionRequest(BaseRequestHandler.java:132)
at org.pentaho.ui.servlet.ViewAction.doGet(ViewAction.java:117)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.pentaho.core.system.SystemStatusFilter.doFilter(SystemStatusFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
14:16:57,607 ERROR [JasperReportsComponent] Error end:
14:16:57,607 ERROR [RuntimeContext] d749feca-5ed4-11db-b22f-3b529a82a9fa:RUNTIME:context-9061299-1161195417560:InvoiceByJobByDatePT2k6.xaction RuntimeContext.ERROR_0012 - ActionDefinition for JasperReportsComponent did not execute successfully
14:16:57,614 ERROR [SolutionEngine] d749feca-5ed4-11db-b22f-3b529a82a9fa:SOLUTION-ENGINE:InvoiceByJobByDatePT2k6.xaction: SolutionEngine.ERROR_0007 - Action sequence execution failed
14:17:34,382 ERROR [RuntimeContext] ed3a4c3b-5ed4-11db-b22f-3b529a82a9fa:RUNTIME:context-20169696-1161195454367:InvoiceByJobByDatePT2k6.xaction RuntimeContext.ERROR_0018 - The requested parameter "pStartDate" has a NULL value
14:17:34,383 ERROR [RuntimeContext] ed3a4c3b-5ed4-11db-b22f-3b529a82a9fa:RUNTIME:context-20169696-1161195454367:InvoiceByJobByDatePT2k6.xaction RuntimeContext.ERROR_0013 - Parameters could not be resolved
14:17:34,383 ERROR [SolutionEngine] ed3a4c3b-5ed4-11db-b22f-3b529a82a9fa:SOLUTION-ENGINE:InvoiceByJobByDatePT2k6.xaction: SolutionEngine.ERROR_0007 - Action sequence execution failed
14:18:10,111 INFO [RuntimeContext] Ignoring input "output-type" to the conditional execution becuase it has a "-" in the name.
14:18:12,176 INFO [RuntimeContext] Ignoring input "output-type" to the conditional execution becuase it has a "-" in the name.
14:18:17,935 INFO [RuntimeContext] Ignoring input "output-type" to the conditional execution becuase it has a "-" in the name.
14:18:17,966 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Cannot open database requested in login 'ms_project]'. Login fails.)
at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:177)
at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:539)
at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:228)
at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:417)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:324)
at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:301)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:379)
at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:812)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
at org.pentaho.plugin.jasperreports.JasperReportsComponent.getConnection(JasperReportsComponent.java:549)
at org.pentaho.plugin.jasperreports.JasperReportsComponent.executeAction(JasperReportsComponent.java:474)
at org.pentaho.plugin.ComponentBase.execute(ComponentBase.java:397)
at org.pentaho.core.runtime.RuntimeContext.executeComponent(RuntimeContext.java:979)
at org.pentaho.core.runtime.RuntimeContext.executeAction(RuntimeContext.java:951)
at org.pentaho.core.runtime.RuntimeContext.performActions(RuntimeContext.java:867)
at org.pentaho.core.runtime.RuntimeContext.executeLoop(RuntimeContext.java:823)
at org.pentaho.core.runtime.RuntimeContext.executeSequence(RuntimeContext.java:729)
at org.pentaho.core.runtime.RuntimeContext.executeSequence(RuntimeContext.java:653)
at org.pentaho.core.solution.SolutionEngine.executeInternal(SolutionEngine.java:251)
at org.pentaho.core.solution.SolutionEngine.execute(SolutionEngine.java:204)
at org.pentaho.core.services.BaseRequestHandler.handleActionRequest(BaseRequestHandler.java:132)
at org.pentaho.ui.servlet.ViewAction.doGet(ViewAction.java:117)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.pentaho.core.system.SystemStatusFilter.doFilter(SystemStatusFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: Cannot open database requested in login 'ms_project]'. Login fails.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:599)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:331)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:178)
at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:169)
... 45 more
14:18:17,973 ERROR [JasperReportsComponent] Error Start: Pentaho 1.2.0 build 398 RC2


I have a number of reports using java.sql.Timestamp and would rather not have to modify them.

mbatchelor
10-19-2006, 07:00 AM
You may want to try creating a Javascript rule that accepts as input the string parameter, and creates Date objects from them.

It's relatively simple to create date objects in a javascript rule. If you're using RC2 or later, one javascript rule can be used for all the date conversions easily.

Take care,

Marc

sarah
10-20-2006, 07:28 AM
Running on Server Version 1.2.0 build 398 RC2

I created a javascript rule and have attempted to call it from another xaction, but I am not getting input prompts as expected and receive "org.mozilla.javascript.NativeDate@37f6bf" or similar as output.

It seems like it should ask me for the date string before it even attempts this:

<pStart type="string">
<default-value/>
<sources>
<request>pStart</request>
</sources>
</pStart>

Conversion is attempted as follows:

<action-definition>
<component-name>SubActionComponent</component-name>
<action-inputs>
<pStart type="string"/>
</action-inputs>
<action-outputs>
<pStartDate type="date"/>
</action-outputs>
<component-definition>
<solution>conversions</solution>
<path></path>
<action>stringToDate.xaction</action>
</component-definition>
</action-definition>


The follow is in the Pentaho logs:

11:24:11,481 ERROR [RuntimeContext] 09705087-604f-11db-a105-136bf933f4bf:RUNTIME:context-2221905-1161357851460:«»stringToDate.xaction RuntimeContext.ERROR_0021 - Invalid output parameter "pStartDate" requested during execution of stringToDate.xaction
11:24:11,482 ERROR [SubActionComponent] 096cf526-604f-11db-a105-136bf933f4bf:COMPONENT:context-11911659-1161357851439:VIByJobPT2k6.xaction Base.ERROR_0002 - Component execution failed
11:24:11,482 ERROR [RuntimeContext] 096cf526-604f-11db-a105-136bf933f4bf:RUNTIME:context-11911659-1161357851439:VIByJobPT2k6.xaction RuntimeContext.ERROR_0012 - ActionDefinition for SubActionComponent did not execute successfully
11:24:11,482 ERROR [SolutionEngine] 096cf526-604f-11db-a105-136bf933f4bf:«»SOLUTION-ENGINE:VIByJobPT2k6.xaction: SolutionEngine.ERROR_0007 - Action sequence execution failed

I need a way to generalize the output from the conversion xaction, as I need to call the conversion for both the start and end date. The example on http://forums.pentaho.org/showthread.php?t=26397 is similar, but it does not seem like sessions variables will suffice.
http://forums.pentaho.org/archived_att/files/stringToDate.xaction