javahadooptomcathbaseapache-phoenix

apache tomcat start fails with phoenix-5.0.0-HBase-2.0-client.jar in project lib folder


i have a web application which connects to apache phoenix; therefore i added phoenix-5.0.0-HBase-2.0-client.jar to dependencies and it works perfectly in intellij on local but when i start tomcat in server i get this error message:

org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
                at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
                at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
                at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
                at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1125)
                at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1859)
                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: org.glassfish.jersey.servlet.internal.Utils.store(Lorg/glassfish/jersey/server/ResourceConfig;Ljavax/servlet/ServletContext;)V
                at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.addServletWithExistingRegistration(JerseyServletContainerInitializer.java:310)
                at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartupImpl(JerseyServletContainerInitializer.java:170)
                at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartup(JerseyServletContainerInitializer.java:143)
                at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5154)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
                ... 10 more
07-Feb-2021 09:10:32.298 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Error deploying web application directory 
        java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
                at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:747)
                at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
                at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
                at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1125)
                at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1859)
                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)

and it gets resolved when i remove phoenix-5.0.0-HBase-2.0-client.jar from projects lib folder! servers operating system is centos. i dont use spring boot, gradle or maven.


Solution

  • Welcome to dependency hell! The jar file phoenix-5.0.0-HBase-2.0-client.jar contains the equivalent of 170 jar files (listed below as Maven groupId:artifactId:version). Specifically it contains Jersey 1.19, while you have already Jersey 2.15. Whenever you have multiple version of the same library on your classpath you will get linkage errors as the one in your question. One Jersey library (probably 2.15) tried to load a dependency, but the dependency came from another version (probably 1.19).

    The solution is not to use fat jars like phoenix-5.0.0-HBase-2.0-client.jar, but use Maven or another system to deal with dependencies. They might still get it wrong (e.g. the com.sun.xml.bind and org.glassfish.jaxb's version of jaxb-core contain the same classes, but Maven does not know that), but the result is much better, than manual dependency management.

    In your case, if you just need the org.apache.phoenix.jdbc.PhoenixDriver you need to include the phoenix-core artifact and let Maven do the rest.

    You'll end up with many useless dependencies (e.g. you can immediately exclude the jetty-* dependencies, since those are the libraries of the Jetty Servlet container, as well as hbase-server if you are connecting to an external one), but hopefully there will be no conflicts.

    com.clearspring.analytics:stream:2.9.5
    com.fasterxml.jackson.core:jackson-annotations:2.4.0
    com.fasterxml.jackson.core:jackson-core:2.4.0
    com.fasterxml.jackson.core:jackson-databind:2.4.0
    com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.7.8
    com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.7.8
    com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.7.8
    com.fasterxml.woodstox:woodstox-core:5.0.3
    com.github.stephenc.findbugs:findbugs-annotations:1.3.9-1
    com.github.stephenc.jcip:jcip-annotations:1.0-1
    com.google.code.gson:gson:2.8.1
    com.google.guava:guava:13.0.1
    com.google.protobuf:protobuf-java-util:3.3.0
    com.google.protobuf:protobuf-java:2.5.0
    com.google.re2j:re2j:1.1
    com.jcraft:jsch:0.1.54
    com.nimbusds:nimbus-jose-jwt:4.41.1
    com.salesforce.i18n:i18n-util:1.0.4
    com.squareup.okhttp:okhttp:2.4.0
    com.squareup.okio:okio:1.4.0
    com.sun.jersey.contribs:jersey-guice:1.19
    com.sun.jersey:jersey-client:1.19
    com.sun.jersey:jersey-core:1.19
    com.sun.jersey:jersey-json:1.19
    com.sun.jersey:jersey-server:1.19
    com.sun.jersey:jersey-servlet:1.19
    com.tdunning:json:1.8
    com.thoughtworks.paranamer:paranamer:2.3
    commons-beanutils:commons-beanutils:1.9.3
    commons-cli:commons-cli:1.4
    commons-codec:commons-codec:1.7
    commons-collections:commons-collections:3.2.2
    commons-daemon:commons-daemon:1.0.13
    commons-io:commons-io:2.5
    commons-lang:commons-lang:2.6
    commons-logging:commons-logging:1.2
    commons-net:commons-net:3.1
    io.dropwizard.metrics:metrics-core:3.1.0
    io.netty:netty-all:4.1.17.Final
    io.netty:netty:3.10.5.Final
    javax.annotation:javax.annotation-api:1.2
    javax.servlet.jsp:javax.servlet.jsp-api:2.3.1
    javax.servlet:javax.servlet-api:3.1.0
    javax.validation:validation-api:1.1.0.Final
    javax.ws.rs:javax.ws.rs-api:2.0.1
    javax.ws.rs:jsr311-api:1.1.1
    javax.xml.bind:jaxb-api:2.2.11
    jline:jline:2.11
    log4j:log4j:1.2.17
    net.minidev:accessors-smart:1.1
    net.minidev:json-smart:2.2.1
    org.antlr:antlr-runtime:3.5.2
    org.apache.avro:avro-ipc:1.7.3
    org.apache.avro:avro:1.7.7
    org.apache.commons:commons-collections4:4.1
    org.apache.commons:commons-compress:1.4.1
    org.apache.commons:commons-configuration2:2.1.1
    org.apache.commons:commons-crypto:1.0.0
    org.apache.commons:commons-csv:1.0
    org.apache.commons:commons-lang3:3.6
    org.apache.commons:commons-math3:3.6.1
    org.apache.curator:curator-client:2.12.0
    org.apache.curator:curator-framework:2.12.0
    org.apache.curator:curator-recipes:2.12.0
    org.apache.flume:flume-ng-configuration:1.4.0
    org.apache.flume:flume-ng-core:1.4.0
    org.apache.flume:flume-ng-sdk:1.4.0
    org.apache.hadoop:hadoop-annotations:3.0.0
    org.apache.hadoop:hadoop-auth:3.0.0
    org.apache.hadoop:hadoop-client:3.0.0
    org.apache.hadoop:hadoop-common:3.0.0
    org.apache.hadoop:hadoop-distcp:2.7.4
    org.apache.hadoop:hadoop-hdfs-client:3.0.0
    org.apache.hadoop:hadoop-hdfs:3.0.0
    org.apache.hadoop:hadoop-mapreduce-client-common:3.0.0
    org.apache.hadoop:hadoop-mapreduce-client-core:3.0.0
    org.apache.hadoop:hadoop-mapreduce-client-jobclient:3.0.0
    org.apache.hadoop:hadoop-yarn-api:3.0.0
    org.apache.hadoop:hadoop-yarn-common:3.0.0
    org.apache.hbase.thirdparty:hbase-shaded-miscellaneous:2.1.0
    org.apache.hbase.thirdparty:hbase-shaded-netty:2.1.0
    org.apache.hbase.thirdparty:hbase-shaded-protobuf:2.1.0
    org.apache.hbase:hbase-annotations:2.0.0
    org.apache.hbase:hbase-client:2.0.0
    org.apache.hbase:hbase-common:2.0.0
    org.apache.hbase:hbase-hadoop-compat:2.0.0
    org.apache.hbase:hbase-hadoop2-compat:2.0.0
    org.apache.hbase:hbase-http:2.0.0
    org.apache.hbase:hbase-mapreduce:2.0.0
    org.apache.hbase:hbase-metrics-api:2.0.0
    org.apache.hbase:hbase-metrics:2.0.0
    org.apache.hbase:hbase-procedure:2.0.0
    org.apache.hbase:hbase-protocol-shaded:2.0.0
    org.apache.hbase:hbase-protocol:2.0.0
    org.apache.hbase:hbase-replication:2.0.0
    org.apache.hbase:hbase-server:2.0.0
    org.apache.hbase:hbase-zookeeper:2.0.0
    org.apache.htrace:htrace-core4:4.2.0-incubating
    org.apache.htrace:htrace-core:3.1.0-incubating
    org.apache.httpcomponents:httpclient:4.0.1
    org.apache.httpcomponents:httpcore:4.0.1
    org.apache.kerby:kerb-admin:1.0.1
    org.apache.kerby:kerb-client:1.0.1
    org.apache.kerby:kerb-common:1.0.1
    org.apache.kerby:kerb-core:1.0.1
    org.apache.kerby:kerb-crypto:1.0.1
    org.apache.kerby:kerb-identity:1.0.1
    org.apache.kerby:kerb-server:1.0.1
    org.apache.kerby:kerb-simplekdc:1.0.1
    org.apache.kerby:kerb-util:1.0.1
    org.apache.kerby:kerby-asn1:1.0.1
    org.apache.kerby:kerby-config:1.0.1
    org.apache.kerby:kerby-pkix:1.0.1
    org.apache.kerby:kerby-util:1.0.1
    org.apache.kerby:kerby-xdr:1.0.1
    org.apache.kerby:token-provider:1.0.1
    org.apache.mina:mina-core:2.0.4
    org.apache.phoenix:phoenix-core:5.0.0-HBase-2.0
    org.apache.phoenix:phoenix-flume:5.0.0-HBase-2.0
    org.apache.phoenix:phoenix-pig:5.0.0-HBase-2.0
    org.apache.phoenix:phoenix-spark:5.0.0-HBase-2.0
    org.apache.tephra:tephra-api:0.14.0-incubating
    org.apache.tephra:tephra-core:0.14.0-incubating
    org.apache.tephra:tephra-hbase-compat-2.0:0.14.0-incubating
    org.apache.twill:twill-api:0.8.0
    org.apache.twill:twill-common:0.8.0
    org.apache.twill:twill-core:0.8.0
    org.apache.twill:twill-discovery-api:0.8.0
    org.apache.twill:twill-discovery-core:0.8.0
    org.apache.twill:twill-zookeeper:0.8.0
    org.apache.yetus:audience-annotations:0.5.0
    org.codehaus.jettison:jettison:1.3.8
    org.codehaus.woodstox:stax2-api:3.1.4
    org.eclipse.jetty:jetty-http:9.3.19.v20170502
    org.eclipse.jetty:jetty-io:9.3.19.v20170502
    org.eclipse.jetty:jetty-security:9.3.19.v20170502
    org.eclipse.jetty:jetty-server:9.3.19.v20170502
    org.eclipse.jetty:jetty-servlet:9.3.19.v20170502
    org.eclipse.jetty:jetty-util-ajax:9.3.19.v20170502
    org.eclipse.jetty:jetty-util:9.3.19.v20170502
    org.eclipse.jetty:jetty-webapp:9.3.19.v20170502
    org.eclipse.jetty:jetty-xml:9.3.19.v20170502
    org.fusesource.leveldbjni:leveldbjni-all:1.8
    org.glassfish.hk2.external:aopalliance-repackaged:2.5.0-b32
    org.glassfish.hk2.external:javax.inject:2.5.0-b32
    org.glassfish.hk2:hk2-api:2.5.0-b32
    org.glassfish.hk2:hk2-locator:2.5.0-b32
    org.glassfish.hk2:hk2-utils:2.5.0-b32
    org.glassfish.hk2:osgi-resource-locator:1.0.1
    org.glassfish.jersey.bundles.repackaged:jersey-guava:2.25.1
    org.glassfish.jersey.containers:jersey-container-servlet-core:2.25.1
    org.glassfish.jersey.core:jersey-client:2.25.1
    org.glassfish.jersey.core:jersey-common:2.25.1
    org.glassfish.jersey.core:jersey-server:2.25.1
    org.glassfish.jersey.media:jersey-media-jaxb:2.25.1
    org.glassfish.web:javax.servlet.jsp:2.3.2
    org.glassfish:javax.el:3.0.1-b11-SNAPSHOT
    org.iq80.snappy:snappy:0.3
    org.jamon:jamon-runtime:2.4.1
    org.javassist:javassist:3.20.0-GA
    org.jruby.jcodings:jcodings:1.0.18
    org.jruby.joni:joni:2.1.2
    org.jvnet:tiger-types:1.4
    org.mortbay.jetty:jetty-util:6.1.26
    org.mortbay.jetty:jetty:6.1.26
    org.mortbay.jetty:servlet-api:2.5-20110124
    org.slf4j:slf4j-api:1.6.4
    org.slf4j:slf4j-log4j12:1.7.25
    org.xerial.snappy:snappy-java:1.0.5
    sqlline:sqlline:1.2.0