Jump to content
We've recently updated our Privacy Statement, available here ×

Problem:report compilation on Tomcat/Eclipse


2005 IR Help

Recommended Posts

By: ziggy - zarthstar

Problem:report compilation on Tomcat/Eclipse

2004-11-16 08:34

Hi all,

 

I'm having some newbie problems compiling a report. I am trying to build a simple servlet that compiles and then renders a simple report.

 

Config:

 

Tomcat 4.1.2

Windows XP

 

I'm using Tomcat under Eclipse and getting some strange failures that look related to Eclipse. I think this is a configuration issue, but I'm not sure.

 

Basically, at run time I hit against my report servlet (code below along with report definition). However, I get the following errors during report compilation in the Eclipse console window:

 

<i>

C:eclipseAccoloEeo.java:4: package net.sf.jasperreports.engine does not exist

import net.sf.jasperreports.engine.*;

^

C:eclipseAccoloEeo.java:5: package net.sf.jasperreports.engine.fill does not exist

import net.sf.jasperreports.engine.fill.*;

^

C:eclipseAccoloEeo.java:17: cannot resolve symbol

symbol : class JRCalculator

location: class AccoloEeo

public class AccoloEeo extends JRCalculator

^

C:eclipseAccoloEeo.java:24: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

private JRFillParameter parameter_BaseDir = null;

^

C:eclipseAccoloEeo.java:25: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

private JRFillParameter parameter_REPORT_CONNECTION = null;

^

C:eclipseAccoloEeo.java:26: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

private JRFillParameter parameter_REPORT_PARAMETERS_MAP = null;

^

C:eclipseAccoloEeo.java:27: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

private JRFillParameter parameter_ReportTitle = null;

^

C:eclipseAccoloEeo.java:28: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

private JRFillParameter parameter_REPORT_DATA_SOURCE = null;

^

C:eclipseAccoloEeo.java:29: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

private JRFillParameter parameter_REPORT_SCRIPTLET = null;

^

C:eclipseAccoloEeo.java:31: cannot resolve symbol

symbol : class JRFillField

location: class AccoloEeo

private JRFillField field_Gender = null;

^

C:eclipseAccoloEeo.java:32: cannot resolve symbol

symbol : class JRFillField

location: class AccoloEeo

private JRFillField field_Ethnicity = null;

^

C:eclipseAccoloEeo.java:34: cannot resolve symbol

symbol : class JRFillVariable

location: class AccoloEeo

private JRFillVariable variable_PAGE_NUMBER = null;

^

C:eclipseAccoloEeo.java:35: cannot resolve symbol

symbol : class JRFillVariable

location: class AccoloEeo

private JRFillVariable variable_COLUMN_NUMBER = null;

^

C:eclipseAccoloEeo.java:36: cannot resolve symbol

symbol : class JRFillVariable

location: class AccoloEeo

private JRFillVariable variable_REPORT_COUNT = null;

^

C:eclipseAccoloEeo.java:37: cannot resolve symbol

symbol : class JRFillVariable

location: class AccoloEeo

private JRFillVariable variable_PAGE_COUNT = null;

^

C:eclipseAccoloEeo.java:38: cannot resolve symbol

symbol : class JRFillVariable

location: class AccoloEeo

private JRFillVariable variable_COLUMN_COUNT = null;

^

C:eclipseAccoloEeo.java:48: cannot resolve symbol

symbol : class JRException

location: class AccoloEeo

) throws JRException

^

C:eclipseAccoloEeo.java:50: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

parameter_BaseDir = (JRFillParameter)parsm.get("BaseDir");

^

C:eclipseAccoloEeo.java:50: cannot resolve symbol

symbol : variable parsm

location: class AccoloEeo

parameter_BaseDir = (JRFillParameter)parsm.get("BaseDir");

^

C:eclipseAccoloEeo.java:51: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

parameter_REPORT_CONNECTION = (JRFillParameter)parsm.get("REPORT_CONNECTION");

^

C:eclipseAccoloEeo.java:51: cannot resolve symbol

symbol : variable parsm

location: class AccoloEeo

parameter_REPORT_CONNECTION = (JRFillParameter)parsm.get("REPORT_CONNECTION");

^

C:eclipseAccoloEeo.java:52: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

parameter_REPORT_PARAMETERS_MAP = (JRFillParameter)parsm.get("REPORT_PARAMETERS_MAP");

^

C:eclipseAccoloEeo.java:52: cannot resolve symbol

symbol : variable parsm

location: class AccoloEeo

parameter_REPORT_PARAMETERS_MAP = (JRFillParameter)parsm.get("REPORT_PARAMETERS_MAP");

^

