Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running tomcat 9 embedded on maven

Tags:

maven

tomcat

i'm trying to run tomcat 9 embedded through maven.

I saw that there is no 'tomcat9-maven-plugin' yet and that i can run tomcat 9 using tomcat7-plugin but i don't seem to be able to do so.

Things I've tried:

  • I've tried to set CATALINA_HOME to the new version path
  • Setting version in the plugin's configurations
  • Change the version using the the dependencies:

        <properties>
          <tomcat.version>9.0.0.M1</tomcat.version>
        </properties>
      <plugins>
        <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.tomcat.embed</groupId>
                        <artifactId>tomcat-embed-core</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-util</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-coyote</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-api</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-jdbc</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-dbcp</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-servlet-api</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-jsp-api</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-jasper</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-jasper-el</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-el-api</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-catalina</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-tribes</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-catalina-ha</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-annotations-api</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat</groupId>
                        <artifactId>tomcat-juli</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
    
                    <dependency>
                        <groupId>org.apache.tomcat.embed</groupId>
                        <artifactId>tomcat-embed-logging-juli</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.tomcat.embed</groupId>
                        <artifactId>tomcat-embed-logging-log4j</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
                </dependencies>
              </plugin>
             </plugins>
    

I don't know what else to try, no matter what i do it always run on version 7.0.47:

INFO: Starting Servlet Engine: Apache Tomcat/7.0.47

Thanks

like image 353
Raz Zelinger Avatar asked Oct 02 '18 13:10

Raz Zelinger


People also ask

Does maven have Tomcat?

Like many of its functionalities, Maven provides Tomcat-specific goals through the use of independently developed plugins. There are currently two Tomcat plugins available for Maven.

What is Tomcat7 Maven plugin?

The Tomcat7 Maven Plugin provides goals to manipulate WAR projects within the Tomcat servlet container version 7.x.


1 Answers

Tomcat Maven plugin seems discontinued, but you can use Cargo plugin instead to run embedded Tomcat 9.

Add plugin configuration in pom:

<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <version>1.7.6</version>
  <configuration>
    <container>
      <containerId>tomcat9x</containerId>
      <type>embedded</type>
    </container>
  </configuration>
</plugin>

Start it with:

mvn org.codehaus.cargo:cargo-maven2-plugin:run
like image 190
holmis83 Avatar answered Oct 28 '22 13:10

holmis83