Announcement Announcement Module
Collapse
No announcement yet.
Funky problem with Jasper Views Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Funky problem with Jasper Views

    Hi

    I am trying to use the Jasper reports support in spring and I am getting the following exception trace.

    ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error
    at org.apache.coyote.tomcat5.OutputBuffer.doFlush(Out putBuffer.java:374)
    at org.apache.coyote.tomcat5.OutputBuffer.flush(Outpu tBuffer.java:340)
    at org.apache.coyote.tomcat5.CoyoteOutputStream.flush (CoyoteOutputStream.java:117)
    at org.springframework.web.servlet.view.jasperreports .AbstractJasperReportsSingleFormatView.renderRepor t(AbstractJasperReportsSingleFormatView.java:82)
    at org.springframework.web.servlet.view.jasperreports .JasperReportsMultiFormatView.renderReport(JasperR eportsMultiFormatView.java:207)
    at org.springframework.web.servlet.view.jasperreports .AbstractJasperReportsView.renderMergedOutputModel (AbstractJasperReportsView.java:499)
    at org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:250)
    at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:928)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:705)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:625)
    at org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(FrameworkServlet.java:386)
    at org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:346)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:743)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:856)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:284)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:204)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:257)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:567)
    at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:245)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:199)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:567)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:184)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:164)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:149)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:567)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:156)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:151)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:567)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:972)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:206)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:833)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:732)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:619)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:688)
    at java.lang.Thread.run(Thread.java:534)


    Here is my Controller, I have tested and I am certain that I am connecting and getting data from the database.

    public class SpringController implements Controller {


    static{

    try {
    Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e) {
    // TODO Auto-generated catch block
    System.out.println("Are you working here*******************");
    e.printStackTrace();
    }

    }

    /**
    *
    */
    public SpringController() {
    super();
    // TODO Auto-generated constructor stub
    }

    /* (non-Javadoc)
    * @see org.springframework.web.servlet.mvc.Controller#han dleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    */
    public ModelAndView handleRequest(HttpServletRequest arg0,
    HttpServletResponse arg1) throws Exception {
    ModelAndView mv = null;
    try{
    Connection con = DriverManager.getConnection("jdbc:mysql://172.16.2.140:3306/test2?autoReconnect=true","test","test");
    ServletContext sc = arg0.getSession().getServletContext();
    JasperReport jr = (JasperReport)JRLoader.loadObject(sc.getRealPath(" ") + "/WEB-INF/reports/report1.jasper");
    Map map = new HashMap();
    ResultSet rs = con.prepareStatement(jr.getQuery().getText()).exec uteQuery();
    JRResultSetDataSource rrds = new JRResultSetDataSource(rs);
    map.put("format", "pdf");
    map.put("myBeanData",rrds);
    mv = new ModelAndView("simpleReport",map);


    }catch(Exception ex){
    System.out.println(ex.getMessage());
    }
    return mv;
    }

    }


    Here is my views.properties file I am using.
    simpleReport.class=org.springframework.web.servlet .view.jasperreports.JasperReportsMultiFormatView
    simpleReport.url=/WEB-INF/reports/report1.jasper
    simpleReport.reportDataKey=myBeanData

    Here is my springapp-servlet.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>

    <bean id="springappController" class="SpringController"/>


    <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="mappings">
    <props>
    <prop key="/testing.htm">springappController</prop>
    </props>
    </property>
    </bean>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.Resour ceBundleViewResolver">
    <property name="basename">
    <value>views</value>
    </property>
    </bean>


    </beans>

    I have tested the JasperReport inside JasperAssistant and it seems to be in perfect order. Any help would be appreciated greatly.

    Thanking In Advance

    Tanaka

  • #2
    What could be the issue?

    Just to add, I have added debug information to the JasperReportsHtmlView
    class and established that the ByteArrayOutputStream that is written to the ServletOutputStream is correctly formatted i.e the report to be rendered is in perfect order.
    This made me believe that it was actually a problem with trying to write to the ServletOutputStream so I attempted to write arbitrary data to the stream just to see, and sure enough even a simple string cannot be printed to the response.

    Help please.

    Comment

    Working...
    X