simonTifo
simonTifo

Reputation: 307

Running Maven web application to Tomcat

I have a problem with Tomcat when I run my web application. Here is the relevant part of my pom.xml :

<build>
<plugins>
    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>7</version>
    </plugin>
</plugins>
</build>

When I run with m2eclipse (tomcat:run) I have this error:

[INFO] Scanning for projects...
[WARNING] The POM for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:7: Plugin org.apache.tomcat.maven:tomcat7-maven-plugin:7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ourtest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:7: Plugin org.apache.tomcat.maven:tomcat7-maven-plugin:7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7
[INFO] 
[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) @ ourtest >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ ourtest ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\user\Documents\EclipseProjects\ourtest\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ ourtest ---
[INFO] Compiling 7 source files to C:\Users\user\Documents\EclipseProjects\ourtest\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre7\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.317s
[INFO] Finished at: Tue Mar 05 15:50:20 GMT+01:00 2013
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ourtest: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

I tested a lot of configurations in pom.xml but to no result.

Upvotes: 2

Views: 3108

Answers (4)

Alessandro Giannone
Alessandro Giannone

Reputation: 885

Try changing two things:

1) Update the tomcat7-maven-plugin version to 2.1

2) Use "mvn tomcat7:run"

The version specified doesn't exist and the command you are using will run the old codehaus plugin.

Upvotes: 4

Cassian
Cassian

Reputation: 3738

Maven is looking for compiler probably in a JRE instead of a JDK make sure that you set the class path to a JDK

Unable to locate the Javac Compiler

Upvotes: 0

Afro
Afro

Reputation: 1

To check Your JAVA_HOME environment variable You need to type in the command line (WIN) java --version. This can tell You if Your sys. using JDK or JRE. You can also go to MyComputer -> Properties -> Advanced -> environment variables and see on the list what JAVA_HOME is(I don't use the english ver. of Win so the names might be a little diferent). To change JRE in Eclipse(I'm using Juno) go to Project Properies -> Java Build Path -> Libraries Tab -> Add a JDK lib if not present.

Upvotes: 0

Larry Shatzer
Larry Shatzer

Reputation: 3627

Please see the FAQ related to this issue for M2Eclipse.

Upvotes: 1

Related Questions