如果我手动将我的网络应用程序部署到 tomcat 6,一切正常。但是当我尝试对 maven6-tomcat-plugin 做同样的事情时,它不会部署。随后出现主机错误,其中任何一个都没有任何意义(来自 catalina.out 日志文件):
信息: validateJarFile(/var/lib/tomcat6/webapps/spring_sec/WEB-INF/lib/servlet-api-2.5.jar) - jar 未加载。这是不正确的; 我解压缩了war文件,文件清晰存在。
严重:创建命名上下文失败:javax.naming.NamingException:上下文是只读的。
严重:部署 Web 应用程序存档 spring_sec.war java.lang.NoClassDefFoundError 时出错:org/springframework/beans/factory/Aware。另一个不真实的陈述;解压缩war包后,我找到了包含所需类的WEB-INF/lib/spring-beans-3.1.1.RELEASE.jar 文件。
手动将war文件部署到tomcat和使用maven插件是一样的吗?
命令 mvn tomcat6:deploy 的 Maven 输出在 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>