8 Replies Latest reply on Jun 23, 2011 10:30 AM by Joshua Davis

    Deploying the Servlet Module in an EAR

    Joshua Davis Expert

      I'm having all sorts of issues getting Seam Servlet to work inside an EAR deployment.  At first I tried things how the booking example works: seam-solder.jar and seam-servlet.jar in my-app.ear/my-webapp.war/WEB-INF/lib, but that resulted in the following exception on deployment:


      2011-06-21 10:01:01,819 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (Thread-2) Error installing to Start: name=vfs:///home/josh/svn/.../jbo
      ss/server/default/deploy/my-app.ear_WeldBootstrapBean state=Create: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ServletExtension] with qualifiers [@Default] at injection point [[parameter 2] of
      [method] @Produces @TypedParamValue protected org.jboss.seam.servlet.http.CookieParamProducer.getTypedParamValue(
      InjectionPoint, ServletExtension)]
              at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:305) [:6.0.0.Final]


      The only configuration that deploys without errors is to have the EAR contain seam-solder.jar and seam-servlet.jar as javaModules in META-INF/application.xml, and to have them at the top level of the EAR structure.   Unfortunately this does not work.   The  public void onStartup(@Observes @Initialized WebApplication webApplication) methods do not get called.


      Does this mean that the META-INF/web-fragment.xml doesn't get processed for javaModules inside an EAR?   If that's the case then maybe I should try manually adding the web-fragment.xml declarations to my web.xml.


      Any ideas on how to debug this?



        • 1. Re: Deploying the Servlet Module in an EAR
          Joshua Davis Expert

          Hm... interesting.   I copied the stuff in web-fragment.xml into my web.xml, and Seam Servlet started working:


              <listener>
                  <display-name>Servlet Event Bridge Listener</display-name>
                  <listener-class>org.jboss.seam.servlet.event.ServletEventBridgeListener</listener-class>
              </listener>
          
              <servlet>
                  <display-name>Servlet Event Bridge Servlet</display-name>
                  <servlet-name>Servlet Event Bridge Servlet</servlet-name>
                  <servlet-class>org.jboss.seam.servlet.event.ServletEventBridgeServlet</servlet-class>
                  <load-on-startup>99999</load-on-startup>
              </servlet>
          
              <filter>
                  <display-name>Servlet Event Bridge Filter</display-name>
                  <filter-name>Servlet Event Bridge Filter</filter-name>
                  <filter-class>org.jboss.seam.servlet.event.ServletEventBridgeFilter</filter-class>
              </filter>
          
              <filter-mapping>
                  <filter-name>Servlet Event Bridge Filter</filter-name>
                  <url-pattern>/*</url-pattern>
              </filter-mapping>
          
              <filter>
                  <filter-name>Catch Exception Filter</filter-name>
                  <filter-class>org.jboss.seam.servlet.exception.CatchExceptionFilter</filter-class>
              </filter>
          
              <filter-mapping>
                  <filter-name>Catch Exception Filter</filter-name>
                  <url-pattern>/*</url-pattern>
              </filter-mapping>
          



          The EAR contains seam-solder.jar and seam-servlet.jar in it's root directory, and the application.xml looks like this:


          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE application PUBLIC
               "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
               "http://java.sun.com/dtd/application_1_3.dtd">
          <application>
            <display-name>my-ear</display-name>
            <description>My Application</description>
            <module>
              <java>seam-solder.jar</java>
            </module>
            <module>
              <java>seam-servlet.jar</java>
            </module>
            <module>
              <ejb>my-ejbs.jar</ejb>
            </module>
            <module>
              <web>
                ... yadda yadda ...
              </web>
            </module>
          </application>
          



          Is this how these modules are supposed to be deployed in an EAR?

          • 2. Re: Deploying the Servlet Module in an EAR
            Joshua Davis Expert

            Wrote up some documentation for myself here


            Not sure if it's right, but that's my experience so far.

            • 3. Re: Deploying the Servlet Module in an EAR
              Jason Porter Master

              Having not tried deployment within an EAR (I see EAR deployments becoming less and less these days anyway) I really can't say. Thank you, though, for doing some research about this. Would you mind if we use this in some documentation?

              • 4. Re: Deploying the Servlet Module in an EAR
                Joshua Davis Expert

                Sure, go right ahead.


                EAR deployment does have some advantage, e.g. JMS destination deployment and app specific logging...   Now if I could only get app specific logging  in JBoss AS 6 working!

                • 5. Re: Deploying the Servlet Module in an EAR
                  Jozef Hartinger Master

                  You have run into AS7-623
                  There's another known workaround (disabling WarClassLoaderDeployer)

                  • 6. Re: Deploying the Servlet Module in an EAR
                    Joshua Davis Expert

                    Jozef Hartinger wrote on Jun 22, 2011 09:38:


                    You have run into AS7-623
                    There's another known workaround (disabling WarClassLoaderDeployer)


                    Aha! Thanks for that.  Here's the link to actual workaround.   I think I like the second approach better, as it doesn't involve global changes to the JBoss AS deployers.

                    • 7. Re: Deploying the Servlet Module in an EAR
                      Joshua Davis Expert

                      I tried disabling WarClassLoaderDeployer.   The server starts, but the web-fragment.xml resources are still not discovered.

                      • 8. Re: Deploying the Servlet Module in an EAR
                        Joshua Davis Expert

                        Update: If I keep the EAR/WAR packaging and deploy the seam-servlet and seam-solder modules in WEB-INF/lib (and not in the EAR as Java modules), then I get an exception on startup:


                        10:13:49,768 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=vfs:///home/josh/jboss/server/default/deploy/myapp.ear_WeldBootstrapBean state=Create: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ServletExtension] with qualifiers [@Default] at injection point [[parameter 2] of [method] @Produces @TypedParamValue protected org.jboss.seam.servlet.http.CookieParamProducer.getTypedParamValue(InjectionPoint, ServletExtension)]
                                at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:305) [:6.0.0.Final]
                                at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:139) [:6.0.0.Final]
                                at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:162) [:6.0.0.Final]
                                at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:377) [:6.0.0.Final]
                                at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:363) [:6.0.0.Final]
                                at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:388) [:6.0.0.Final]
                        



                        If I comment out WarClassLoaderDeployer as per option 1 on this page, then it works fine.   The Servlet Module web-fragment.xml is processed.


                        So basically it looks like there are two workarounds:



                        1. Deploy the Seam modules as <javaModule>s in the EAR.  Put the web-fragment.xml content in web.xml.

                        2. Deploy everything in the WAR inside the EAR.   Include the Seam modules in WEB-INF/lib.   Comment out the WarClassLoaderDeployer.



                        Added this to my wiki page