问题
I have developed a java application and made it a jar file. I bundled all the dependencies using mvn clean package
maven-shaded-plugin.
My problem is that although the application works fine in my local machine, it does not work in the server environment. Whenever I run it, I get a NullPointerException
which means the variable is not being initialized, which implies the underlying dependency is not working properly.
The original question I posted is in here: JMS connection not connecting to remote JBoss but connects local instance
I tried to run this on different servers, all of which were unsuccessful. When I re-built the package again, I found these warnings, some of which say that some jars are omitted due to them being strongly coupled.
I am using maven-shade-plugin without another way of testing the jar on test server. Because I cannot copy entire project and re-compile at the server (an uber-jar seemed a shortcut for me to quickly test it on both Windows and Linux servers). Server machine only have java installed. It does not have maven either to re-download the dependencies there. (Also I don't want my jar to depend on maven so I can copy it and run anywhere)
Are these warnings culprit for my jar not working on the server? Please help with any other alternatives.
The complete maven log is here:
E:\Programs\Tutorials\Appia\appia_jms_bridge_component>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.gmt:component >--------------------------
[INFO] Building BRIDGE_COMPONENT 0.2.5-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ component ---
[INFO] Deleting E:\Programs\Tutorials\Appia\appia_jms_bridge_component\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ component ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ component ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to E:\Programs\Tutorials\Appia\appia_jms_bridge_component\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ component ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Programs\Tutorials\Appia\appia_jms_bridge_component\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ component ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ component ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ component ---
[INFO] Building jar: E:\Programs\Tutorials\Appia\appia_jms_bridge_component\target\BRIDGE_COMPONENT.jar
[INFO]
[INFO] --- maven-shade-plugin:3.2.4:shade (default) @ component ---
[INFO] Including org.apache.commons:commons-lang3:jar:3.11 in the shaded jar.
[INFO] Including org.slf4j:slf4j-api:jar:1.7.6 in the shaded jar.
[INFO] Including org.slf4j:slf4j-log4j12:jar:1.7.5 in the shaded jar.
[INFO] Including log4j:log4j:jar:1.2.17 in the shaded jar.
[INFO] Including com.leansoft:bigqueue:jar:0.7.0 in the shaded jar.
[INFO] Including org.jboss.eap:wildfly-client-properties:jar:7.3.3.GA-redhat-00004 in the shaded jar.
[INFO] Including com.google.guava:guava:jar:25.0.0.redhat-1 in the shaded jar.
[INFO] Including commons-beanutils:commons-beanutils:jar:1.9.4.redhat-00002 in the shaded jar.
[INFO] Including commons-collections:commons-collections:jar:3.2.2.redhat-2 in the shaded jar.
[INFO] Including io.netty:netty-all:jar:4.1.48.Final-redhat-00001 in the shaded jar.
[INFO] Including org.apache.activemq:artemis-commons:jar:2.9.0.redhat-00011 in the shaded jar.
[INFO] Including org.apache.activemq:artemis-core-client:jar:2.9.0.redhat-00011 in the shaded jar.
[INFO] Including org.apache.activemq:artemis-hqclient-protocol:jar:2.9.0.redhat-00011 in the shaded jar.
[INFO] Including org.apache.activemq:artemis-jms-client:jar:2.9.0.redhat-00011 in the shaded jar.
[INFO] Including org.apache.activemq:artemis-selector:jar:2.9.0.redhat-00011 in the shaded jar.
[INFO] Including org.jboss.spec.javax.jms:jboss-jms-api_2.0_spec:jar:2.0.0.Final-redhat-00001 in the shaded jar.
[INFO] Including org.jgroups:jgroups:jar:4.1.10.Final-redhat-00001 in the shaded jar.
[INFO] Including org.wildfly:wildfly-naming-client:jar:1.0.13.Final-redhat-00001 in the shaded jar.
[INFO] Including jakarta.json:jakarta.json-api:jar:1.1.6.redhat-00001 in the shaded jar.
[INFO] Including org.glassfish:jakarta.json:jar:1.1.6.redhat-00001 in the shaded jar.
[INFO] Including org.jboss.logging:jboss-logging:jar:3.4.1.Final-redhat-00001 in the shaded jar.
[INFO] Including org.jboss.marshalling:jboss-marshalling:jar:2.0.9.Final-redhat-00001 in the shaded jar.
[INFO] Including org.jboss.marshalling:jboss-marshalling-river:jar:2.0.9.Final-redhat-00001 in the shaded jar.
[INFO] Including org.jboss.remoting:jboss-remoting:jar:5.0.18.Final-redhat-00001 in the shaded jar.
[INFO] Including org.jboss.threads:jboss-threads:jar:2.3.3.Final-redhat-00001 in the shaded jar.
[INFO] Including org.jboss.xnio:xnio-api:jar:3.7.9.Final-redhat-00001 in the shaded jar.
[INFO] Including org.jboss.xnio:xnio-nio:jar:3.7.9.Final-redhat-00001 in the shaded jar.
[INFO] Including org.slf4j:jcl-over-slf4j:jar:1.7.22.redhat-2 in the shaded jar.
[INFO] Including org.wildfly.client:wildfly-client-config:jar:1.0.1.Final-redhat-00001 in the shaded jar.
[INFO] Including org.wildfly.common:wildfly-common:jar:1.5.2.Final-redhat-00002 in the shaded jar.
[INFO] Including org.wildfly.security:wildfly-elytron:jar:1.10.8.Final-redhat-00001 in the shaded jar.
[INFO] Including com.javatech:appia:jar:1.0.0 in the shaded jar.
[INFO] Including org.apache.maven.plugins:maven-compiler-plugin:jar:3.8.1 in the shaded jar.
[INFO] Including org.apache.maven:maven-plugin-api:jar:3.0 in the shaded jar.
[INFO] Including org.apache.maven:maven-model:jar:3.0 in the shaded jar.
[INFO] Including org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2 in the shaded jar.
[INFO] Including org.sonatype.sisu:sisu-inject-bean:jar:1.4.2 in the shaded jar.
[INFO] Including org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7 in the shaded jar.
[INFO] Including org.apache.maven:maven-artifact:jar:3.0 in the shaded jar.
[INFO] Including org.codehaus.plexus:plexus-utils:jar:2.0.4 in the shaded jar.
[INFO] Including org.apache.maven:maven-core:jar:3.0 in the shaded jar.
[INFO] Including org.apache.maven:maven-settings:jar:3.0 in the shaded jar.
[INFO] Including org.apache.maven:maven-settings-builder:jar:3.0 in the shaded jar.
[INFO] Including org.apache.maven:maven-repository-metadata:jar:3.0 in the shaded jar.
[INFO] Including org.apache.maven:maven-model-builder:jar:3.0 in the shaded jar.
[INFO] Including org.apache.maven:maven-aether-provider:jar:3.0 in the shaded jar.
[INFO] Including org.sonatype.aether:aether-impl:jar:1.7 in the shaded jar.
[INFO] Including org.sonatype.aether:aether-spi:jar:1.7 in the shaded jar.
[INFO] Including org.sonatype.aether:aether-api:jar:1.7 in the shaded jar.
[INFO] Including org.sonatype.aether:aether-util:jar:1.7 in the shaded jar.
[INFO] Including org.codehaus.plexus:plexus-interpolation:jar:1.14 in the shaded jar.
[INFO] Including org.codehaus.plexus:plexus-classworlds:jar:2.2.3 in the shaded jar.
[INFO] Including org.codehaus.plexus:plexus-component-annotations:jar:1.5.5 in the shaded jar.
[INFO] Including org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3 in the shaded jar.
[INFO] Including org.sonatype.plexus:plexus-cipher:jar:1.4 in the shaded jar.
[INFO] Including org.apache.maven.shared:maven-shared-utils:jar:3.2.1 in the shaded jar.
[INFO] Including commons-io:commons-io:jar:2.5 in the shaded jar.
[INFO] Including org.apache.maven.shared:maven-shared-incremental:jar:1.1 in the shaded jar.
[INFO] Including org.codehaus.plexus:plexus-java:jar:0.9.10 in the shaded jar.
[INFO] Including org.ow2.asm:asm:jar:6.2 in the shaded jar.
[INFO] Including com.thoughtworks.qdox:qdox:jar:2.0-M8 in the shaded jar.
[INFO] Including org.codehaus.plexus:plexus-compiler-api:jar:2.8.4 in the shaded jar.
[INFO] Including org.codehaus.plexus:plexus-compiler-manager:jar:2.8.4 in the shaded jar.
[INFO] Including org.codehaus.plexus:plexus-compiler-javac:jar:2.8.4 in the shaded jar.
[INFO] Skipping pom dependency org.jboss.eap:wildfly-jms-client-bom:pom:7.3.3.GA in the shaded jar.
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
[WARNING] BRIDGE_COMPONENT.jar, aether-api-1.7.jar, aether-impl-1.7.jar, aether-spi-1.7.jar, aether-util-1.7.jar, appia-1.0.0.jar, artemis-commons-2.9.0.redhat-00011.ja
r, artemis-core-client-2.9.0.redhat-00011.jar, artemis-hqclient-protocol-2.9.0.redhat-00011.jar, artemis-jms-client-2.9.0.redhat-00011.jar, artemis-selector-2.9.0.redha
t-00011.jar, asm-6.2.jar, bigqueue-0.7.0.jar, commons-beanutils-1.9.4.redhat-00002.jar, commons-collections-3.2.2.redhat-2.jar, commons-io-2.5.jar, commons-lang3-3.11.j
ar, guava-25.0.0.redhat-1.jar, jakarta.json-1.1.6.redhat-00001.jar, jakarta.json-api-1.1.6.redhat-00001.jar, jboss-jms-api_2.0_spec-2.0.0.Final-redhat-00001.jar, jboss-
logging-3.4.1.Final-redhat-00001.jar, jboss-marshalling-2.0.9.Final-redhat-00001.jar, jboss-marshalling-river-2.0.9.Final-redhat-00001.jar, jboss-remoting-5.0.18.Final-
redhat-00001.jar, jboss-threads-2.3.3.Final-redhat-00001.jar, jcl-over-slf4j-1.7.22.redhat-2.jar, jgroups-4.1.10.Final-redhat-00001.jar, log4j-1.2.17.jar, maven-aether-
provider-3.0.jar, maven-artifact-3.0.jar, maven-compiler-plugin-3.8.1.jar, maven-core-3.0.jar, maven-model-3.0.jar, maven-model-builder-3.0.jar, maven-plugin-api-3.0.ja
r, maven-repository-metadata-3.0.jar, maven-settings-3.0.jar, maven-settings-builder-3.0.jar, maven-shared-incremental-1.1.jar, maven-shared-utils-3.2.1.jar, netty-all-
4.1.48.Final-redhat-00001.jar, plexus-cipher-1.4.jar, plexus-classworlds-2.2.3.jar, plexus-compiler-api-2.8.4.jar, plexus-compiler-javac-2.8.4.jar, plexus-compiler-mana
ger-2.8.4.jar, plexus-component-annotations-1.5.5.jar, plexus-interpolation-1.14.jar, plexus-java-0.9.10.jar, plexus-sec-dispatcher-1.3.jar, plexus-utils-2.0.4.jar, qdo
x-2.0-M8.jar, sisu-guice-2.1.7-noaop.jar, sisu-inject-bean-1.4.2.jar, sisu-inject-plexus-1.4.2.jar, slf4j-api-1.7.6.jar, slf4j-log4j12-1.7.5.jar, wildfly-client-config-
1.0.1.Final-redhat-00001.jar, wildfly-client-properties-7.3.3.GA-redhat-00004.jar, wildfly-common-1.5.2.Final-redhat-00002.jar, wildfly-elytron-1.10.8.Final-redhat-0000
1.jar, wildfly-naming-client-1.0.13.Final-redhat-00001.jar, xnio-api-3.7.9.Final-redhat-00001.jar, xnio-nio-3.7.9.Final-redhat-00001.jar define 1 overlapping resource:
[WARNING] - META-INF/MANIFEST.MF
[WARNING] commons-beanutils-1.9.4.redhat-00002.jar, commons-collections-3.2.2.redhat-2.jar, commons-io-2.5.jar, commons-lang3-3.11.jar, jboss-logging-3.4.1.Final-redhat
-00001.jar, jboss-threads-2.3.3.Final-redhat-00001.jar, wildfly-elytron-1.10.8.Final-redhat-00001.jar define 1 overlapping resource:
[WARNING] - META-INF/LICENSE.txt
[WARNING] commons-beanutils-1.9.4.redhat-00002.jar, commons-collections-3.2.2.redhat-2.jar, commons-io-2.5.jar, commons-lang3-3.11.jar define 1 overlapping resource:
[WARNING] - META-INF/NOTICE.txt
[WARNING] artemis-commons-2.9.0.redhat-00011.jar, artemis-core-client-2.9.0.redhat-00011.jar, artemis-hqclient-protocol-2.9.0.redhat-00011.jar, artemis-jms-client-2.9.0
.redhat-00011.jar, artemis-selector-2.9.0.redhat-00011.jar, log4j-1.2.17.jar, maven-aether-provider-3.0.jar, maven-artifact-3.0.jar, maven-compiler-plugin-3.8.1.jar, ma
ven-core-3.0.jar, maven-model-3.0.jar, maven-model-builder-3.0.jar, maven-plugin-api-3.0.jar, maven-repository-metadata-3.0.jar, maven-settings-3.0.jar, maven-settings-
builder-3.0.jar, maven-shared-incremental-1.1.jar, maven-shared-utils-3.2.1.jar, plexus-utils-2.0.4.jar define 2 overlapping resources:
[WARNING] - META-INF/LICENSE
[WARNING] - META-INF/NOTICE
[WARNING] artemis-commons-2.9.0.redhat-00011.jar, artemis-core-client-2.9.0.redhat-00011.jar, artemis-jms-client-2.9.0.redhat-00011.jar, artemis-selector-2.9.0.redhat-0
0011.jar, commons-beanutils-1.9.4.redhat-00002.jar, commons-collections-3.2.2.redhat-2.jar, jboss-jms-api_2.0_spec-2.0.0.Final-redhat-00001.jar, jboss-logging-3.4.1.Fin
al-redhat-00001.jar, jboss-marshalling-2.0.9.Final-redhat-00001.jar, jboss-marshalling-river-2.0.9.Final-redhat-00001.jar, jboss-remoting-5.0.18.Final-redhat-00001.jar,
jboss-threads-2.3.3.Final-redhat-00001.jar, jcl-over-slf4j-1.7.22.redhat-2.jar, wildfly-client-config-1.0.1.Final-redhat-00001.jar, wildfly-client-properties-7.3.3.GA-
redhat-00004.jar, wildfly-common-1.5.2.Final-redhat-00002.jar, wildfly-elytron-1.10.8.Final-redhat-00001.jar, wildfly-naming-client-1.0.13.Final-redhat-00001.jar, xnio-
api-3.7.9.Final-redhat-00001.jar, xnio-nio-3.7.9.Final-redhat-00001.jar define 1 overlapping resource:
[WARNING] - META-INF/build.metadata
[WARNING] artemis-commons-2.9.0.redhat-00011.jar, artemis-core-client-2.9.0.redhat-00011.jar, artemis-hqclient-protocol-2.9.0.redhat-00011.jar, artemis-jms-client-2.9.0
.redhat-00011.jar, artemis-selector-2.9.0.redhat-00011.jar, maven-aether-provider-3.0.jar, maven-artifact-3.0.jar, maven-compiler-plugin-3.8.1.jar, maven-core-3.0.jar,
maven-model-3.0.jar, maven-model-builder-3.0.jar, maven-plugin-api-3.0.jar, maven-repository-metadata-3.0.jar, maven-settings-3.0.jar, maven-settings-builder-3.0.jar, m
aven-shared-incremental-1.1.jar, maven-shared-utils-3.2.1.jar define 1 overlapping resource:
[WARNING] - META-INF/DEPENDENCIES
[WARNING] jakarta.json-1.1.6.redhat-00001.jar, jakarta.json-api-1.1.6.redhat-00001.jar, jboss-jms-api_2.0_spec-2.0.0.Final-redhat-00001.jar define 2 overlapping resourc
es:
[WARNING] - META-INF/LICENSE.md
[WARNING] - META-INF/NOTICE.md
[WARNING] jakarta.json-1.1.6.redhat-00001.jar, jakarta.json-api-1.1.6.redhat-00001.jar define 34 overlapping classes:
[WARNING] - javax.json.EmptyArray
[WARNING] - javax.json.EmptyObject
[WARNING] - javax.json.Json
[WARNING] - javax.json.JsonArray
[WARNING] - javax.json.JsonArrayBuilder
[WARNING] - javax.json.JsonBuilderFactory
[WARNING] - javax.json.JsonException
[WARNING] - javax.json.JsonMergePatch
[WARNING] - javax.json.JsonNumber
[WARNING] - javax.json.JsonObject
[WARNING] - 24 more...
[WARNING] jboss-logging-3.4.1.Final-redhat-00001.jar, wildfly-elytron-1.10.8.Final-redhat-00001.jar define 37 overlapping classes and resources:
[WARNING] - META-INF/maven/org.jboss.logging/jboss-logging/pom.properties
[WARNING] - META-INF/maven/org.jboss.logging/jboss-logging/pom.xml
[WARNING] - org.jboss.logging.AbstractLoggerProvider
[WARNING] - org.jboss.logging.AbstractLoggerProvider$Entry
[WARNING] - org.jboss.logging.AbstractMdcLoggerProvider
[WARNING] - org.jboss.logging.BasicLogger
[WARNING] - org.jboss.logging.DelegatingBasicLogger
[WARNING] - org.jboss.logging.JBossLogManagerLogger
[WARNING] - org.jboss.logging.JBossLogManagerProvider
[WARNING] - org.jboss.logging.JBossLogManagerProvider$1
[WARNING] - 27 more...
[WARNING] aether-impl-1.7.jar, maven-aether-provider-3.0.jar, maven-core-3.0.jar, maven-model-builder-3.0.jar, maven-settings-builder-3.0.jar, plexus-cipher-1.4.jar, pl
exus-compiler-javac-2.8.4.jar, plexus-compiler-manager-2.8.4.jar, plexus-java-0.9.10.jar, plexus-sec-dispatcher-1.3.jar, sisu-inject-plexus-1.4.2.jar define 1 overlappi
ng resource:
[WARNING] - META-INF/plexus/components.xml
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/
[INFO] Attaching shaded artifact.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.149 s
[INFO] Finished at: 2020-12-14T20:14:36+05:30
[INFO] ------------------------------------------------------------------------
来源:https://stackoverflow.com/questions/65293636/is-maven-shade-plugin-culprit-for-my-jar-to-not-work-in-server