C:eclipseAccoloEeo.java:53: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

parameter_ReportTitle = (JRFillParameter)parsm.get("ReportTitle");

^

C:eclipseAccoloEeo.java:53: cannot resolve symbol

symbol : variable parsm

location: class AccoloEeo

parameter_ReportTitle = (JRFillParameter)parsm.get("ReportTitle");

^

C:eclipseAccoloEeo.java:54: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

parameter_REPORT_DATA_SOURCE = (JRFillParameter)parsm.get("REPORT_DATA_SOURCE");

^

C:eclipseAccoloEeo.java:54: cannot resolve symbol

symbol : variable parsm

location: class AccoloEeo

parameter_REPORT_DATA_SOURCE = (JRFillParameter)parsm.get("REPORT_DATA_SOURCE");

^

C:eclipseAccoloEeo.java:55: cannot resolve symbol

symbol : class JRFillParameter

location: class AccoloEeo

parameter_REPORT_SCRIPTLET = (JRFillParameter)parsm.get("REPORT_SCRIPTLET");

^

C:eclipseAccoloEeo.java:55: cannot resolve symbol

symbol : variable parsm

location: class AccoloEeo

parameter_REPORT_SCRIPTLET = (JRFillParameter)parsm.get("REPORT_SCRIPTLET");

^

C:eclipseAccoloEeo.java:57: cannot resolve symbol

symbol : class JRFillField

location: class AccoloEeo

field_Gender = (JRFillField)fldsm.get("Gender");

^

C:eclipseAccoloEeo.java:57: cannot resolve symbol

symbol : variable fldsm

location: class AccoloEeo

field_Gender = (JRFillField)fldsm.get("Gender");

^

C:eclipseAccoloEeo.java:58: cannot resolve symbol

symbol : class JRFillField

location: class AccoloEeo

field_Ethnicity = (JRFillField)fldsm.get("Ethnicity");

^

C:eclipseAccoloEeo.java:58: cannot resolve symbol

symbol : variable fldsm

location: class AccoloEeo

field_Ethnicity = (JRFillField)fldsm.get("Ethnicity");

^

C:eclipseAccoloEeo.java:60: cannot resolve symbol

symbol : class JRFillVariable

location: class AccoloEeo

variable_PAGE_NUMBER = (JRFillVariable)varsm.get("PAGE_NUMBER");

^

C:eclipseAccoloEeo.java:60: cannot resolve symbol

symbol : variable varsm

location: class AccoloEeo

variable_PAGE_NUMBER = (JRFillVariable)varsm.get("PAGE_NUMBER");

^

C:eclipseAccoloEeo.java:61: cannot resolve symbol

symbol : class JRFillVariable

location: class AccoloEeo

variable_COLUMN_NUMBER = (JRFillVariable)varsm.get("COLUMN_NUMBER");

^

C:eclipseAccoloEeo.java:61: cannot resolve symbol

symbol : variable varsm

location: class AccoloEeo

variable_COLUMN_NUMBER = (JRFillVariable)varsm.get("COLUMN_NUMBER");

^

C:eclipseAccoloEeo.java:62: cannot resolve symbol

symbol : class JRFillVariable

location: class AccoloEeo

variable_REPORT_COUNT = (JRFillVariable)varsm.get("REPORT_COUNT");

^

C:eclipseAccoloEeo.java:62: cannot resolve symbol

symbol : variable varsm

location: class AccoloEeo

variable_REPORT_COUNT = (JRFillVariable)varsm.get("REPORT_COUNT");

^

C:eclipseAccoloEeo.java:63: cannot resolve symbol

symbol : class JRFillVariable

location: class AccoloEeo

variable_PAGE_COUNT = (JRFillVariable)varsm.get("PAGE_COUNT");

^

C:eclipseAccoloEeo.java:63: cannot resolve symbol

symbol : variable varsm

location: class AccoloEeo

variable_PAGE_COUNT = (JRFillVariable)varsm.get("PAGE_COUNT");

^

C:eclipseAccoloEeo.java:64: cannot resolve symbol

symbol : class JRFillVariable

location: class AccoloEeo

variable_COLUMN_COUNT = (JRFillVariable)varsm.get("COLUMN_COUNT");

^

C:eclipseAccoloEeo.java:64: cannot resolve symbol

symbol : variable varsm

location: class AccoloEeo

variable_COLUMN_COUNT = (JRFillVariable)varsm.get("COLUMN_COUNT");

^

C:eclipseAccoloEeo.java:95: inconvertible types

found : java.lang.String

required: java.lang.Integer

value = (java.lang.Integer)(((java.lang.String)field_Ethnicity.getValue()));

^

