I´m using an embedded tomcat in my maven project to do some integration tests (client - server scenario).
Tomcat tomcat = new Tomcat();
//set Host and port..
//add user and role for basic authentication
tomcat.start()
If I build the project with maven the tests are running as expected and the server starts properly. If I try to debug the tests via Eclipse the tomcat server doesn´t start with the exception:
org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
I tried to debug the tomcat.start()
method to figure out where the exception occures. It´s in (StandardServer.class
):
synchronized (services) {
for (int i = 0; i < services.length; i++) {
services[i].start();
}
}
Services
is at the state [StandardService[Tomcat]]
, so I actually doesn´t know much more than before since I get no stack trace. The exception is caught in this snippet (LifeCycleBase.class
):
try {
startInternal();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
setStateInternal(LifecycleState.FAILED, null, false);
throw new LifecycleException(
sm.getString("lifecycleBase.startFail",toString()), t);
}
Im using Eclipse Version: Neon Release (4.6.0). Some colleagues uses eclipse too and it works in one case. We tried to figure out the difference but didn´t find much. What we´ve tried so far is to edit the build paths of some dependencies of our project. Of course we did change our own project dependencies only. The other libraries e.G. embedded tomcat are untouched.
In Netbeans it works as expected. I assume it´s an eclipse setting or something like that..
Edit:
I guess I´m not providing enough information. The dependencies of the pom.xml
looks like:
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>7.0.55</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-logging-log4j</artifactId>
</dependency
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>7.0.55</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
I tried to remove the dependency of javax.servlet and the exclusion. After I do this, the tomcat server starts but there are more than 200 tests failing. So I need this dependency. This post explains the difference between this two dependencies. But I still don´t get, why it doesn´t work..