4 Replies Latest reply on Dec 31, 2013 3:30 PM by Joshua Davis

    JBoss AS 7.2 - Is there a way to exclude CDI/WELD an implied dependency?

    Joshua Davis Expert

      I have a Seam 2.2 / JSF 1.2 appplication that I'm moving over to AS 7.  A while ago I had updated my JBoss AS 5.1 deployed application to Guava 15.0, which has META-INF/beans.xml in the JAR file, which is deployed in the EAR/lib directory in my case.  This causes AS 7 (and AS 5.1) to think that the application requires CDI/Weld (it doesn't, it's a Seam 2 application).   I solved this in AS 5.1 by disabling the Weld deployer.   What's the correct way to do this in AS 7?

       

      I was able to succesfully exclude some dependencies in META-INF/jboss-deployment-structure.xml, so I'm guessing that the correct way to do this is to exclude CDI/Weld in there?  What are the exclusions I need to make?

       

       

      The error I get is the same one listed here: Re: JBoss7: java.lang.InstantiationException: org.jboss.as.weld.webtier.jsf.WeldApplicationFactory

       

      Except... I don't want it to load CDI/Weld.

        • 1. Re: JBoss AS 7.2 - Is there a way to exclude CDI/WELD an implied dependency?
          Joshua Davis Expert

          I tried adding the following exclusions to META-INF/jboss-deployment-structure.xml, but it's still starting Weld when deploying the EAR:

           

                      <module name="org.jboss.interceptor" slot="main"/>
                      <module name="org.jboss.as.weld" slot="main"/>
                      <module name="org.jboss.weld.core" slot="main"/>
                      <module name="org.jboss.weld.api" slot="main"/>
                      <module name="org.jboss.weld.spi" slot="main"/>
          

           

          So the complete file looks like this:

           

          <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
              <deployment>
                  <exclusions>
                      <module name="javax.faces.api" slot="main"/>
                      <module name="com.sun.jsf-impl" slot="main"/>
                      <module name="org.hibernate" slot="main"/>
                      <module name="org.hibernate.validator" slot="main"/>
                      <module name="org.jboss.interceptor" slot="main"/>
                      <module name="org.jboss.as.weld" slot="main"/>
                      <module name="org.jboss.weld.core" slot="main"/>
                      <module name="org.jboss.weld.api" slot="main"/>
                      <module name="org.jboss.weld.spi" slot="main"/>
                  </exclusions>
                  <dependencies>
                      <module name="org.apache.log4j" export="true"/>
                      <module name="org.dom4j" export="true"/>
                      <module name="org.slf4j" export="true"/>
                      <module name="javax.faces.api" slot="1.2" export="true"/>
                      <module name="com.sun.jsf-impl" slot="1.2" export="true"/>
                      <module name="org.hibernate" slot="3" export="true"/>
                      <module name="org.apache.commons.logging" export="true"/>
                  </dependencies>
              </deployment>
          
              <sub-deployment name="pep-web.war">
                  <exclusions>
                      <module name="javax.faces.api" slot="main"/>
                      <module name="com.sun.jsf-impl" slot="main"/>
                      <module name="org.hibernate" slot="main"/>
                      <module name="org.hibernate.validator" slot="main"/>
                      <module name="org.jboss.interceptor" slot="main"/>
                      <module name="org.jboss.as.weld" slot="main"/>
                      <module name="org.jboss.weld.core" slot="main"/>
                      <module name="org.jboss.weld.api" slot="main"/>
                      <module name="org.jboss.weld.spi" slot="main"/>
                  </exclusions>
                  <dependencies>
                      <module name="org.hibernate" slot="3"/>
                      <module name="javax.faces.api" slot="1.2"/>
                      <module name="com.sun.jsf-impl" slot="1.2"/>
                  </dependencies>
              </sub-deployment>
          
          </jboss-deployment-structure>
          
          
          • 2. Re: JBoss AS 7.2 - Is there a way to exclude CDI/WELD an implied dependency?
            Tomaz Cerar Master

            No need to complicate that much.

             

            simply exclude weld subsystem to be applied to your deployment.

             

            this config should do:

            <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">

              <deployment>

                 <exclude-subsystems>

                    <subsystem name="weld" />

                </exclude-subsystems>

              </deployment>

              <sub-deployment name="myapp.war">

                 <exclude-subsystems>

                    <subsystem name="weld" />

                </exclude-subsystems>

            </sub-deployment>

            </jboss-deployment-structure>

            • 3. Re: JBoss AS 7.2 - Is there a way to exclude CDI/WELD an implied dependency?
              Joshua Davis Expert

              Thanks, that is exactly what I was looking for!   I'll give it a try on Monday. 

              • 4. Re: JBoss AS 7.2 - Is there a way to exclude CDI/WELD an implied dependency?
                Joshua Davis Expert

                Hm... looks like the 1.2 XSD thinks I should have some extra elements in there, like <module-alias>.   My IDE is giving me a red-flag on the <deployment> and <sub-deployment> elements.   I guess I could ignore that, or maybe I have the wrong XSD?   I followed the link from JBossDTDs

                 

                Anyway, changing the XSD reference and adding the <exclude-subsystems> elements to both <deployment> and <subdeployment> sections worked!  My Seam 2 app now starts up just fine in AS 7.2, even when guava.jar is in the EAR lib directory.