Reputation: 362
If I manually deploy my web app to tomcat 6, everything works. But when I attempt to do the same with maven6-tomcat-plugin it won't deploy. A host error follows, not one of which makes any sense (from catalina.out log file):
INFO: validateJarFile(/var/lib/tomcat6/webapps/spring_sec/WEB-INF/lib/servlet-api-2.5.jar) - jar not loaded. This is simply not true; I unzipped the war file and the file is clearly present.
SEVERE: Creation of the naming context failed: javax.naming.NamingException: Context is read only.
SEVERE: Error deploying web application archive spring_sec.war java.lang.NoClassDefFoundError: org/springframework/beans/factory/Aware. Another untrue statement; after unzipping the war package I found WEB-INF/lib/spring-beans-3.1.1.RELEASE.jar file which contains the desired class.
Is it the same thing to manually deploy the war file to tomcat and to use the maven plugin?
Maven output for command mvn tomcat6:deploy after mvn clean:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SpringSec 0.1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat6-maven-plugin:2.0-beta-1:deploy (default-cli) @ spring_sec >>>
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ spring_sec ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /media/winchester/spring_sec/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ spring_sec ---
[INFO] Compiling 1 source file to /media/winchester/spring_sec/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.3:testResources (default-testResources) @ spring_sec ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /media/winchester/spring_sec/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ spring_sec ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ spring_sec ---
[INFO] No tests to run.
[INFO] Surefire report directory: /media/winchester/spring_sec/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ spring_sec ---
[INFO] Packaging webapp
[INFO] Assembling webapp [spring_sec] in [/media/winchester/spring_sec/target/spring_sec-0.1.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/media/winchester/spring_sec/src/main/webapp]
[INFO] Webapp assembled in [40 msecs]
[INFO] Building war: /media/winchester/spring_sec/target/spring_sec-0.1.0-SNAPSHOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] <<< tomcat6-maven-plugin:2.0-beta-1:deploy (default-cli) @ spring_sec <<<
[INFO]
[INFO] --- tomcat6-maven-plugin:2.0-beta-1:deploy (default-cli) @ spring_sec ---
[INFO] Deploying war to ***:8080/spring_sec
Uploading: ***:8080/manager/html/deploy?path=%2Fspring_sec
3211/3211 KB
Uploaded: ***:8080/manager/html/deploy?path=%2Fspring_sec (3211 KB at 50171.2 KB/sec)
[INFO] FAIL - Failed to deploy application at context path /spring_sec
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.280s
[INFO] Finished at: Thu Apr 19 22:07:39 EEST 2012
[INFO] Final Memory: 15M/144M
[INFO] ------------------------------------------------------------------------
** Maven pom: **
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.denarced</groupId>
<artifactId>spring_sec</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>SpringSec</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0-beta-1</version>
<configuration>
<server>lapserver</server>
<url>http://192.168.11.7:8080/manager/html</url>
</configuration>
</plugin>
</plugins>
</build>
</project>
Upvotes: 4
Views: 5118
Reputation: 59634
You can use the cargo plugin too. See http://tshikatshikaaa.blogspot.nl/2012/07/how-to-deploy-war-to-tomcat-7-during.html for more details.
Upvotes: 0
Reputation: 362
Problem has been solved with Chris White's help, which was essential. It appears that Tomcat was holding on to some elder version of the webapp, which was made of of elder versions of Spring components. After shutting down Tomcat and manually deleting both packaged and unpackaged webapp files, I was able to deploy again via the maven plugin.
Upvotes: 0
Reputation: 30089
Tomcat will not load the servlet-api.jar as it is a core part of Tomcat (and already present in the $TOMCAT_HOME/lib folder), this 'info' statement is just telling you that Tomcat has ignored the jar file
When you say it works fine if you manually deploy - what do you mean? Are you manually placing the war file in the $TOMCAT_HOME/webapps folder, or are you using the manager web app and uploading the war on the deploy page. Can you confirm that you are able to deploy 'manually' via the manager application (which is what the maven-tomcat6-plugin is wrapping - a PUT to the manager webapp, posting your war file
Can you verify the unpacked war file (in $TOMCAT_HOME/webapps/spring_sec/WEB-INF/lib) contains the spring-beans-3.1.1.RELEASE.jar
Upvotes: 3