C:eclipseAccoloEeo.java:178: inconvertible types

found : java.lang.String

required: java.lang.Integer

value = (java.lang.Integer)(((java.lang.String)field_Ethnicity.getOldValue()));

^

C:eclipseAccoloEeo.java:261: inconvertible types

found : java.lang.String

required: java.lang.Integer

value = (java.lang.Integer)(((java.lang.String)field_Ethnicity.getValue()));

^

46 errors

</i>

 

<b>Servlet Code</b>

public class ReportEngineServlet extends HttpServlet

{

 

private BaseDao baseDao = new BaseDao();

 

public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException

{

ServletContext context = this.getServletConfig().getServletContext();

 

Connection conn = null;

 

response.setContentType("text/html");

PrintWriter out = response.getWriter();

 

try

{

conn = baseDao.getConnection();

 

JasperCompileManager.compileReportToFile(context.getRealPath("/Reports/EeoReport.jrxml"));

 

File reportFile = new File(context.getRealPath("/Reports/EeoReport.jasper"));

 

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());

 

Map parameters = new HashMap();

parameters.put("ReportTitle", "Address Report");

parameters.put("BaseDir", reportFile.getParentFile());

 

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);

 

JRHtmlExporter exporter = new JRHtmlExporter();

 

Map imagesMap = new HashMap();

request.getSession().setAttribute("IMAGES_MAP", imagesMap);

 

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);

exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image=");

 

exporter.exportReport();

}

 

<b>Report Definition</b>

<?xml version="1.0" encoding="UTF-8"?>

<!-- Created using an evaluation version of JasperAssistant (http://www.jasperassistant.com) -->

<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

 

<jasperReport name="AccoloEeo" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50">

<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>

<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>

<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/>

<parameter name="ReportTitle" class="java.lang.String">

</parameter>

<parameter name="BaseDir" class="java.io.File">

</parameter>

<queryString><![CDATA[sELECT ETHNICITY, GENDER FROM EEO]]></queryString>

<field name="Ethnicity" class="java.lang.String">

</field>

<field name="Gender" class="java.lang.String">

</field>

<title>

<band height="50">

<line>

<reportElement x="0" y="0" width="515" height="1"/>

<graphicElement/>

</line>

<textField isBlankWhenNull="true">

<reportElement x="170" y="10" width="345" height="30"/>

<textElement textAlignment="Right">

<font reportFont="Arial_Normal" size="22"/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$P{ReportTitle}]]></textFieldExpression>

</textField>

</band>

</title>

<pageHeader>

<band height="20">

<rectangle>

<reportElement x="0" y="5" width="515" height="15" forecolor="#333333" backcolor="#333333"/>

<graphicElement/>

</rectangle>

<staticText>

<reportElement mode="Opaque" x="0" y="5" width="55" height="15" forecolor="#ffffff" backcolor="#333333"/>

<textElement textAlignment="Center">

<font reportFont="Arial_Bold"/>

</textElement>

<text><![CDATA[Ethnicity]]></text>

</staticText>

<staticText>

<reportElement mode="Opaque" x="55" y="5" width="205" height="15" forecolor="#ffffff" backcolor="#333333"/>

<textElement>

<font reportFont="Arial_Bold"/>

</textElement>

<text><![CDATA[Gender]]></text>

</staticText>

</band>

</pageHeader>

<detail>

<band height="20">

<textField>

<reportElement x="3" y="3" width="104" height="15"/>

<textElement textAlignment="Right"/>

<textFieldExpression class="java.lang.Integer"><![CDATA[$F{Ethnicity}]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="true">

<reportElement positionType="Float" x="129" y="4" width="126" height="15"/>

<textElement/>

<textFieldExpression class="java.lang.String"><![CDATA[$F{Gender}]]></textFieldExpression>

</textField>

<line>

<reportElement positionType="Float" x="0" y="19" width="515" height="1" forecolor="#808080"/>

<graphicElement/>

</line>

</band>

</detail>

<pageFooter>

<band height="40">

<line>

<reportElement x="0" y="10" width="515" height="1"/>

<graphicElement/>

</line>

<textField>

<reportElement x="200" y="20" width="80" height="15"/>

<textElement textAlignment="Right"/>

<textFieldExpression class="java.lang.String"><![CDATA["Page " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></textFieldExpression>

</textField>

<textField evaluationTime="Report">

<reportElement x="280" y="20" width="75" height="15"/>

<textElement/>

<textFieldExpression class="java.lang.String"><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression>

</textField>

</band>

</pageFooter>

<summary>

<band height="80">

</band>

</summary>

</jasperReport>

 

Thanks,

 

Seth

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...