1

When I start tomcat from cmd like "start catalina", another cmd terminal opens and then the error given below iis taken. How can this be fixed?

... SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1069)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1719)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getClassLoader()Ljava/lang/ClassLoader;
        at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:210)
        at org.apache.catalina.startup.ContextConfig.processJarsForWebFragments(ContextConfig.java:1855)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1119)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:771)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)
        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:5095)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 10 more
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Denisa
  • 125
  • 4
  • 16
  • is it a bare tomcat installation or do you have something deployed ? I recall having NoSuchMethodErrors for having deployed a webapp using servlet spec recent than supported ones. It's been ages since I last touched Tomcat, but ver 8 doesn't seem extremely "recent" – BigMike Jan 06 '21 at 18:05
  • @BigMike I ll deploy some projects but I have not deployed yet; I am not sure but if 'm not mistaken as no server/src/shared folders and application file exist in Tomcat Home, it is not a bare tomcat installation. Even localhost:8080 not open Tomcat welcome page after "catalina start " or run is applied – Denisa Jan 06 '21 at 20:48
  • then the only thing I can think of is you're using a too recent/old JVM or have some jar for a different servlet version in your classpath. Which jvm are you using ? – BigMike Jan 06 '21 at 21:28
  • Java SE Runtime Environment = 1.8.0_201 JDK = 1.8.0_181, servlet are: servlet-api, javax.servlet-3.0 @BigMike – Denisa Jan 07 '21 at 08:50

1 Answers1

1

java.lang.NoSucMethodError comes when Java code tries to call a method which is not existed on a class, this could be either static or non static method.

Maybe solution for your issue is here

java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String

javax.servlet.ServletContext.getContextPath()Ljava/lang/String

Sibin Rasiya
  • 1,132
  • 1
  • 11
  • 15