Uploaded image for project: 'JBoss Enterprise Application Platform 6'
  1. JBoss Enterprise Application Platform 6
  2. JBPAPP6-896

FacesContext.getCurrentInstance returns external context from a different deployment during application startup

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Migrated to another ITS
    • Affects Version/s: EAP 6.0.0
    • Fix Version/s: EAP 6.0.1 ER 1
    • Component/s: Web
    • Labels:
    • Environment:

      EAP 6.0.0.CR1, JDK 1.6.0_30

    • Steps to Reproduce:
      Hide

      1. Start the AS7/EAP6 with ./standalone.sh -Dorg.jboss.server.bootstrap.maxThreads=1 (which makes it easier to reproduce, as the issue occurs only when both the deployments are handled by the same MSC service thread)
      2. deploy seam-blog.ear
      3. deploy seam-booking.ear
      4. notice the seam-booking doesn't work

      the ears can be found in http://file.brq.redhat.com/~maschmid/JBPAPP-9197/

      Show
      1. Start the AS7/EAP6 with ./standalone.sh -Dorg.jboss.server.bootstrap.maxThreads=1 (which makes it easier to reproduce, as the issue occurs only when both the deployments are handled by the same MSC service thread) 2. deploy seam-blog.ear 3. deploy seam-booking.ear 4. notice the seam-booking doesn't work the ears can be found in http://file.brq.redhat.com/~maschmid/JBPAPP-9197/
    • Affects:
      Release Notes
    • Workaround Description:
      Hide

      Make sure that you do not try to call FacesContext.getCurrentInstance() from a ServletContextListener. If you are using FacesContext at application initialization it should only be done in response to a JSF PostConstructApplicationEvent. And then, you should always call FacesContext.release() in a finally block when you are done.

      Presumably, once http://java.net/jira/browse/JAVASERVERFACES-2436 is fixed, the call to FacesContext.release() will be done for you just as it is during a request to the FacesServlet.

      Show
      Make sure that you do not try to call FacesContext.getCurrentInstance() from a ServletContextListener. If you are using FacesContext at application initialization it should only be done in response to a JSF PostConstructApplicationEvent. And then, you should always call FacesContext.release() in a finally block when you are done. Presumably, once http://java.net/jira/browse/JAVASERVERFACES-2436 is fixed, the call to FacesContext.release() will be done for you just as it is during a request to the FacesServlet.

      Description

      Deplying two Seam2 applications sometimes fails with the second one not working, as it loads configuration files belonging to the other application. The problem seems to be that during application initialization, the FacesContext.getCurrentInstance sometimes returns a non-null instance belonging to a previous deployment.

      The code in Seam2 to load resources looks like this (called during SeamListener contextInitialized, which is a ServletListener)

      public InputStream getResourceAsStream(String resource) {
            javax.faces.context.FacesContext context = javax.faces.context.FacesContext.getCurrentInstance(); 
            
            if (context!=null)
            {
               log.debug("XXX: facesContext " + context.getExternalContext().getContextName());
               stream = FacesResources.getResourceAsStream( resource, context.getExternalContext() );
            }
            
            if (stream == null)
            {
               // ... load stream from the ServletContext
            }
      

      The FacesServlet is initialized later,

      from the web.xml:

      <listener>
        <listener-class&gt;org.jboss.seam.servlet.SeamListener</listener-class&gt;      
      </listener>
      
      <servlet>
         <servlet-name>Faces Servlet</servlet-name>
         <servlet-class&gt;javax.faces.webapp.FacesServlet</servlet-class&gt;
         <load-on-startup>1</load-on-startup>                        
      </servlet>
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ssilvert Stan Silvert
                  Reporter:
                  maschmid Marek Schmidt
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  8 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: