2 Replies Latest reply on Feb 1, 2008 9:10 AM by Terry

    Error during PDF generation - IllegalStateException: No acti

    Terry Apprentice

      I am getting following error since upgrading to Seam 2.0.0GA.

      Error only happens when use-extensions="true". I open PDF in new window with h:commandLink. The new windows is blank with IE error ...cannot download xxx.pdf?docId=1... and Server logs shows following error.

      Error
      18:40:14,262 ERROR [[Document Store Servlet]] Servlet.service() for servlet Document Store Servlet threw exception
      java.lang.IllegalStateException: No active event context
       at org.jboss.seam.core.Manager.instance(Manager.java:248)
       at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:55)
       at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:543)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      
      
      
      
      .xhtml
       <h:commandLink value="Generate Letter" action="#{paymentReminderLetter.generateLetter}"
       onclick="return generateLetter(document.paymentReminderLetter);" target="_blank" type="submit">
       </h:commandLink>
      
      
      
      
      component.xml
       <pdf:document-store use-extensions="true" error-page="/error.xhtml"/>
      
      
      
      
      web.xml
      <?xml version="1.0" ?>
      <web-app xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       version="2.5">
      
       <!--rich faces and ajax4jsf -->
       <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>blueSky</param-value>
       </context-param>
      
       <!-- Seam -->
       <listener>
       <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
       </listener>
       <filter>
       <filter-name>Seam Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>Seam Filter</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
       <servlet>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
       </servlet>
       <servlet-mapping>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <url-pattern>/seam/resource/*</url-pattern>
       </servlet-mapping>
      
       <!-- pdf/rtf related servlet settings -->
      <!--
       <filter>
       <filter-name>Seam Redirect Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamRedirectFilter</filter-class>
       </filter>
      -->
       <filter>
       <filter-name>Seam Servlet Filter</filter-name>
       <filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>Seam Servlet Filter</filter-name>
       <url-pattern>*.pdf</url-pattern>
       </filter-mapping>
       <filter-mapping>
       <filter-name>Seam Servlet Filter</filter-name>
       <url-pattern>*.rtf</url-pattern>
       </filter-mapping>
       <servlet>
       <servlet-name>Document Store Servlet</servlet-name>
       <servlet-class>org.jboss.seam.pdf.DocumentStoreServlet</servlet-class>
       </servlet>
       <servlet-mapping>
       <servlet-name>Document Store Servlet</servlet-name>
       <url-pattern>*.pdf</url-pattern>
       </servlet-mapping>
       <servlet-mapping>
       <servlet-name>Document Store Servlet</servlet-name>
       <url-pattern>*.rtf</url-pattern>
       </servlet-mapping>
      
      
       <!-- JSF -->
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
       </context-param>
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.seam</url-pattern>
       </servlet-mapping>
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>client</param-value>
       </context-param>
      
       <!-- Facelets development mode (disable in production) -->
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>false</param-value>
       </context-param>
       <context-param>
       <param-name>facelets.SKIP_COMMENTS</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <error-page>
       <exception-type>java.lang.Exception</exception-type>
       <location>/error.xhtml</location>
       </error-page>
       <error-page>
       <error-code>404</error-code>
       <location>/error-404.seam</location>
       </error-page>
      
       <security-constraint>
       <display-name>Restrict raw XHTML Documents</display-name>
       <web-resource-collection>
       <web-resource-name>XHTML</web-resource-name>
       <url-pattern>*.xhtml</url-pattern>
       </web-resource-collection>
       <auth-constraint/>
       </security-constraint>
      
       <session-config>
       <session-timeout>20</session-timeout>
       </session-config>
      </web-app>
      
      seam component
      @Name("paymentReminderLetter")
      @Scope(ScopeType.CONVERSATION)
      public class PaymentReminderLetter {
      
       @In(value="entityManager", required=false, create=true)
       EntityManager em;
      
      ...
      
       public String generateLetter() throws ApplicationException {
      
       this.maxQueryResults = this.maxLetterPerAttempt;
       submitSearch();
      
       if (this.getResultCount() <= 0) {
       FacesMessages.instance().add(FacesMessage.SEVERITY_INFO, "No declard but unpaid applicants exist within specified criteria.");
       } else {
       flagAsReminded();
       }
      
       return null;
       }
      
      
       private void submitSearch() throws ApplicationException {
      
       try {
       Query query = em.createQuery(this.getEjbql());
       query.setMaxResults(this.maxQueryResults);
       paymentReminderLetterList = query.getResultList();
       this.executeSearch = true;
       } catch (Exception e) {
       throw new OnlineException(OnlineException.ERROR_EXTRACTING_RECORD, "Payment Reminder Letter. Error: " + e.getMessage());
       }
       }
      
       private void flagAsReminded() throws ApplicationException {
      
       try {
       String ejbqlUpdate = "update Application set paymentReminderGeneratedDate = current_timestamp() " +
       "where applicationNumber in (:remindedApplicant)";
      
       em.createQuery(ejbqlUpdate)
       .setParameter("remindedApplicant", getRemindedUsernameList())
       .executeUpdate();
       } catch (Exception e) {
       throw new OnlineException(OnlineException.ERROR_UPDATING_RECORD, "Failed to flag unpaid applications as reminded. Error: " + e.getMessage());
       }
       }
      
      ...
      
      }