Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1016801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:36:09+00:00 2026-05-16T10:36:09+00:00

I’m working on a web application written in Java using the Tapestry 5.1.0.5 framework.

  • 0

I’m working on a web application written in Java using the Tapestry 5.1.0.5 framework. This framework does not have out-of-the-box support for JasperReports, so I wrote a service that modifies ChenilleKit’s JasperReport service. I do not depend on the ChenilleKit version, instead I use the JasperReport 3.5.0 dependency. This may not be necessary information, but it never hurts to be specific.

Anyway, my service works pretty well. I have it built into the webapp and I am able to compile and output basic reports in PDF, XLS, HTML, and CSV formats. However, I’m having a big issue with getting the SQL in the jasperReport XML file(s) to load the parameter map properly.

I get the following error when trying to run reports with startdate and enddate parameters.

SQLException: Missing IN or OUT parameter at index:: 1

SQL knowledge would say this means I have some form of parameter that is not being passed into the SQL. Debug statements indicate to me that I am passing in the parameters alright and that at least some are making their way into the XML report.

For example, I am passing three parameters into a report, Title, StartDate, and EndDate. Title shows up in the rendering of reports, but StartDate and EndDate seem to get lost in translation?

I’m not sure what I’m missing because nearly identical code works in my company’s JSP-Tomcat-Servlet based application with JasperReports.

Anyway I’ll start showing code and explaining what’s going on:

public StreamResponse getReport(String reportTitle, ExportFormat formMode, Date startDate, Date endDate) {
    Map<String,String> parameterMap = loadParameters(reportTitle);
    Connection conn = null;
    OutputStream os = new ByteArrayOutputStream();

    try{
        conn = Report.getConnection();

        Resource resc = new ContextResource(cimpl, "src/main/webapp/reports/"+reportTitle+".xml");

        log.debug("Calling fillAndExport to fetch the report " + reportTitle);
        log.debug("resource="+resc+"\n"+"formMode="+formMode+"\n"+"parameterMap="+parameterMap+"\n"+"conn="+conn+"\n"+
                "outputStream="+os);

        SimpleDateFormat repDate = new SimpleDateFormat("MM/dd/yyyy HH:mm");
        parameterMap.put("StartDate", repDate.format(startDate));
        parameterMap.put("EndDate", repDate.format(endDate));

        log.debug("StartDate into report: " + parameterMap.get("StartDate"));
        log.debug("EndDate into report: " + parameterMap.get("EndDate"));

        js.fillAndExport(resc, formMode, parameterMap, conn, os);
        SimpleDateFormat sdf = new SimpleDateFormat("MMMddyyyy");

        return new JasperStreamResponse((ByteArrayOutputStream) os, formMode, reportTitle+"-"+sdf.format(startDate)+"-"
                +sdf.format(endDate));
    }catch (Exception e){
        log.error("Caught exception while trying to execute the report fillAndExport service method.");
        throw new TapestryException("Issue executing report", e);
    } finally {
        if(conn != null){
            try {
                conn.close();
            } catch (SQLException e) {
                System.out.println("Could not close the JDBC connection!!");
            }
        }
    }
}

In a nutshell, I load the report resource, and add the StartDate and EndDate parameters (Title is already in the parameterMap). I then make the call to a JasperService that uses fillAndExport to generate the report. If there are no exceptions it is returned to the browser in a stream.

Here is accompanying debug statements for a given time I get the exception:

[DEBUG] AppModule.ReportService Loaded report class: com.moremagic.reports.TriggerReport
[DEBUG] AppModule.ReportService Calling fillAndExport to fetch the report Trigger
[DEBUG] AppModule.ReportService resource=context:src/main/webapp/reports/Trigger.xml
formMode=HTML
parameterMap={Title=Triggering Merchant Commission}
conn=oracle.jdbc.driver.T4CConnection@7c974e4b
outputStream=
[DEBUG] AppModule.ReportService StartDate into report: 08/22/2010 14:19
[DEBUG] AppModule.ReportService EndDate into report: 08/23/2010 14:19
[DEBUG] AppModule.JasperService Constructed configuration: {}
[DEBUG] AppModule.JasperService Invoking method com.moremagic.services.AppModule.buildJasperService(Logger, Map) (at AppModule.java:188).
[DEBUG] AppModule.JasperService Using template -> src/main/webapp/reports/Trigger.xml
[DEBUG] AppModule.JasperService In fillReport, parameterMap is : {EndDate=08/23/2010 14:31, StartDate=08/22/2010 14:31, Title=Triggering Merchant Commission}

