2016-04-01 14 views
1

HI Sorunum, Spring mvc ve açısal js arasında. Bir pdf'yi yayma isteği aldım. Url, tek başıma test ettiğim için gayet iyi çalışıyor. Ancak sorun, FrontEnd ile etkileşimde bulunduğumda ve engelleme modunda değil, istisnayı alıyorum. İşte benim kodudur:Web sayfamda pdfüm görüntülenemiyorUygulama (engelleme modunda değil)

@RequestMapping(value = "/getFacture", method = RequestMethod.GET, headers = "Accept=application/json") 
    public @ResponseBody OutputStream postPrice(HttpServletResponse response) throws IOException { 

     try { 
      JasperTest.main(response.getOutputStream()); 
      response.setContentType("application/pdf"); 
     } catch (IOException e) { 

      e.printStackTrace(); 
     } 
     return JasperTest.main(response.getOutputStream()); 


    } 

JasperTest.java

public static OutputStream main(OutputStream out) { 

     try { 
      System.out.println("Generating PDF..."); 

      JasperReport jasperReport = JasperCompileManager 
        .compileReport(JasperTest.class.getClassLoader().getResource("hellojasper.jrxml").getPath()); 


      List<ParamJasper> l = new ArrayList<ParamJasper>(); 

      l.add(new ParamJasper("Card 12")); 
      JRDataSource JRdataSource = new JRBeanCollectionDataSource(l); 
      JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, 
        JRdataSource); 
      JasperExportManager.exportReportToPdfStream(jasperPrint, out); 

      System.out.println("HelloJasper.pdf has been generated!"); 
     } catch (JRException e) { 
      e.printStackTrace(); 
     } 
     return out; 

    } 

Benim ön uç Kodu: Denetleyici:

$scope.continueCheckOut = function(total, priceByCard, priceByCheque, 
      priceByEspece, size) { 
     $scope.priceByCard = priceByCard; 
     $scope.priceByCheque = priceByCheque; 
     $scope.priceByEspece = priceByEspece; 

     $scope.cancel(); 
     $scope.total = total; 
     ProductService.postPayement($scope.priceByCard, $scope.priceByEspece, 
       $scope.priceByCheque, $scope.total,$rootScope.test.idClient).then(function(d) { 

      self.payment = d; 
      if (self.payment.result == true) 
{ 
       console.log("Felecitation"); 
       ProductService.getFacture().then(function(d) { 

        self.pdf = d; 
       }, function(errResponse) { 
        console.error('Error while generating pdf'); 
       }); 
} 
      if (self.payment.result == false) { 
       if (self.payment.reste != 0) { 
        $scope.reste = self.payment.reste; 
        console.log("scope reste is " + -($scope.reste)); 
       } else 
        alert("Veuillez payer le montant souhaité"); 
      } 

     }, function(errResponse) { 
      console.error('Error while fetching Currencies'); 
     }); 



    }; 

myFrontEnd Hizmeti:

getFacture : function() 
    { 
     return $http.get('http://127.0.0.1:9001/PrototypePos/rest/products/getFacture') 
    .then(
       function(response){ 
        return response.data; 
       }, 
       function(errResponse){ 
        console.error('Error while genrating facture'); 
        return $q.reject(errResponse); 
       } 
     ); 
    } 

istisna ben m hg etting geçerli:

GRAVE: Servlet.service() for servlet [dispatcher] in context with path [/PrototypePos] threw exception [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: not in non blocking mode. (through reference chain: org.apache.catalina.connector.CoyoteOutputStream["ready"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: not in non blocking mode. (through reference chain: org.apache.catalina.connector.CoyoteOutputStream["ready"])] with root cause 
java.lang.IllegalStateException: not in non blocking mode. 
    at org.apache.coyote.Response.isReady(Response.java:609) 
    at org.apache.catalina.connector.OutputBuffer.isReady(OutputBuffer.java:663) 
    at org.apache.catalina.connector.CoyoteOutputStream.isReady(CoyoteOutputStream.java:156) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:497) 
    at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:654) 
    at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:675) 
    at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:157) 
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:130) 
    at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1387) 
    at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:889) 
    at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:265) 
    at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:100) 
    at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:222) 
    at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:153) 
    at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:165) 
    at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:80) 
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126) 
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817) 
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731) 
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) 
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) 
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) 
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968) 
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) 
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) 
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) 
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) 
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
    at java.lang.Thread.run(Thread.java:745) 
+0

Söz konusu istisnayı dahil ettik, bunu [değiştir]. –

+0

İşte benim istisnlığım: – yeddez

cevap

0

Ben Aslında pdf görüntüleme için doğru bir istek yapmak benim angularjs bazı kod eksikti ly sorunu çözmek olabilir!

+1

Aynı sorunla karşılaşan başkaları için sorununuzu nasıl çözdüğünüze dair daha fazla ayrıntı sağlayabiliyor musunuz? –