4 Replies Latest reply on Oct 16, 2015 5:44 AM by Chris Rankin

    Disabling WELD 2.3.0.Final for a particular servlet inside an embedded Tomcat.

    Chris Rankin Novice

      Hi,

       

      I have an Arquillian test that wants to run 3 WARs inside an embedded Tomcat container. Only one of the WARs uses WELD (2.3.0.Final), and yet org.jboss.weld.environment.servlet.EnhancedListener executes for all WARs. I've already found issue WELD-1771, but I suspect that

      this fix doesn't work for an embedded container that doesn't support classloader isolation.

       

      Is there any other way of configuring WELD not to initialise for a given servlet, please?

       

      Cheers,

      Chris

        • 1. Re: Disabling WELD 2.3.0.Final for a particular servlet inside an embedded Tomcat.
          Martin Kouba Master

          I'm not aware of any way to disable the EnhancedListener in such an environment. Could you try to migrate to a managed Tomcat container adapter instead?

          • 2. Re: Disabling WELD 2.3.0.Final for a particular servlet inside an embedded Tomcat.
            Chris Rankin Novice

            The Arquillian tests are being run by maven-failsafe-plugin as part of a standard Maven project structure. So the project starts an embedded Tomcat via an Arquillian extension, executes the integration tests against it and the shuts the embedded Tomcat down again. I simply have no idea if this is even possible using the managed Tomcat container adapter, since the project would need to create its own Tomcat installation to manage in the first place.

            • 3. Re: Disabling WELD 2.3.0.Final for a particular servlet inside an embedded Tomcat.
              Martin Kouba Master

              Well, you could make use of Tomcat dist artifact and maven-dependency-plugin, e.g.:

                                  <plugin>
                                      <groupId>org.apache.maven.plugins</groupId>
                                      <artifactId>maven-dependency-plugin</artifactId>
                                      <executions>
                                          <execution>
                                              <id>unpack</id>
                                              <phase>process-test-classes</phase>
                                              <goals>
                                                  <goal>unpack</goal>
                                              </goals>
                                              <configuration>
                                                  <artifactItems>
                                                      <artifactItem>
                                                           <groupId>org.apache.tomcat</groupId>
                                                           <artifactId>tomcat</artifactId>
                                                          <version>7.0.64</version>
                                                          <type>zip</type>
                                                          <overWrite>false</overWrite>
                                                          <outputDirectory>${project.build.directory}</outputDirectory>
                                                      </artifactItem>
                                                  </artifactItems>
                                              </configuration>
                                          </execution>
                                      </executions>
                                  </plugin>
              

              And then set CATALINA_HOME to ${project.build.directory}/apache-tomcat-7.0.64 in maven-failsafe-plugin configuration.

              • 4. Re: Disabling WELD 2.3.0.Final for a particular servlet inside an embedded Tomcat.
                Chris Rankin Novice

                Hi, that was a good starting point. I've moved the maven-dependency-plugin goal into the generate-test-resources phase so that I can rewrite the conf/server.xml file with Google's replacer plugin in the process-test-resouces phase, and I've added

                <excludes>**/webapps/ROOT/**</excludes>
                

                when unpacking Tomcat to remove its built-in ROOT.war.

                 

                And I've also needed to add a custom tomcat-users.xml file (copied from somewhere):

                 

                <?xml version="1.0" encoding="UTF-8"?>
                <tomcat-users>
                    <role rolename="manager-gui"/>
                    <role rolename="manager-jmx"/>
                    <role rolename="manager-script"/>
                    <user username="tomcat" password="tomcat" roles="manager-script, manager-jmx, manager-gui"/>
                    <user username="${tomcat.user}" password="${tomcat.password}" roles="manager-script"/>
                </tomcat-users>
                

                 

                And then I still need to configure my application! But it looks promising.

                 

                Thanks,

                Chris