Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 474347

Summary: provided maven dependency included in virtualClasspath of server.xml
Product: [WebTools] WTP ServerTools Reporter: Sven Ulrich <sven-ulrich>
Component: jst.serverAssignee: jst.server <jst.server-inbox>
Status: CLOSED DUPLICATE QA Contact: Elson Yuen <eyuen7>
Severity: critical    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
example project to reproduce the problem none

Description Sven Ulrich CLA 2015-08-05 13:40:55 EDT
Created attachment 255651 [details]
example project to reproduce the problem

With the new eclipse-version mars, maven projects with a dependency to "servlet-api" with scope "provided" can't be started in eclipse with a tomcat 7 server when the option "Serve modules without publishing" is checked.

The following errormessage is displayed:

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hello]]
	at java.util.concurrent.FutureTask.report(Unknown Source)
	at java.util.concurrent.FutureTask.get(Unknown Source)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1122)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/hello]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
	... 6 more
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/jst/server/tomcat/loader/WtpWebappClassLoader) previously initiated loading for a different type with name "javax/servlet/ServletContext"
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at java.net.URLClassLoader.defineClass(Unknown Source)
	at java.net.URLClassLoader.access$100(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1229)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1692)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1573)
	at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:167)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5520)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 6 more
	
The reason for this seems to be that after publishing, the servlet-api.jar is included in the virtualClasspath of the server.xml in the conf-folder of the tomcat. Since the dependency has scope "provided" it shouldn't be. Because tomcat provides this dependency in the lib-folder the exception is thrown.

Steps to reproduce:
 - See the attachment for a simple "hello world" spring maven project.
 - Create a Tomcat7-Server in eclipse mars and check the "Serve modules without publishing"-option
 - Try starting the server, this should cause the exception
 - remove the servlet-api dependency in the pom.xml. The server will start successfully.
 - Try the unchanged server in an eclipse luna. It should start without any problems.
Comment 1 Sven Ulrich CLA 2015-08-06 03:16:21 EDT
I just noticed that this is a duplicate to 471596. The provided fix works for me too.

When will the fix be included in the official eclipse version?

*** This bug has been marked as a duplicate of bug 471596 ***