Alo pessoal estou comecando a fazer Relatorios com o Jasper report e estou tendo um erro que nao consigo resolver ajuda aiii.
Tento cchamar o meu report atraves do eclipse e dame o seguinte erro
Caused by: java.lang.ClassCastException: java.util.GregorianCalendar cannot be cast to java.sql.Timestamp
ai vao minhas classes.
Classe estabelecimento
package mz.co.mpteventos.springsecurity.model;
import java.util.Calendar;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
public class Estabelecimento {
@Id
@GeneratedValue
private Integer id;
private String nomeEstabelecimento;
private String descricaoEstabelecimento;
@Temporal(TemporalType.TIMESTAMP)
private Calendar dataEhoradeOperacaoInicio = Calendar.getInstance();
@Temporal(TemporalType.TIMESTAMP)
private Calendar dataEhoradeOperacaoFim = Calendar.getInstance();
@OneToOne
private Contacto contacto;
@OneToOne
private Local local;
@ManyToOne
private Conta conta;
@OneToMany
private List<Imagem> imagem;
// getters & setters
public Contacto getContacto() {
return contacto;
}
public void setContacto(Contacto contacto) {
this.contacto = contacto;
}
public Integer getId() {
return id;
}
public String getNomeEstabelecimento() {
return nomeEstabelecimento;
}
public void setNomeEstabelecimento(String nomeEstabelecimento) {
this.nomeEstabelecimento = nomeEstabelecimento;
}
public Local getLocal() {
return local;
}
public void setLocal(Local local) {
this.local = local;
}
public void setId(Integer id) {
this.id = id;
}
public String getDescricaoEstabelecimento() {
return descricaoEstabelecimento;
}
public void setDescricaoEstabelecimento(String descricaoEstabelecimento) {
this.descricaoEstabelecimento = descricaoEstabelecimento;
}
public Calendar getDataEhoradeOperacaoInicio() {
return dataEhoradeOperacaoInicio;
}
public void setDataEhoradeOperacaoInicio(Calendar dataEhoradeOperacaoInicio) {
this.dataEhoradeOperacaoInicio = dataEhoradeOperacaoInicio;
}
public Calendar getDataEhoradeOperacaoFim() {
return dataEhoradeOperacaoFim;
}
public void setDataEhoradeOperacaoFim(Calendar dataEhoradeOperacaoFim) {
this.dataEhoradeOperacaoFim = dataEhoradeOperacaoFim;
}
public Conta getConta() {
return conta;
}
public void setConta(Conta conta) {
this.conta = conta;
}
public List<Imagem> getImagem() {
return imagem;
}
public void setImagem(List<Imagem> imagem) {
this.imagem = imagem;
}
// gets para relatorio
public Object getAvenida() {
return getLocal().getAvenida();
}
public Object getTelefone() {
return getContacto().getTelefone();
}
public Object getCelular_principal() {
return getContacto().getCelular_principal();
}
public Object getEmail() {
return getContacto().getEmail();
}
}
Meu bean (apenas o metodo do bean que uso para criar o relatorio)
public void imprimirRelatorioListaEstabelecimento() throws JRException, SQLException{
// compilacao do JRXML
JasperReport report = JasperCompileManager
.compileReport("C:/Users/hamil/workspace/springsecurity/src/RelatorioListaEstabelecimentos.jrxml");
System.out.println("Passei");
// preenchimento do relatorio, note que o metodo recebe 3 parametros:
// 1 - o relatorio
//
// 2 - um Map, com parametros que sao passados ao relatorio
// no momento do preenchimento. No nosso caso eh null, pois nao
// estamos usando nenhum parametro
//
// 3 - o data source. Note que nao devemos passar a lista diretamente,
// e sim "transformar" em um data source utilizando a classe
// JRBeanCollectionDataSource
JasperPrint print = JasperFillManager.fillReport(report, null,
new JRBeanCollectionDataSource(listaEstabelecimentos));
// exportacao do relatorio para outro formato, no caso PDF
JasperExportManager.exportReportToPdfFile(print,
"C:/Users/hamil/workspace/springsecurity/src/RelatorioListaEstabelecimentos.pdf");
System.out.println("Relatório gerado.");
}
O XML do relatorio ()retirado do proprio jasper studio - nota que la no jasper tudo funciona bem, apenas no eclipse e que da o erro
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Report_ListaEstabelecimento" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" whenResourceMissingType="Empty" uuid="c368610e-5bee-4e75-8f1e-ecda64380534">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="47"/>
<property name="ireport.y" value="451"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="MPTEventosAdapter"/>
<style name="Title" forecolor="#FFFFFF" fontName="Times New Roman" fontSize="50" isBold="false"/>
<style name="SubTitle" forecolor="#666666" fontName="Times New Roman" fontSize="18" isBold="false"/>
<style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true"/>
<style name="Detail" mode="Transparent" fontName="Times New Roman"/>
<style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style mode="Opaque" backcolor="#F0EFEF"/>
</conditionalStyle>
</style>
<subDataset name="PieChartDataset" uuid="21b70311-b650-4678-a39c-887917366bf0"/>
<queryString language="SQL">
<![CDATA[select es.id, es.nomeEstabelecimento, es.dataEhoradeOperacaoFim, es.dataEhoradeOperacaoInicio, loc.avenida, con.telefone, con.celular_principal, con.email from estabelecimento as es join local as loc on es.local_id=loc.id join contacto as con on es.contacto_id=con.id ORDER BY es.id]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<field name="nomeEstabelecimento" class="java.lang.String"/>
<field name="dataEhoradeOperacaoFim" class="java.sql.Timestamp"/>
<field name="dataEhoradeOperacaoInicio" class="java.sql.Timestamp"/>
<field name="avenida" class="java.lang.String"/>
<field name="telefone" class="java.lang.String"/>
<field name="celular_principal" class="java.lang.String"/>
<field name="email" class="java.lang.String"/>
<group name="Group1">
<groupExpression><![CDATA[$F{id}]]></groupExpression>
<groupHeader>
<band height="31">
<frame>
<reportElement mode="Opaque" x="0" y="7" width="802" height="24" forecolor="#B89F7D" backcolor="#70A9C6" uuid="f4dcb66c-b415-4c03-b80f-d37cc7d7e4f1"/>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="SubTitle" isPrintRepeatedValues="false" x="0" y="1" width="262" height="23" forecolor="#FFFFFF" uuid="28a206df-70e0-4131-ac68-390d711bd9c4"/>
<textElement>
<font fontName="Arial" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
</textField>
</frame>
</band>
</groupHeader>
<groupFooter>
<band/>
</groupFooter>
</group>
<background>
<band height="555" splitType="Stretch"/>
</background>
<title>
<band height="106" splitType="Stretch">
<staticText>
<reportElement style="SubTitle" x="380" y="65" width="422" height="29" uuid="0dae0af3-dd1d-4b42-b346-386af21f0689"/>
<textElement textAlignment="Right">
<font size="22" isBold="false"/>
</textElement>
<text><![CDATA[Lista de Estabelecimentos]]></text>
</staticText>
<frame>
<reportElement mode="Opaque" x="120" y="0" width="682" height="65" forecolor="#006699" backcolor="#006699" uuid="83f5e806-cc04-4161-87a9-07633f604bc1"/>
<staticText>
<reportElement style="Title" x="100" y="0" width="580" height="65" uuid="f5cd9ee0-5caa-4e48-8946-c7e84d82a845"/>
<textElement textAlignment="Right">
<font size="54" isBold="false"/>
</textElement>
<text><![CDATA[Relatório]]></text>
</staticText>
<image scaleImage="RetainShape" hAlign="Center" vAlign="Middle">
<reportElement positionType="Float" mode="Transparent" x="-120" y="0" width="120" height="65" uuid="9c777b86-81de-4684-9d68-b98911ae0f78">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="net.sf.jasperreports.export.xls.auto.fit.column" value="true"/>
</reportElement>
<imageExpression><![CDATA["C:/Users/hamil/workspace/springsecurity/WebContent/resources/img/mpteventos.jpg"]]></imageExpression>
</image>
</frame>
</band>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="14" splitType="Stretch">
<frame>
<reportElement x="0" y="0" width="802" height="14" uuid="2a3d298d-90eb-4db1-919a-c9b2ed28c222"/>
<staticText>
<reportElement style="Column header" positionType="Float" x="220" y="0" width="60" height="14" forecolor="#000000" uuid="a84703ec-66fc-4297-928e-4a5e79e56c2b"/>
<textElement>
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Hora Fim]]></text>
</staticText>
<staticText>
<reportElement style="Column header" positionType="Float" x="130" y="0" width="70" height="14" forecolor="#000000" uuid="35c2dc5e-b713-4420-a9df-57dd994c2ee8"/>
<textElement>
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Hora Inicio]]></text>
</staticText>
<staticText>
<reportElement style="Column header" positionType="Float" x="0" y="0" width="130" height="14" forecolor="#000000" uuid="a3639bc6-42cd-499d-8ad4-bea56710bf0f"/>
<textElement>
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Estabelecimento]]></text>
</staticText>
<staticText>
<reportElement style="Column header" positionType="Float" x="670" y="0" width="120" height="14" forecolor="#000000" uuid="e3b5b871-650c-4aff-bd3f-3367e07f8ee2"/>
<textElement>
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Avenida]]></text>
</staticText>
<staticText>
<reportElement style="Column header" positionType="Float" x="290" y="0" width="100" height="14" forecolor="#000000" uuid="46a9d2c0-f51c-4ae2-9660-bfd979707ffb"/>
<textElement>
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Telefone]]></text>
</staticText>
<staticText>
<reportElement style="Column header" positionType="Float" x="400" y="0" width="110" height="14" forecolor="#000000" uuid="aaac7faf-00c4-4e54-b0c8-26c620feb544"/>
<textElement>
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Celular Principal]]></text>
</staticText>
<staticText>
<reportElement style="Column header" positionType="Float" x="520" y="0" width="130" height="14" forecolor="#000000" uuid="1f3f56a0-5ff0-43e8-91b1-57225799f377"/>
<textElement>
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[E-mail]]></text>
</staticText>
</frame>
</band>
</columnHeader>
<detail>
<band height="19" splitType="Stretch">
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="15" width="802" height="1" uuid="ad4e998c-7071-4467-b7fa-4441cc53d3f6"/>
</line>
<frame>
<reportElement x="0" y="0" width="802" height="14" uuid="822bafe9-34ee-4b4f-aa76-3eae029c4911"/>
<textField isStretchWithOverflow="true" pattern="h:mm a" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="220" y="0" width="70" height="14" uuid="c6e164a1-2976-4f5a-805c-2ea3c3fa24b2"/>
<textElement>
<font fontName="Arial" size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{dataEhoradeOperacaoFim}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="h:mm a" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="130" y="0" width="70" height="14" uuid="06710dcc-29a8-413b-b8bc-39d245ef1511"/>
<textElement>
<font fontName="Arial" size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{dataEhoradeOperacaoInicio}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="h:mm a" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="0" y="0" width="130" height="14" uuid="19de7aaf-f9a5-4712-9c2f-cb9567c56636"/>
<textElement>
<font fontName="Arial" size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{nomeEstabelecimento}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="670" y="0" width="120" height="14" uuid="1587646e-0363-4e89-aa54-acd365912d0e"/>
<textElement>
<font fontName="Arial" size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{avenida}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="290" y="0" width="100" height="14" uuid="8e8c8657-7d6f-4a17-80cc-7b9b3de835d3"/>
<textElement>
<font fontName="Arial" size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{telefone}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="400" y="0" width="110" height="14" uuid="c065d0da-88d0-49ba-9c3c-a82aedd0cf96"/>
<textElement>
<font fontName="Arial" size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{celular_principal}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true">
<reportElement style="Detail" positionType="Float" x="520" y="0" width="130" height="14" uuid="d1c94533-8e32-4211-80cb-e8e136b02ed7"/>
<textElement>
<font fontName="Arial" size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{email}]]></textFieldExpression>
</textField>
</frame>
</band>
</detail>
<columnFooter>
<band height="8" splitType="Stretch">
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="7" width="801" height="1" uuid="c23ffbf7-1928-41f8-ade3-5930d9a4871d"/>
<graphicElement>
<pen lineWidth="0.5" lineColor="#999999"/>
</graphicElement>
</line>
</band>
</columnFooter>
<pageFooter>
<band height="16" splitType="Stretch">
<frame>
<reportElement mode="Opaque" x="0" y="0" width="802" height="16" forecolor="#D0B48E" backcolor="#006699" uuid="6f4fe8ef-88ca-4d5d-b46a-054826bb7893"/>
<textField evaluationTime="Report">
<reportElement style="Column header" x="771" y="0" width="30" height="16" forecolor="#FFFFFF" uuid="970781d6-87a0-4d3d-a07b-5ae173a1317a"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Column header" x="690" y="0" width="80" height="16" forecolor="#FFFFFF" uuid="42664b34-c87b-42f8-911b-bd9c2ab9111e"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA["Pagina"+$V{PAGE_NUMBER}+" de"]]></textFieldExpression>
</textField>
<textField pattern="d MMMM yyyy h:mm a">
<reportElement style="Column header" x="0" y="0" width="199" height="16" forecolor="#FFFFFF" uuid="06b3d6e8-b4a5-4251-b1fb-f640689933e8"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</frame>
</band>
</pageFooter>
<summary>
<band splitType="Stretch"/>
</summary>
</jasperReport>
trecho do Erro no eclipse
`WARNING: #{estabelecimentoBean.imprimirRelatorioListaEstabelecimento}: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $F{dataEhoradeOperacaoFim}
javax.faces.FacesException: #{estabelecimentoBean.imprimirRelatorioListaEstabelecimento}: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $F{dataEhoradeOperacaoFim}
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:117)`
Caused by: javax.faces.el.EvaluationException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $F{dataEhoradeOperacaoFim}
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101)
... 61 more
Caused by: java.lang.ClassCastException: java.util.GregorianCalendar cannot be cast to java.sql.Timestamp
at Report_ListaEstabelecimento_1508528275679_879654.evaluate(Report_ListaEstabelecimento_1508528275679_879654:214)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:280)
... 89 more