我正在使用 spring mvc 和ehCache开发一个 java webapp 。我可以使用 tomcat 或 jetty 很好地部署它。我有 2 个 maven 项目,一个 webapp/war 和一个集成测试。我希望 hudson 作业在启动 webapp 作为集成测试生命周期的一部分后运行集成测试。
但是,当我尝试将它作为 hudson 工作的一部分启动时,我得到一个例外说
java.lang.NoSuchMethodError: net.sf.ehcache.Cache.getAll(Ljava/util/Collection;)Ljava/util/Map;
我的集成测试 POM 具有以下功能:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<container>
<containerId>jetty7x</containerId>
<type>embedded</type>
</container>
<configuration>
<type>standalone</type>
<properties>
<cargo.servlet.port>8040</cargo.servlet.port>
</properties>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>webapp</artifactId>
<type>war</type>
<pingURL>http://localhost:8040/context/status</pingURL>
<properties>
<context>context</context>
</properties>
</deployable>
</deployables>
</configuration>
</configuration>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
<configuration></configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>**/*.class</include>
</includes>
<skipTests>false</skipTests>
</configuration>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
以及失败的代码行:
@Named("statGroupDto")
@Repository
@Transactional
public class CachedStatGroupDaoImpl implements StatGroupDao {
@Inject
public CachedStatGroupDaoImpl(@Named("cacheManager") final org.springframework.cache.CacheManager cacheManager) {
this.cacheManager = (EhCacheCacheManager) cacheManager;
statsGroupCacheCache = (EhCacheCache) this.cacheManager.getCache("statsCache");
statsGroupCache = (Cache) statsGroupCacheCache.getNativeCache();
@Override
public Collection<StatGroup> getAll() {
Map<Object, Element> allElements = statsGroupCache.getAll(statsGroupCache.getKeys());
它在我的开发机器和生产环境中启动并运行良好,但是当 hudson 尝试运行集成测试时,它无法启动 Web 服务。
有任何想法吗?