1

I am using Eclipse Luna (4.4) on a Mac along with Java 1.8 and Tomcat 7. When setting up Tomcat with Eclipse with or without an application configured, I am unable to get it to start up.

I see the following stack trace in the Eclipse console


    Jul 13, 2015 2:02:42 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/apadmanabhan/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
    Jul 13, 2015 2:02:42 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:RESTfulPhoneBook' did not find a matching property.
    Jul 13, 2015 2:02:42 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["http-bio-8080"]
    Jul 13, 2015 2:02:42 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
    Jul 13, 2015 2:02:42 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 593 ms
    Jul 13, 2015 2:02:42 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    Jul 13, 2015 2:02:42 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.55
    Jul 13, 2015 2:02:42 PM org.apache.tomcat.util.descriptor.DigesterFactory locationFor
    WARNING: The XML schema [javaee_web_services_1_2.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
    Jul 13, 2015 2:02:42 PM org.apache.tomcat.util.descriptor.DigesterFactory locationFor
    WARNING: The XML schema [web-app_3_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
    Jul 13, 2015 2:02:42 PM org.apache.tomcat.util.descriptor.DigesterFactory locationFor
    WARNING: The XML schema [web-fragment_3_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
    Jul 13, 2015 2:02:42 PM org.apache.tomcat.util.descriptor.DigesterFactory locationFor
    WARNING: The XML schema [web-common_3_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
    Jul 13, 2015 2:02:42 PM org.apache.tomcat.util.descriptor.DigesterFactory locationFor
    WARNING: The XML schema [javaee_6.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
    Jul 13, 2015 2:02:42 PM org.apache.tomcat.util.descriptor.DigesterFactory locationFor
    WARNING: The XML schema [javaee_web_services_1_3.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
    Jul 13, 2015 2:02:42 PM org.apache.tomcat.util.descriptor.DigesterFactory locationFor
    WARNING: The XML schema [javaee_web_services_client_1_3.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
    Jul 13, 2015 2:02:42 PM org.apache.catalina.core.ContainerBase startInternal
    SEVERE: A child container failed during start
    java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:816)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        ... 6 more
    Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getClassLoader()Ljava/lang/ClassLoader;
        at org.apache.catalina.startup.WebappServiceLoader.load(WebappServiceLoader.java:90)
        at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1546)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1268)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:876)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5378)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 6 more

There are a bunch more of these similar errors. I have tried a few things like editing permissions to have full access to the tomcat installation directory, playing around with different tomcat v.s. java installs but none seem to help.

Any ideas?

avinash
  • 97
  • 2
  • 10

1 Answers1

3

This method javax.servlet.ServletContext.getClassLoader()Ljava/lang/ClassLoader is introduced in Servlet 3.0. And, the Tomcat 7.0 should be having that Servlet 3.0 API jar.

But, you should be having an older servlet-api.jar somewhere else in your classpath.

Verify your classpath to see if there are any other references to servlet-api.jar

Pass the -verbose:class argument to java executable. It will print something like this:

[Loaded javax.servlet.Servlet from file:/home:/.../lib/servlet-api.jar]
Ramesh PVK
  • 15,200
  • 2
  • 46
  • 50
  • I tried Tomcat 8, and based on the manifest file for servlet-api.jar file in the lib folder it is using version 3.1. I do not see any other servlet jar file in the tomcat installation directory – avinash Jul 13 '15 at 22:08
  • I am saying there is older servlet-api.jar somewhere else in your classpath that is taking precedence. – Ramesh PVK Jul 13 '15 at 22:16
  • Thanks for your patience. I have cleaned up the m2 repo and removed any other instance of this jar file. How do I check what Tomcat is using in its classpath? – avinash Jul 13 '15 at 22:30
  • Thanks, your updated answer helped. I have deleted the other jar files and now able to start Tomcat – avinash Jul 13 '15 at 22:54