[ERROR] AppModule.JasperService Caught exception in fillReport of ReportsServiceImpl {}
net.sf.jasperreports.engine.JRException: Error executing SQL statement for : WebappReport1
Caused by: java.sql.SQLException: Missing IN or OUT parameter at index:: 1

So as you can see the values are in the parameter map all the way through right until the JasperService calls the JapserReports API. Now I will show the JasperService code and some of the report so you can see the SQL breaking things.

JasperService:

/**
 * Fills the report design loaded from the supplied input resource and returns the generated report object.
 * <p/>
 * if parameter <em>jasperPrint<em> not null, the data filled into <em>jasperPrint</em>
 * instead of returns a new jasper print object.
 *
 * @param jasperPrint
 * @param inputResource the input resource (report template file ".jrxml")
 * @param parameterMap  the parameter map
 * @param dataSource    the datasource, either a JRDataSource or an SQL JDBC Connection.
 *
 * @return
 */
public JasperPrint fillReport(JasperPrint jasperPrint, Resource inputResource, Map parameterMap, Object dataSource) throws JRException
{
    JasperReport jasperReport = doCompileReportSource(inputResource);
    JasperPrint actualJasperPrint;

    logger.debug("In fillReport, parameterMap is : " + parameterMap + "\n startDate: " + parameterMap.get("StartDate") + "\n endDate: " + parameterMap.get("EndDate"));

    try
    {
        if (dataSource != null && dataSource instanceof JRDataSource)
            actualJasperPrint = JasperFillManager.fillReport(jasperReport, parameterMap, (JRDataSource) dataSource);
        else if(dataSource != null && dataSource instanceof Connection)
            actualJasperPrint = JasperFillManager.fillReport(jasperReport, parameterMap, (Connection) dataSource);
        else
            actualJasperPrint = JasperFillManager.fillReport(jasperReport, parameterMap);

        if (jasperPrint != null)
        {
            for (Object page : actualJasperPrint.getPages())
                jasperPrint.addPage((JRPrintPage) page);
        }
        else
            jasperPrint = actualJasperPrint;

        return jasperPrint;
    }
    catch (JRException e)
    {
        logger.error("Caught exception in fillReport of ReportsServiceImpl {}", e);
        throw new JRException(e);
    }
}

Report:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" 
 "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport 
    name="WebappReport1" 
    pageWidth="595" 
    pageHeight="842" 
    columnWidth="555" 
    columnSpacing="0" 
    leftMargin="20" 
    rightMargin="20" 
    topMargin="30" 
    whenNoDataType="AllSectionsNoDetail"
    bottomMargin="30"> 
<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="9" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="9" isBold="true" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="9" isItalic="true" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<parameter name="Title" class="java.lang.String"/>
<parameter name="StartDate" class="java.lang.String" />
<parameter name="EndDate" class="java.lang.String" />


<!--This is report query string used to fill data-->
<queryString><![CDATA[
SELECT 
something
from table b
    where
b.ba_timestamp between to_date( $P!{StartDate}, 'MM/DD/YYYY HH24:MI' ) and to_date( $P!{EndDate}, 'MM/DD/YYYY HH24:MI' )+1 
]]></queryString>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:36:10+00:00Added an answer on May 16, 2026 at 10:36 am

    I think you should either remove the ! in the SQL query or surround your parameters with quotes.

    In a jasper query $P{xyz} creates and binds a parameter whereas $P!{xyz} modifies the query string. I think that in your case you’re creating an invalid query by appending raw (unquoted) parameters.

    More details in this blog post

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I know there's a lot of other questions out there that deal with this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.