javatomcatgraphhopper

Adding Maven dependencies back into GraphHopper's Classpath causes a working Tomcat server to fail


I must preface my question with the fact that I am a complete novice when it comes to Java. I have been trying to host graphhopper on a local tomcat server and I get right to the end of the online guide here before my progress falls apart.

Prior to taking the last step of the guide, I can get Eclipse to launch the tomcat server but I get NoClassDefFoundError and the localhost is blank. So, I do as instructed in the guide with the Jar files and load all of the Maven Dependencies back into the Classpath. Attempting to run this server now causes several "severe" errors regarding catalina.LifecycleException (amongst others) and the server will not load. I've included the error log at the end.

I have searched online regarding the error with catalina and the only response to all questions is that there is a conflict between the JDK/JRE versions used by Tomcat and the one used by Eclipse. I have spent a long time looking into this and I have confirmed that JAVA_HOME and the selected JRE in Eclipse are pointing to exactly the same folder. I have tried this with JRE and JDK to get the same response, both times from scratch. I have also set CATALINA_HOME to the correct Tomcat folder. I am able to load Tomcat separately from startup.bat to see the success splash screen.

This is what I am using:
JDK 8u45 or JRE 8u45
Eclipse (Mars Release 4.5.0)
Tomcat 8.0.23

I'm missing some fundamental understanding into why Tomcat works fine with Eclipse until I load these dependencies (screenshot at end) and so I can't seem to make any progress. Any help or pointers to move me forwards would be much appreciated; thank you in advance.

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:917)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
    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.getVirtualServerName()Ljava/lang/String;
    at org.apache.tomcat.websocket.server.WsServerContainer.<init>(WsServerContainer.java:147)
    at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
    at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5156)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more

Jul 01, 2015 4:09:55 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]]
    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:917)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:625)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
    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: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:925)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more

Jul 01, 2015 4:09:55 PM org.apache.catalina.startup.Catalina start
SEVERE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:625)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:769)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:925)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more

Jul 01, 2015 4:09:55 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-nio-8080"]
Jul 01, 2015 4:09:55 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-nio-8009"]
Jul 01, 2015 4:09:55 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jul 01, 2015 4:09:55 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-nio-8080"]
Jul 01, 2015 4:09:55 PM org.apache.coyote.AbstractProtocol destroy
SEVERE: Failed to destroy end point associated with ProtocolHandler ["http-nio-8080"]
java.lang.NullPointerException
    at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:303)
    at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:479)
    at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:818)
    at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:532)
    at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:588)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:859)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

Jul 01, 2015 4:09:55 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-nio-8009"]
Jul 01, 2015 4:09:55 PM org.apache.coyote.AbstractProtocol destroy
SEVERE: Failed to destroy end point associated with ProtocolHandler ["ajp-nio-8009"]
java.lang.NullPointerException
    at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:303)
    at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:479)
    at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:818)
    at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:532)
    at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:588)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:859)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

dependencies


Solution

  • After a lot of blind searching I seem to have been able to get it to generate all of the graph files and plot a route in my browser. I'm sure that there will be an obvious reason for why it wasn't working earlier, but perhaps it would be worth including something about this in the (already fantastic) online guide?

    I went into pom and found that the list of dependencies was far shorter than what I had been putting back in the classpath. The list was:

    core dependencies

    So I stripped the classpath to this list and the server loaded with NoClassDefFoundError. One by one I added the Jars back in to address each new error until I came to the final list:

    final dependencies

    Perhaps I will run into some functionality issues further down the line but this was a fix to my immediate problem.