2 Replies Latest reply on Oct 20, 2011 4:57 PM by Jason Porter

    Exception was thrown after I added a Servlet...

    hantsy bai Master

      I tried to add a servlet to generate pdf in browser.



      But I opened the home page in browser, I got the following exception.



      javax.enterprise.event.ObserverException
           sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
           sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
           sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
           java.lang.reflect.Constructor.newInstance(Constructor.java:513)
           java.lang.Class.newInstance0(Class.java:355)
           java.lang.Class.newInstance(Class.java:308)
           org.jboss.weld.util.reflection.SecureReflections$16.work(SecureReflections.java:395)
           org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
           org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInstantiation(SecureReflectionAccess.java:216)
           org.jboss.weld.util.reflection.SecureReflections.newInstance(SecureReflections.java:390)
           org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:40)
           org.jboss.weld.injection.Exceptions.rethrowException(Exceptions.java:92)
           org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:214)
           org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282)
           org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265)
           org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:234)
           org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:635)
           org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:622)
           org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:616)
           org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:74)
           org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72)
      
      root cause
      
      javax.servlet.ServletException: The class 'org.jboss.weld.proxies.Conversation$-1395802890$Proxy$_$$_WeldClientProxy' does not have the property 'end'.
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:325)
           com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
           com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110)
           org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
           org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72)
      
      root cause
      
      javax.el.PropertyNotFoundException: The class 'org.jboss.weld.proxies.Conversation$-1395802890$Proxy$_$$_WeldClientProxy' does not have the property 'end'.
           javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:661)
           javax.el.BeanELResolver.getValue(BeanELResolver.java:290)
           javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
           com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
           org.apache.el.parser.AstValue.getValue(AstValue.java:134)
           org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:187)
           org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:55)
           com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:207)
           com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:148)
           com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:70)
           com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:75)
           com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:176)
           javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
           com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
           com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
           com.ocpsoft.pretty.faces.application.PrettyViewHandler.renderView(PrettyViewHandler.java:163)
           javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
           javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
           javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
           com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
           com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
           com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
           com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
           com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110)
           org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
           org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72)
      
      

        • 1. Re: Exception was thrown after I added a Servlet...
          hantsy bai Master

          The servlet code.


          @WebServlet("/forwarding/caseExportPdfServlet")
          public class ExportPdfServlet extends HttpServlet {
               private static final long serialVersionUID = 1L;
          
               @RequestParam
               Long id;
          
               @Inject
               EntityManager em;
          
               // /*@Inject
               // @Resource("XlsDataSourceReport.jrxml")
               // InputStream sourceReport;*/
          
               @Inject
               private ResourceProvider resourceProvider;
          
               @Inject
               @Jasper
               ReportCompiler compiler;
          
               // @Inject
               // JRDataSource jasperDataSource;
          
               @Inject
               @PDF
               @Jasper
               ReportRenderer<Report> pdfRenderer;
          
               /**
                * @see HttpServlet#HttpServlet()
                */
               public ExportPdfServlet() {
                    super();
                    // TODO Auto-generated constructor stub
               }
          
               /**
                * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
                *      response)
                */
               protected void doGet(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException, IOException {
                    processRequest(request, response);
               }
          
               /**
                * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
                *      response)
                */
               protected void doPost(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException, IOException {
                    processRequest(request, response);
               }
          
               protected void processRequest(HttpServletRequest request,
                         HttpServletResponse response) throws ServletException, IOException {
                    ForwardingCase _case = em.find(ForwardingCase.class, id);
                    OutputStream _out = response.getOutputStream();
          
                    InputStream sourceReport = resourceProvider.loadResourceStream("/reports/forwarding-case.jrxml");
                    JRDataSource jasperDataSource = new JRBeanCollectionDataSource(
                              _case.getForwardingItems());
          
                    // source
                    ReportDefinition report = compiler.compile(sourceReport);
          
                    Map<String, Object> params = new HashMap<String, Object>();
                    params.put("forwardingCase", _case);
                    
          
                    Report reportInstance = report.fill(jasperDataSource, params);
          
                    // ByteArrayOutputStream os = new ByteArrayOutputStream(_out); //
                    // OutputStream
                    // Render output as the desired content
                    pdfRenderer.render(reportInstance, _out);
                    _out.flush();
               }
          
          }
          
          
          




          Where is wrong?

          • 2. Re: Exception was thrown after I added a Servlet...
            Jason Porter Master

            You'd need to pass 'cid' as a param with the conversation ID, and probably have inject the Conversation and call a get or a begin with the id.