Announcement Announcement Module
Collapse
No announcement yet.
Stack Overflow when returning view with JDK 1.3 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stack Overflow when returning view with JDK 1.3

    Hi!

    I have a controller that returns a PDF view to the browser; and i also want to save this pdf in the server. Here's the code:

    Code:
    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
            request.setAttribute("gestionAltas","S");
            
    		// Primero obtenemos la lista de seleccionados
    		String ids = request.getParameter(Constants.DATAGRID_SELECTION_PARAMETER);
    		HashMap modelo = new HashMap();
    		modelo.put("ids","(" + ids + ")");
    		
    		// Actualizamos el contador de impresiones de los registros recibidos
    		mgrAltas.incrementPrintCount(ids);
            mgrBajas.incrementPrintCount(ids);
            DataSource ds = (DataSource)getApplicationContext().getBean("dataSource");
            JasperReport jr = (JasperReport)JRLoader.loadObject(getServletContext().getRealPath("/") + "/reports/cartaAlta.jasper"); 
            JasperPrint print = JasperFillManager.fillReport(jr, modelo, ds.getConnection());
            JasperExportManager.exportReportToPdfFile(print,getServletContext().getRealPath("/") + "/reports/cartas.pdf");
    
            return new ModelAndView("cartaAltaView",modelo);
    	}
    So, i generate the report 'by hand' and save it in the specified folder, and then return the pdf view to the browser.

    THE THING IS:

    The pdf gets correctly rendered and saved in the server, but the view never gets to the browser. Turning on spring logging, here's the stacktrace:


    Code:
    [06.11.09 14:51:31:000 CET] 1a4a978f SystemOut     U 2006-11-09 14:51:31,000 [Servlet.Engine.Transports:10] DEBUG org.springframework.web.servlet.view.ResourceBundleViewResolver - Cached view 'cartaAltaView_es_ES'
    
    [06.11.09 14:51:31:000 CET] 1a4a978f SystemOut     U 2006-11-09 14:51:31,000 [Servlet.Engine.Transports:10] DEBUG org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView: name 'cartaAltaView'; URL [/reports/cartaAlta.jasper]] in DispatcherServlet with name 'springaction'
    
    [06.11.09 14:53:46:031 CET] 1a4a978f SystemOut     U 2006-11-09 14:51:31,078 [Servlet.Engine.Transports:10] ERROR org.springframework.web.servlet.DispatcherServlet - Could not complete request
    org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.StackOverflowError: null
    java.lang.StackOverflowError
    	at java.lang.String.getChars(String.java(Compiled Code))
    	at java.lang.StringBuffer.append(StringBuffer.java(Compiled Code))
    	at java.util.Locale.toString(Locale.java(Compiled Code))
    	at java.util.Locale.toString(Locale.java(Compiled Code))
    	at java.lang.String.valueOf(String.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    	at java.lang.String.valueOf(String.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    
    ...(this goes on for like 1 thousand lines)
    
            at java.lang.String.valueOf(String.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    	at java.lang.String.valueOf(String.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    	at java.lang.String.valueOf(String.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    	at java.lang.String.valueOf(String.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    	at java.util.AbstractMap.toString(AbstractMap.java(Compiled Code))
    	at java.lang.StringBuffer.append(StringBuffer.java(Compiled Code))
    	at java.lang.StringBuffer.append(StringBuffer.java(Compiled Code))
    	at org.springframework.web.servlet.view.AbstractView.render(Unknown Source)
    	at org.springframework.web.servlet.DispatcherServlet.render(Unknown Source)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(Unknown Source)
    	at org.springframework.web.servlet.DispatcherServlet.doService(Unknown Source)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(Unknown Source)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(Unknown Source)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    	at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
    	at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:159)
    	at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:286)
    	at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:106)
    	at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
    	at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
    	at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
    The puzzling thing: this error only happens when i create the PDF 'by hand', before returning the modelandview. IF I COMMENT THESE LINES:

    Code:
            JasperPrint print = JasperFillManager.fillReport(jr, modelo, ds.getConnection());
            JasperExportManager.exportReportToPdfFile(print,getServletContext().getRealPath("/") + "/reports/cartas.pdf");
    THE PDF ARRIVES CORRECTLY TO THE BROWSER.

    And one more piece to this puzzle, you Spring detectives: this only happend in tomcat 3 and websphere AS 4.0. In Tomcat 4 there's not a single problem.
    I'm using JDK 1.3.

    Thanks in advance!

    Nacho
Working...
X