16

I hava a maven project, pom.xml contains tomcat plugin.

<plugin>
 <groupId>org.apache.tomcat.maven</groupId>
 <artifactId>tomcat7-maven-plugin</artifactId>
 <version>2.2</version>
</plugin>

I've downloaded Tomcat 7, so I've got Tomcat directory (apache-tomcat-7.0.56). I tried three goals to run my project:

tomcat7:run, tomcat7:run-war, tomcat7:run-war-only

My application is running at http://localhost:8080/projectname, if I run tomcat7:run-war, projectname-0.0.1-SNAPSHOT.war appears in the /target directory of my project.

I want to run my application at http://localhost:8080/.

I know this question was asked before, but unfortunately those solutions didn't help me.

I tried both methods from the first answer of this.

First method didn't work for me, after renaming war nothing changed, tomcat7:run-war-only requires war with name like projectname-0.0.1-SNAPSHOT.war.

The second method changed nothing (I tried both

<Context path="" docBase="projectname-0.0.1-SNAPSHOT" debug="0" reloadable="true"></Context>
and

<Context path="" docBase="projectname" debug="0" reloadable="true"></Context>)

I have also looked throw this, but I don't have <catalina_home>/conf/Catalina/localhost/ directory in my Tomcat directory.

Community
  • 1
  • 1
Bogdan Timofeev
  • 1,062
  • 3
  • 11
  • 33

2 Answers2

18

Have you tried changing the context path by setting it in the configuration section of the Maven plugin?

FYI: Find the current version of the plugin here

  <plugin>
   <groupId>org.apache.tomcat.maven</groupId>
   <artifactId>tomcat7-maven-plugin</artifactId>
   <version>2.2</version>

    <configuration>
      <path>/</path>
    </configuration>

  </plugin>
Stefan
  • 12,108
  • 5
  • 47
  • 66
0

I am using tomee and it works for me.

Add the context tag to the pom file as follows:-

<plugin>
 <groupId>org.apache.tomcat.maven</groupId>
 <artifactId>tomcat7-maven-plugin</artifactId>
 <version>2.2</version>
 <configuration>
   ..
   <context>ROOT<context>
   ..
 </configuration>
</plugin>
Mav55
  • 4,080
  • 2
  • 21
  • 20