I have to continue the development of a web application done in JSF. It generates a PDF file using Jasper Reports. It works well in localhost, no warnings, no errors, everything is ok. But, when I uploaded to the VPS, it doesn't workm which is quite weird because the code is the same. My PC is an Ubuntu 15.04 with Glassfish 4.1 and Oracle Java 8. The server has an Ubuntu 14.04 server, Glassfish 4.1 and Oracle Java 7. According to the log file of the glassfish of the server, there is a problem with the database but I don't know why. Localhost and server uses the same version of MySQL and the definition of the database is the same. Actually, I can login in the server, so I can access to the database.
Is there any configuration which must be different in the server? Does anybody know what I should look for?
These are the errors:
ERROR 1
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error creating scriptlet class instance : com.appglass.jasper.CorteScriptlet javax.el.ELException: net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error creating scriptlet class instance : com.appglass.jasper.CorteScriptlet at com.sun.el.parser.AstValue.invoke(AstValue.java:293) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149) at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88) at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:813) at javax.faces.component.UICommand.broadcast(UICommand.java:300) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) at java.lang.Thread.run(Thread.java:745) Caused by: net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error creating scriptlet class instance : com.appglass.jasper.CorteScriptlet at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:762) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:328) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:377) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:351) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2039) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:771) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:281) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:144) 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.fill(JasperFillManager.java:407) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:824) at com.appglass.jasper.Reportes.crearPDF(Reportes.java:321) at com.appglass.backing.ProyectoAgregadoBacking.crearPDF(ProyectoAgregadoBacking.java:99) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.sun.el.parser.AstValue.invoke(AstValue.java:289) ... 46 more Caused by: net.sf.jasperreports.engine.JRException: Error creating scriptlet class instance : com.appglass.jasper.CorteScriptlet at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriptlet(DefaultScriptletFactory.java:118) at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriplets(DefaultScriptletFactory.java:69) at net.sf.jasperreports.engine.fill.JRFillDataset.createScriptlets(JRFillDataset.java:502) at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:619) at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1252) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:877) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:822) at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:652) at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59) at org.apache.commons.javaflow.bytecode.StackRecorder.execute(StackRecorder.java:95) at org.apache.commons.javaflow.Continuation.continueWith(Continuation.java:170) at org.apache.commons.javaflow.Continuation.startWith(Continuation.java:129) at org.apache.commons.javaflow.Continuation.startWith(Continuation.java:102) at net.sf.jasperreports.engine.fill.JRContinuationSubreportRunner.start(JRContinuationSubreportRunner.java:53) at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:737) ... 66 more Caused by: org.hibernate.TransactionException: nested transactions not supported at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:154) at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1431) at sun.reflect.GeneratedMethodAccessor475.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:356) at com.sun.proxy.$Proxy208.beginTransaction(Unknown Source) at com.appglass.data.dao.ConstantesDAO.cargarConstantes(ConstantesDAO.java:32) at com.appglass.jasper.CorteScriptlet.(CorteScriptlet.java:17) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:383) at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriptlet(DefaultScriptletFactory.java:110) ... 80 more
ERROR 2
StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception org.hibernate.TransactionException: nested transactions not supported at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:154) at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1431) at sun.reflect.GeneratedMethodAccessor475.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:356) at com.sun.proxy.$Proxy208.beginTransaction(Unknown Source) at com.appglass.data.dao.ConstantesDAO.cargarConstantes(ConstantesDAO.java:32) at com.appglass.jasper.CorteScriptlet.(CorteScriptlet.java:17) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:383) at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriptlet(DefaultScriptletFactory.java:110) at net.sf.jasperreports.engine.scriptlets.DefaultScriptletFactory.getScriplets(DefaultScriptletFactory.java:69) at net.sf.jasperreports.engine.fill.JRFillDataset.createScriptlets(JRFillDataset.java:502) at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:619) at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1252) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:877) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:822) at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:652) at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59) at org.apache.commons.javaflow.bytecode.StackRecorder.execute(StackRecorder.java:95) at org.apache.commons.javaflow.Continuation.continueWith(Continuation.java:170) at org.apache.commons.javaflow.Continuation.startWith(Continuation.java:129) at org.apache.commons.javaflow.Continuation.startWith(Continuation.java:102) at net.sf.jasperreports.engine.fill.JRContinuationSubreportRunner.start(JRContinuationSubreportRunner.java:53) at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:737) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:328) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:377) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:351) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2039) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:771) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:281) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:144) 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.fill(JasperFillManager.java:407) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:824) at com.appglass.jasper.Reportes.crearPDF(Reportes.java:321) at com.appglass.backing.ProyectoAgregadoBacking.crearPDF(ProyectoAgregadoBacking.java:99) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.sun.el.parser.AstValue.invoke(AstValue.java:289) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149) at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88) more things
ProyectoAgregadoBacking
@ManagedBean
@ViewScoped
public class ProyectoAgregadoBacking implements Serializable{
public void crearPDF()
{
renderNotificationBar = false;
Reportes reporte = new Reportes();
Locale loc = null;
disabledVerPDF = true;
if(idIdioma == null){
try{
reporte.crearPDF(idProyecto, getCurrentUser(), getCurrentUser().getEmail(), false, null);
} catch(SQLException sqlE){
sqlE.printStackTrace();
}
} else {
if(idIdioma == 0){
loc = new Locale("es", "ES");
} else if(idIdioma == 1){
loc = new Locale("en", "US");
} else if(idIdioma == 2){
loc = new Locale("it", "IT");
} else if(idIdioma == 3){
loc = new Locale("fr", "FR");
} else if(idIdioma == 4){
loc = new Locale("pt", "PT");
} else if(idIdioma == 5){
loc = new Locale("ru", "RU");
} else if(idIdioma == 6){
loc = new Locale("pl", "PL");
}
try {
reporte.crearPDF(idProyecto, getCurrentUser(), getCurrentUser().getEmail(), false, loc);
} catch (SQLException ex) {
Logger.getLogger(ProyectoAgregadoBacking.class.getName()).log(Level.SEVERE, null, ex);
}
}
//Si el usuario es administrador: Reduce el stock
if(getCurrentUser().getRol().compareTo("0") == 0){
fabricar();
}
}
}
Reporte.java
@ManagedBean
@ApplicationScoped
public class Reportes
{
public void crearPDF(Integer idProyecto, Usuarios usuario, String email, Boolean archivoDoc, Locale locale) throws SQLException
{
System.err.println("Entrando en crearPDF");
//String ruta = "\\\\SERVER\\producción\\PDFAPP\\" + usuario.getNombre() + "\\";
String ruta = "/home/haritz/pdfapp/" + usuario.getNombre() + "/";
Integer versionProyecto;
File rutaFile = new File(ruta);
JRPdfExporter exp = new JRPdfExporter();
JRPdfExporter exp2 = new JRPdfExporter();
JRDocxExporter expD = new JRDocxExporter();
Connection conn = null;
if(!rutaFile.exists()){
rutaFile.mkdirs();
}
MailUtil mUtil = new MailUtil();
String nombreProyecto;
FacesContext context = FacesContext.getCurrentInstance();
//LOCALIZACIÓN DE INFORMES
//Si no viene especificado por el administrador, extraer el idioma del contexto (establecido en función del usuario)
if(locale == null){
locale = context.getViewRoot().getLocale();
}
//Genera el ResourceBundle que le pasaremos por parámetro
ResourceBundle rb = ResourceBundle.getBundle("com.appglass.jasper.resources.report", locale);
//Introducimos los parámetros necesarios
HashMap <String, Object> map = new HashMap <String, Object>();
map.put("rutaImagenes", (Object) rutaImagenes);
map.put("idProyecto", (Object) idProyecto);
map.put("archivoDoc", (Object) archivoDoc);
map.put(JRParameter.REPORT_LOCALE,locale);
map.put(JRParameter.REPORT_RESOURCE_BUNDLE, rb);
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx = session.beginTransaction();
try{
//Nuevo para conseguir session.connection() en hibernate 4.x
SessionFactoryImpl sessionFactory = (SessionFactoryImpl) session.getSessionFactory();
conn = sessionFactory.getConnectionProvider().getConnection();
//session.connection() fue borrado en hibernate 4.x
//conn = session.connection();
/*JRProperties.setProperty("net.sf.jasperreports.default.pdf.font.name", "Deja Vu Sans");
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params);
JasperExportManager.exportReportToPdfFile(jasperPrint, outputFileName); */
InputStream reporte = (InputStream) getClass().getResourceAsStream("/com/appglass/jasper/report2.jasper");
InputStream reporte2 = (InputStream) getClass().getResourceAsStream("/com/appglass/jasper/report2_subreport1B.jasper");
InputStream reporte3 = (InputStream) getClass().getResourceAsStream("/com/appglass/jasper/report2_subreport2B.jasper");
InputStream reporte4 = (InputStream) getClass().getResourceAsStream("/com/appglass/jasper/report2_plano.jasper");
InputStream reporte5 = (InputStream) getClass().getResourceAsStream("/com/appglass/jasper/report2_resumen.jasper");
// Path completo C:/Users/pool/Documents/NetBeansProjects/AppGlass/src/java
if ((reporte == null) || reporte2 == null || reporte3 == null || reporte4 == null){
System.err.println("No se ha encontrado el archivo .jasper");
}
JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, map, conn);
System.err.println("Report1 done");
JasperPrint jasperPrint2 = JasperFillManager.fillReport(reporte2, map, conn); //THIS RISES AN ERROR
JasperPrint jasperPrint3 = JasperFillManager.fillReport(reporte3, map, conn);
JasperPrint jasperPrint4 = JasperFillManager.fillReport(reporte4, map, conn);
JasperPrint jasperPrint5 = JasperFillManager.fillReport(reporte5, map, conn);
System.err.println("Antes de llamar a JasperViewer.viewReport");
//Para exportar el PDF al cliente
HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
List list = new ArrayList();
list.add(jasperPrint4);
list.add(jasperPrint5);
list.add(jasperPrint);
list.add(jasperPrint2);
list.add(jasperPrint3);
if(!archivoDoc){
exp.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, list);
exp2.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, list);
exp.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
exp.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
}
nombreProyecto = queryGetNombreProyecto(conn, idProyecto);
versionProyecto = queryGetVersionProyecto(conn, idProyecto);
if(!archivoDoc){
//Fijamos como salida un fichero en SERVER
exp2.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, ruta + nombreProyecto + "version" + (versionProyecto + 1) + ".pdf");
exp2.setParameter(JRPdfExporterParameter.METADATA_AUTHOR, usuario.getNombre());
exp2.setParameter(JRPdfExporterParameter.METADATA_TITLE, nombreProyecto);
exp2.exportReport();
} else {
expD.setParameter(JRDocxExporterParameter.JASPER_PRINT_LIST, list);
//Fijamos como salida un fichero en SERVER
expD.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, ruta + nombreProyecto + "(" + (versionProyecto + 1) + ").doc");
//Fijamos como salida la un fichero en el servidor remoto
expD.exportReport();
}
//Enviamos el mail de confirmación con el informe adjunto
mUtil.confirmacionInforme(email, usuario, nombreProyecto, archivoDoc, versionProyecto + 1);
//Fijamos como salida el lector de PDF del navegador
if(!archivoDoc){
response.setHeader("Content-Type", "application/pdf; charset=UTF-8");
response.setHeader("Content-disposition", "attachment; filename*=UTF-8\'\'" + URLEncoder.encode(nombreProyecto, "UTF-8") + ".pdf");
exp.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
exp.exportReport();
}
}catch(SQLException sqlEx){
System.err.println("Error creando el PDF");
System.err.println(sqlEx.getClass());
System.err.println(sqlEx.getCause());
System.err.println(sqlEx.getMessage());
}
catch (HibernateException ex)
{
System.err.println("Error creando el PDF");
System.err.println(ex.getClass());
System.err.println(ex.getCause());
System.err.println(ex.getMessage());
} catch (JRException ex) {
System.err.println("Error creando el PDF");
System.err.println(ex.getClass());
System.err.println(ex.getCause());
System.err.println(ex.getMessage());
} catch (IOException ex) {
System.err.println("Error creando el PDF");
System.err.println(ex.getClass());
System.err.println(ex.getCause());
System.err.println(ex.getMessage());
} finally {
if(conn != null){
tx.commit();
conn.close();
}
}
FacesContext.getCurrentInstance().responseComplete();
}
}
ConstantesDAO.java
public Constantes cargarConstantes() throws IndexOutOfBoundsException
{
Constantes c = new Constantes();
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
try
{
c = (Constantes) session.createCriteria(Constantes.class).
add(Restrictions.eq("id", 1)).
list().get(0);
session.getTransaction().commit();
}
catch (IndexOutOfBoundsException ex)
{
session.getTransaction().rollback();
throw new IndexOutOfBoundsException("Problema al cargar las constantes de la base de datos. Espere unos minutos y vuelva a intentarlo.");
}
return c;
UPDATE:
I've removed all pages of the PDF except one, i.e.:
This is not anymore
JasperPrint jasperPrint2 = JasperFillManager.fillReport(reporte2, map, conn); //THIS RISES AN ERROR
JasperPrint jasperPrint3 = JasperFillManager.fillReport(reporte3, map, conn);
JasperPrint jasperPrint4 = JasperFillManager.fillReport(reporte4, map, conn);
JasperPrint jasperPrint5 = JasperFillManager.fillReport(reporte5, map, conn);
Only this is in the code, and it works!
JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, map, conn);
but I need all pages, not just one.
at com.appglass.data.dao.ConstantesDAO.cargarConstantes(ConstantesDAO.java:32)
– Kukeltje