6 Replies Latest reply on Apr 23, 2007 8:46 AM by leman_1

    Deploying seam app along side standard jsf app problem

      Hello,

      App Server: 4.0.5GA
      Seam version: 1.2.0 Patch 1

      I am trying to deploy a single ear file with a seam app inside it and a JSF app. The ear file deploys but as soon as I try to hit a page in the JSF app the JSF code tries to load some objects into the application scope but fails with the following error:

      17:49:39,168 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      java.lang.IllegalStateException: No active application scope
       at org.jboss.seam.core.Init.instance(Init.java:78)
       at org.jboss.seam.jsf.SeamNavigationHandler.handleNavigation(SeamNavigationHandler.java:28)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:84)
       at javax.faces.component.UICommand.broadcast(UICommand.java:106)
       at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java
      :664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      


      The stack trace contains seam classes in it. The war file containing the JSF code doesn't have any references to any Seam classes or jars. I was hoping the two would be able to run independently of each other.

      Has anyone already done this?

      I would appreciate any help.

      Thanks.

        • 1. Re: Deploying seam app along side standard jsf app problem

          I'd guess that this has to do with the scoping of servlet filters within ears. If two wars are published within the same ear what happens? I suppose you have your answer. Don't know if this is a bug or a feature of JEE deployment.

          This could also be a scoping problem with the JSF context. With both wars sharing a reference to the same JSF context. You may be able to specify a classloader isolation property in your wars to avoid this. Dunno.

          This is all pure speculation at this point. Although you have to ask yourself how a SeamNavigationHandler is getting called in a war that has no idea about Seam.

          • 2. Re: Deploying seam app along side standard jsf app problem
            pmuir

            Make sure you have classloading isolation set up for both apps

            • 3. Re: Deploying seam app along side standard jsf app problem

              Thank you for the quick responses. It looks like classpath isolation can only be done per deployment, the ear file in my case which contains both the wars.

              I don't know if this means that each war file in the ear will use classpath isolation or just the ear file as a whole will be isolated from other deployments.

              Anyway I tried setting the isolation level at both the ear and war level (just in case) but still end up with the same problem.

              I have never done it before so hopefully I set it up correctly by placing
              jboss-app.xml in the META-INF directory of the ear with the following content

              <jboss-app>
              <loader-repository>
              com.example:loader=unique-archive-name
              </loader-repository>
              </jboss-app>

              And placed a jboss-web.xml file in the WEB-INF directory of both my wars with the following content.

              <jboss-web>
              <class-loading>
              <loader-repository>
              com.example:loader=unique-archive-name
              </loader-repository>
              </class-loading>
              </jboss-web>

              Please let me know if you have any other ideas, I am trying to avoid deploying them separately.

              Thanks again.

              • 4. Re: Deploying seam app along side standard jsf app problem
                tzman

                From http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration


                With nested modules, only the top level file may specify class loader scoping. If you have a .ear file containing other modules, only scoping specified in the .ear's META-INF/jboss-app.xml is used. This also applies for any other deployment which contains sub-deployments. For example, if a .sar contains a .war deployment, only the .sar META-INF/jboss-service.xml scoping has effect.


                I took this as meaning that if you specify a loader at the ear level, any loader specified in a nested war or sar will be ignored. If you specified the loader in jboss-app, then all of contents of the ear should be loaded within the same classloader. You can see what jars are loaded within your specified classloader by checking the jmx-console; just search for your unique-archive-name.

                • 5. Re: Deploying seam app along side standard jsf app problem

                  Thank you for that. I read the same thing and was trying to set the classloading in the war files as a desperate measure. Upon startup I get warnings saying that JBoss is going to ignore the loader in the war files because only the root deployment can set it.

                  It must be a classloading issue I just don't know a way around it. I tried removing the seam jar from the application.xml file hoping this would stop the jar from being seen by all the components. That worked and of course stopped the seam app from working as well. I then set the Class-Path in the MANIFEST.MF file of the Seam EJB jar which brought up the same problem again. It looks like adding the jar to any artifacts classpath makes it visible to all.

                  I don't know of any way in a jar/war to say exclude from class path (of course thats assuming that it would solve the problem).

                  • 6. Re: Deploying seam app along side standard jsf app problem

                    In case anyone has the same problem, I couldn't come up with a proper solution so have had to hack one in. A sort of if you can't beat em join em answer. I still don't know if the problem is happening because of a bug or feature.

                    I had to wire Seam into the JSF app, so the web.xml had the following added to it.

                    <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>


                    and the faces-config.xml file had the following added.

                    <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>


                    just like a regular Seam project. So far everything in the JSF app still works and hopefully will stay that way.

                    Thank you for all the replies.