Olá,
que estou fazendo de errado pra dar esse erro …help…help
6:22:08,818 INFO [STDOUT] Está no service
16:22:48,920 ERROR [[Controller]] Servlet.service() for servlet Controller threw exception
java.io.FileNotFoundException: http://localhost:8080/webreport/teste2.jasper
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at br.com.xxx.controller.Controller.service(Controller.java:88)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("Está no service");
//String path = getServletContext().getRealPath("")+"/relatorio";
String jasper = request.getContextPath()+ "/teste2.jasper";
String host = "http://" + request.getServerName() + ":" + request.getServerPort();
URL jasperURL = new URL(host + jasper);
ClienteDAOFake dao = new ClienteDAOFake();
List<Cliente> clientes = dao.getList();
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(clientes);
Map parameters = new HashMap();
try {
JasperPrint print = JasperFillManager.fillReport(jasperURL.openStream(),parameters,ds);
response.setContentType("application/pdf");
byte x1[] = JasperExportManager.exportReportToPdf(print);
response.getOutputStream().write(x1);
} catch (JRException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}