Hi,
I am having a trouble with a jrxml file. When I preview the file in jasperstudio it works but when I execute it in java I'm getting aĀ NumberFormatException. I don't understand because the java code is the same that I use in other project where it works.
It is the java code:
public String getInformeReport(String idEncuesta, String urlJrxml, String urlPDFs, Entidad entidad) throws EncuestasException { //LOG util.Log.log("getInformeReport(idEncuesta: "+idEncuesta+", " + "urlJrxml: "+urlJrxml+", urlPDFs: "+urlPDFs+", entidad: "+entidad+")"); //Comprobaciones if(idEncuesta == null || "".equals(idEncuesta) || entidad == null || entidad.getIdEntidad() == null){ throw new EncuestasException("Falta algún dato obligatorio"); } // TODO: comprobar que el usuario que pide este informe puede verlo // Connection conn = null; try { JasperReport report = JasperCompileManager.compileReport(urlJrxml+"Informe20150424.jrxml"); conn = this.abrirConexion(); // Map parameters = new HashMap(); parameters.put("id_encuesta", new Integer(idEncuesta)); parameters.put("id_entidad", entidad.getIdEntidad() ); parameters.put("fecha", Util.devuelveFechaActual() ); parameters.put("SUBREPORT_DIR",urlJrxml);//Necesario para imÔgenes y subreports // String nombreFichero = util.Util.generaNumeroAleatorioDe8Cifras() ; JasperPrint print = JasperFillManager.fillReport(report, parameters, conn); JasperExportManager.exportReportToPdfFile(print, urlPDFs+nombreFichero+".pdf");  return nombreFichero;  } catch (JRException e) { Log.log("No pudo obtenerse el informe"); e.printStackTrace(); throw new EncuestasException("No pudo obtenerse el informe", e); } catch(Exception e){ Log.log("No pudo obtenerse el informe"); e.printStackTrace(); throw new EncuestasException("No pudo obtenerse el informe", e); }finally{ if(conn != null){try{conn.close();}catch(Exception e){util.Log.log("No se pudo cerrar la coneción " + e.getMessage());}} } }
it is the jrxml file:
<?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0 --> <!-- 2015-04-25T17:58:45 --> <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="Borrame" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ee2fe6f1-1fea-4055-94e3-21980d798e43"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="606"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="encuestas local"/> <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"/> <parameter name="id_encuesta" class="java.lang.Integer"/> <parameter name="id_entidad" class="java.lang.String"/> <parameter name="fecha" class="java.lang.String"/> <queryString language="SQL"> <![CDATA[select e.nombre nombre_encuesta, p.texto pregunta_texto, r.texto respuesta_texto, count(*) votos, cast(r.valor_numerico as decimal(2,0)) respuesta_valor_numerico, p.id_pregunta id_pregunta, e.id_entidad id_entidad, e.id_encuesta id_encuesta, r.id_respuesta id_respuesta from encuesta e, pregunta p, respuesta r, voto_anonimo v where e.id_encuesta = $P{id_encuesta} and e.id_entidad = $P{id_entidad} and e.id_encuesta = p.id_encuesta and e.id_entidad = p.id_entidad and p.id_pregunta = r.id_pregunta and p.id_entidad = r.id_entidad and v.id_respuesta = r.id_respuesta and v.id_entidad = r.id_entidad group by v.id_encuesta, v.id_pregunta, v.id_respuesta order by v.id_encuesta, v.id_pregunta, v.id_respuesta desc]]> </queryString> <field name="nombre_encuesta" class="java.lang.String"/> <field name="pregunta_texto" class="java.lang.String"/> <field name="respuesta_texto" class="java.lang.String"/> <field name="votos" class="java.lang.Long"/> <field name="respuesta_valor_numerico" class="java.math.BigDecimal"/> <field name="id_pregunta" class="java.lang.Long"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="id_entidad" class="java.lang.Long"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="id_encuesta" class="java.lang.Long"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="id_respuesta" class="java.lang.Long"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <group name="Group1" isStartNewPage="true"> <groupExpression><![CDATA[$F{pregunta_texto}]]></groupExpression> <groupHeader> <band height="24"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> <textField> <reportElement x="0" y="0" width="554" height="24" uuid="57f690e9-bd61-491e-960f-95d8c610bc62"> <property name="local_mesure_unitx" value="pixel"/> <property name="com.jaspersoft.studio.unit.x" value="px"/> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <textFieldExpression><![CDATA[$F{pregunta_texto}]]></textFieldExpression> </textField> </band> </groupHeader> <groupFooter> <band height="50"/> </groupFooter> </group> <background> <band splitType="Stretch"/> </background> <title> <band height="61"> <textField> <reportElement x="0" y="0" width="280" height="30" uuid="2577bfae-1e02-4fce-b2f9-4ef21fba324f"> <property name="local_mesure_unitx" value="pixel"/> <property name="com.jaspersoft.studio.unit.x" value="px"/> <property name="local_mesure_unity" value="pixel"/> <property name="com.jaspersoft.studio.unit.y" value="px"/> </reportElement> <textFieldExpression><![CDATA[$F{nombre_encuesta}]]></textFieldExpression> </textField> <textField> <reportElement x="455" y="0" width="100" height="30" uuid="ba4b05cb-994d-47af-828c-54cc71ccb641"> <property name="local_mesure_unity" value="pixel"/> <property name="com.jaspersoft.studio.unit.y" value="px"/> <property name="local_mesure_unitx" value="pixel"/> <property name="com.jaspersoft.studio.unit.x" value="px"/> </reportElement> <textFieldExpression><![CDATA[$P{fecha}]]></textFieldExpression> </textField> </band> </title> <detail> <band height="24" splitType="Stretch"> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> <textField> <reportElement x="0" y="0" width="390" height="24" uuid="fa1aa9c0-7c60-4c36-94ff-f9535639bd9e"> <property name="local_mesure_unitx" value="pixel"/> <property name="com.jaspersoft.studio.unit.x" value="px"/> <property name="local_mesure_unity" value="pixel"/> <property name="com.jaspersoft.studio.unit.y" value="px"/> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <textFieldExpression><![CDATA[$F{respuesta_texto}]]></textFieldExpression> </textField> <textField> <reportElement x="454" y="0" width="100" height="24" uuid="6fe8c396-4e24-42bc-a533-8943a0f3c340"> <property name="local_mesure_unity" value="pixel"/> <property name="com.jaspersoft.studio.unit.y" value="px"/> <property name="local_mesure_unitheight" value="pixel"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <textFieldExpression><![CDATA[$F{votos}]]></textFieldExpression> </textField> </band> </detail> </jasperReport>
It is the log when i execute the java method:
Sun Apr 26 10:29:51 CEST 2015 Encuestas getInformeReport(idEncuesta: 35, urlJrxml: K:\\Codigo\\Encuestas\\build\\web\\iReports\\jrxml\\, urlPDFs: K:\\Codigo\\Encuestas\\build\\web\\iReports\\PDF\\, entidad: entidad[idEntidad: 2, nombre: Probando])
and it is the error error stack that I get:
Sun Apr 26 10:29:53 CEST 2015 Encuestas No pudo obtenerse el informe java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Integer.java:454) at java.lang.Integer.parseInt(Integer.java:527) at net.sf.jasperreports.engine.util.JRProperties.asInteger(JRProperties.java:411) at net.sf.jasperreports.engine.util.JRProperties.getIntegerProperty(JRProperties.java:378) at net.sf.jasperreports.engine.util.JRStyleResolver.getFirstLineIndent(JRStyleResolver.java:643) at net.sf.jasperreports.engine.base.JRBaseParagraph.getFirstLineIndent(JRBaseParagraph.java:196) at net.sf.jasperreports.engine.fill.TextMeasurer.renderNextLine(TextMeasurer.java:629) at net.sf.jasperreports.engine.fill.TextMeasurer.renderParagraph(TextMeasurer.java:459) at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:400) at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:541) at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:651) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:331) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:384) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:358) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:346) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:280) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:822) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:61) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:849) at Modelo.Modelo.getInformeReport(Modelo.java:578) at Controlador.Delegate.getInforme(Delegate.java:257) at Controlador.Controlador.processRequest(Controlador.java:655) at Controlador.Controlador.doGet(Controlador.java:812) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at Filtros.Filtro.doFilter(Filtro.java:98) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722)
could somebody help me? I do not what more try to do
0 Answers:
No answers yet