[JAVA-2701] ClientMetadataHelper.getDriverVersion throws NullPointerException Created: 12/Dec/17  Updated: 28/Oct/23  Resolved: 18/Dec/17

Status: Closed
Project: Java Driver
Component/s: Wire Protocol
Affects Version/s: 3.6.0
Fix Version/s: 3.6.1

Type: Bug Priority: Minor - P4
Reporter: akshay mendole Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: HTML File Error trace     File stormtest-shaded.jar     File stormtest-shaded.jar    

 Description   

I am trying to run a topology code in storm that uses mongoclient.
Upon submitting the command storm jar <jarname> <mainclass>, I am getting following null pointer in the mongo client.

java.lang.NullPointerException
at com.mongodb.connection.ClientMetadataHelper.getDriverVersion(ClientMetadataHelper.java:117) ~[stormjar.jar:?]
at com.mongodb.connection.ClientMetadataHelper.getDriverInformation(ClientMetadataHelper.java:214) ~[stormjar.jar:?]
at com.mongodb.connection.ClientMetadataHelper.addDriverInformation(ClientMetadataHelper.java:195) ~[stormjar.jar:?]
at com.mongodb.connection.ClientMetadataHelper.<clinit>(ClientMetadataHelper.java:65) ~[stormjar.jar:?]
... 50 more

Complete stack trace:
2017-12-12T17:23:03.764+0530 worker [ERROR] Error on initialization of server mk-worker
java.lang.ExceptionInInitializerError
at com.mongodb.connection.InternalStreamConnectionFactory.<init>(InternalStreamConnectionFactory.java:45) ~[stormjar.jar:?]
at com.mongodb.connection.DefaultClusterableServerFactory.create(DefaultClusterableServerFactory.java:64) ~[stormjar.jar:?]
at com.mongodb.connection.BaseCluster.createServer(BaseCluster.java:364) ~[stormjar.jar:?]
at com.mongodb.connection.SingleServerCluster.<init>(SingleServerCluster.java:52) ~[stormjar.jar:?]
at com.mongodb.connection.DefaultClusterFactory.createCluster(DefaultClusterFactory.java:181) ~[stormjar.jar:?]
at com.mongodb.Mongo.createCluster(Mongo.java:738) ~[stormjar.jar:?]
at com.mongodb.Mongo.createCluster(Mongo.java:732) ~[stormjar.jar:?]
at com.mongodb.Mongo.<init>(Mongo.java:298) ~[stormjar.jar:?]
at com.mongodb.Mongo.<init>(Mongo.java:293) ~[stormjar.jar:?]
at com.mongodb.Mongo.<init>(Mongo.java:289) ~[stormjar.jar:?]
at com.mongodb.MongoClient.<init>(MongoClient.java:191) ~[stormjar.jar:?]
at com.mongodb.MongoClient.<init>(MongoClient.java:166) ~[stormjar.jar:?]
at com.mongodb.MongoClient.<init>(MongoClient.java:156) ~[stormjar.jar:?]
at com.flipkart.alchemist.hooks.AffAbstractModule.configure(AffAbstractModule.java:46) ~[stormjar.jar:?]
at com.google.inject.AbstractModule.configure(AbstractModule.java:62) ~[stormjar.jar:?]
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340) ~[stormjar.jar:?]
at com.google.inject.spi.Elements.getElements(Elements.java:110) ~[stormjar.jar:?]
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138) ~[stormjar.jar:?]
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104) ~[stormjar.jar:?]
at com.google.inject.Guice.createInjector(Guice.java:99) ~[stormjar.jar:?]
at com.google.inject.Guice.createInjector(Guice.java:73) ~[stormjar.jar:?]
at com.google.inject.Guice.createInjector(Guice.java:62) ~[stormjar.jar:?]
at com.flipkart.alchemist.hooks.AffWorkerHook.start(AffWorkerHook.java:26) ~[stormjar.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_92]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_92]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_92]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_92]
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93) ~[clojure-1.7.0.jar:?]
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28) ~[clojure-1.7.0.jar:?]
at org.apache.storm.daemon.worker$run_worker_start_hooks$iter_84208424$fn_8425.invoke(worker.clj:569) ~[storm-core-1.0.1.jar:1.0.1]
at clojure.lang.LazySeq.sval(LazySeq.java:40) ~[clojure-1.7.0.jar:?]
at clojure.lang.LazySeq.seq(LazySeq.java:49) ~[clojure-1.7.0.jar:?]
at clojure.lang.RT.seq(RT.java:507) ~[clojure-1.7.0.jar:?]
at clojure.core$seq__4128.invoke(core.clj:137) ~[clojure-1.7.0.jar:?]
at clojure.core$dorun.invoke(core.clj:3009) ~[clojure-1.7.0.jar:?]
at clojure.core$doall.invoke(core.clj:3025) ~[clojure-1.7.0.jar:?]
at org.apache.storm.daemon.worker$run_worker_start_hooks.invoke(worker.clj:566) ~[storm-core-1.0.1.jar:1.0.1]
at org.apache.storm.daemon.worker$fn_8450$exec_fn2461auto$reify_8452.run(worker.clj:635) ~[storm-core-1.0.1.jar:1.0.1]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_92]
at javax.security.auth.Subject.doAs(Subject.java:422) ~[?:1.8.0_92]
at org.apache.storm.daemon.worker$fn_8450$exec_fn2461auto___8451.invoke(worker.clj:609) ~[storm-core-1.0.1.jar:1.0.1]
at clojure.lang.AFn.applyToHelper(AFn.java:178) ~[clojure-1.7.0.jar:?]
at clojure.lang.AFn.applyTo(AFn.java:144) ~[clojure-1.7.0.jar:?]
at clojure.core$apply.invoke(core.clj:630) ~[clojure-1.7.0.jar:?]
at org.apache.storm.daemon.worker$fn_8450$mk_worker_8545.doInvoke(worker.clj:583) [storm-core-1.0.1.jar:1.0.1]
at clojure.lang.RestFn.invoke(RestFn.java:512) [clojure-1.7.0.jar:?]
at org.apache.storm.daemon.worker$_main.invoke(worker.clj:771) [storm-core-1.0.1.jar:1.0.1]
at clojure.lang.AFn.applyToHelper(AFn.java:165) [clojure-1.7.0.jar:?]
at clojure.lang.AFn.applyTo(AFn.java:144) [clojure-1.7.0.jar:?]
at org.apache.storm.daemon.worker.main(Unknown Source) [storm-core-1.0.1.jar:1.0.1]
Caused by: java.lang.NullPointerException
at com.mongodb.connection.ClientMetadataHelper.getDriverVersion(ClientMetadataHelper.java:117) ~[stormjar.jar:?]
at com.mongodb.connection.ClientMetadataHelper.getDriverInformation(ClientMetadataHelper.java:214) ~[stormjar.jar:?]
at com.mongodb.connection.ClientMetadataHelper.addDriverInformation(ClientMetadataHelper.java:195) ~[stormjar.jar:?]
at com.mongodb.connection.ClientMetadataHelper.<clinit>(ClientMetadataHelper.java:65) ~[stormjar.jar:?]
... 50 more



 Comments   
Comment by akshay mendole [ 26/Dec/17 ]

Thanks a lot. This solved the issue.

Comment by Jeffrey Yemin [ 20/Dec/17 ]

You can find a snapshot build of 3.6.1 here.

Comment by SANDEEP REDDY GUTHA [X] [ 20/Dec/17 ]

Hi,
Please find attached Error log
We are trying to get 3.6.x jar to make it fix with above error,

I tired with below test but I am getting some errors can't succeeded Build!!

Build
To build and test the driver:

$ git clone https://github.com/mongodb/mongo-java-driver.git
$ cd mongo-java-driver
$ ./gradlew check

:bson:check
:driver-core:compileJava
Download https://repo1.maven.org/maven2/io/netty/netty-handler/4.1.17.Final/netty-handler-4.1.17.Final.pom
Download https://repo1.maven.org/maven2/io/netty/netty-transport/4.1.17.Final/netty-transport-4.1.17.Final.pom
Download https://repo1.maven.org/maven2/io/netty/netty-buffer/4.1.17.Final/netty-buffer-4.1.17.Final.pom
Download https://repo1.maven.org/maven2/org/xerial/snappy/snappy-java/1.1.4/snappy-java-1.1.4.pom
Download https://repo1.maven.org/maven2/io/netty/netty-parent/4.1.17.Final/netty-parent-4.1.17.Final.pom
Download https://repo1.maven.org/maven2/io/netty/netty-common/4.1.17.Final/netty-common-4.1.17.Final.pom
Download https://repo1.maven.org/maven2/io/netty/netty-resolver/4.1.17.Final/netty-resolver-4.1.17.Final.pom
Download https://repo1.maven.org/maven2/io/netty/netty-codec/4.1.17.Final/netty-codec-4.1.17.Final.pom
Download https://repo1.maven.org/maven2/io/netty/netty-handler/4.1.17.Final/netty-handler-4.1.17.Final.jar
Download https://repo1.maven.org/maven2/io/netty/netty-codec/4.1.17.Final/netty-codec-4.1.17.Final.jar
Download https://repo1.maven.org/maven2/io/netty/netty-transport/4.1.17.Final/netty-transport-4.1.17.Final.jar
Download https://repo1.maven.org/maven2/io/netty/netty-buffer/4.1.17.Final/netty-buffer-4.1.17.Final.jar
Download https://repo1.maven.org/maven2/io/netty/netty-resolver/4.1.17.Final/netty-resolver-4.1.17.Final.jar
Download https://repo1.maven.org/maven2/org/xerial/snappy/snappy-java/1.1.4/snappy-java-1.1.4.jar
Download https://repo1.maven.org/maven2/io/netty/netty-common/4.1.17.Final/netty-common-4.1.17.Final.jar
:driver-core:compileGroovy NO-SOURCE
:driver-core:processResources NO-SOURCE
:driver-core:classes
:driver-core:osgiClasses
:driver-core:jar
:driver:compileJava
:driver:compileGroovy NO-SOURCE
:driver:processResources NO-SOURCE
:driver:classes
:driver:checkstyleMain
:driver:checkstyleTest
:driver:jar
:driver:clirr

Clirr Report
------------
Infos: 357
Warnings: 0
Errors: 192

Please review C:\Users\Vinayaka\mongo-java-driver\driver\build\reports\clirr\compatibility-report.html for more information
:driver:codenarcMain NO-SOURCE
:driver:codenarcTest
:driver:spotbugsMain
Scanning archives (265 / 265)
2 analysis passes to perform
Pass 1: Analyzing classes (717 / 717) - 100% complete
Pass 2: Analyzing classes (255 / 255) - 100% complete
Done with analysis
:driver-core:compileTestJava NO-SOURCE
:driver-core:compileTestGroovy
:driver-core:processTestResources
:driver-core:testClasses
:driver:compileTestJava NO-SOURCE
:driver:compileTestGroovy
:driver:processTestResources
:driver:testClasses
:driver:test
com.mongodb.AggregateIterableSpecification
? should build the expected AggregationOperation (753 ms)
? should build the expected AggregateToCollectionOperation (39 ms)
? should use ClientSession for AggregationOperation (89 ms)
? should use ClientSession for AggregateToCollectionOperation (7 ms)
? should handle exceptions correctly (11 ms)
? should follow the MongoIterable interface as expected (84 ms)

com.mongodb.AggregationOptionsSpecification
? should return new options with the same property values (24 ms)

com.mongodb.BasicDBObjectTest
? testGetStringWithDefault (1 ms)
? testDown1 (199 ms)
? testParse (602 ms)
? testGetLongWithDefault (0 ms)
? testGetDate (1 ms)
? testBuilderIsEmpty (0 ms)
? testGetObjectIdWithDefault (0 ms)
? testGetDateWithDefault (0 ms)
? testEqualsAndHashCode (9 ms)
? testGetObjectId (0 ms)
? testBuilderNested (0 ms)
? testGetDoubleWithDefault (1 ms)
? testToJson (23 ms)

com.mongodb.ChangeStreamIterableSpecification
? should build the expected ChangeStreamOperation (97 ms)
? should use ClientSession (11 ms)
? should handle exceptions correctly (5 ms)
? should follow the MongoIterable interface as expected (36 ms)
? should be able to return the raw results (42 ms)

Comment by Githook User [ 18/Dec/17 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@10gen.com', 'username': 'jyemin'}

Message: JAVA-2701: Add more defensive checks when looking for the driver version to avoid NullPointerException in cases where the driver has been re-packaged without a manifest.
Branch: 3.6.x
https://github.com/mongodb/mongo-java-driver/commit/8c1b46508e2a11607bc64a96805b5892020578ac

Comment by Githook User [ 18/Dec/17 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@10gen.com', 'username': 'jyemin'}

Message: JAVA-2701: Add more defensive checks when looking for the driver version to avoid NullPointerException in cases where the driver has been re-packaged without a manifest.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/da0f80d93bc1c2e0f72d4c926b20b725e13738d2

Comment by Jeffrey Yemin [ 14/Dec/17 ]

We haven't settled on a release date for 3.6.1 yet, but it's not imminent. You can reasonably expect it in mid-January. If you need something quicker, feel free to patch the driver yourself by adding a null check on the return value of java.util.jar.Manifest#getMainAttributes in ClientMetadataHelper.getDriverVersion. I suspect that will work around the issue.

Comment by akshay mendole [ 14/Dec/17 ]

Awesome. Any idea when this will be fixed and released.

Comment by Jeffrey Yemin [ 14/Dec/17 ]

Maybe, but not sure yet what to ask for. I'm running on OS X with a more recent 1.8 JDK, but otherwise I don't see any differences.

But regardless, even without knowing the root cause the fix is obvious, so I'll add this to the 3.6.1 release.

Comment by akshay mendole [ 14/Dec/17 ]

Do you need more information for reproducing this?

Comment by akshay mendole [ 13/Dec/17 ]

I am running this on Linux platform with java build 1.8.0_25-b17.

Comment by Jeffrey Yemin [ 13/Dec/17 ]

Interesting, I run the same command with no error:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jeff/Downloads/stormtest-shaded.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Running: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/Users/jeff/Downloads/apache-storm-1.1.1 -Dstorm.log.dir=/Users/jeff/Downloads/apache-storm-1.1.1/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /Users/jeff/Downloads/apache-storm-1.1.1/lib/slf4j-api-1.7.21.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/minlog-1.3.0.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-api-2.8.2.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/kryo-3.0.3.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/servlet-api-2.5.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/objenesis-2.1.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-over-slf4j-1.6.6.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/asm-5.0.3.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-slf4j-impl-2.8.2.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/storm-core-1.1.1.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/reflectasm-1.10.1.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/ring-cors-0.1.5.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/clojure-1.7.0.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/disruptor-3.3.2.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-core-2.8.2.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/storm-rename-hack-1.1.1.jar:stormtest-shaded.jar:/Users/jeff/Downloads/apache-storm-1.1.1/conf:/Users/jeff/Downloads/apache-storm-1.1.1/bin -Dstorm.jar=stormtest-shaded.jar -Dstorm.dependency.jars= -Dstorm.dependency.artifacts={} storm.TestTopology
hello
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jeff/Downloads/stormtest-shaded.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
754  [main] INFO  o.m.d.cluster - Cluster created with settings {hosts=[10.32.181.152:27300], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}

What's your Java version, and on what platform are you doing this?

Comment by akshay mendole [ 13/Dec/17 ]

Interestingly, the issue does not reproduce when I am trying to run this command locally (on my system) but does reproduce when I try to run the command on the cluster (prod environment).
The version of storm I am using on local and storm is same (1.0.1) .

This is the output when I run the command in cluster mode.

 
storm jar stormtest-shaded.jar storm.TestTopology
Running: java -server -Ddaemon.name= -Dstorm.options= -Dstorm.home=/usr/share/fk-3p-storm -Dstorm.log.dir=/usr/share/fk-3p-storm/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /usr/share/fk-3p-storm/lib/slf4j-api-1.7.7.jar:/usr/share/fk-3p-storm/lib/reflectasm-1.10.1.jar:/usr/share/fk-3p-storm/lib/objenesis-2.1.jar:/usr/share/fk-3p-storm/lib/disruptor-3.3.2.jar:/usr/share/fk-3p-storm/lib/log4j-core-2.1.jar:/usr/share/fk-3p-storm/lib/storm-core-1.0.1.jar:/usr/share/fk-3p-storm/lib/storm-rename-hack-1.0.1.jar:/usr/share/fk-3p-storm/lib/servlet-api-2.5.jar:/usr/share/fk-3p-storm/lib/clojure-1.7.0.jar:/usr/share/fk-3p-storm/lib/log4j-over-slf4j-1.6.6.jar:/usr/share/fk-3p-storm/lib/log4j-slf4j-impl-2.1.jar:/usr/share/fk-3p-storm/lib/asm-5.0.3.jar:/usr/share/fk-3p-storm/lib/minlog-1.3.0.jar:/usr/share/fk-3p-storm/lib/log4j-api-2.1.jar:/usr/share/fk-3p-storm/lib/kryo-3.0.3.jar org.apache.storm.daemon.ClientJarTransformerRunner org.apache.storm.hack.StormShadeTransformer stormtest-shaded.jar /tmp/b71d3d86dfb711e7b93202010a21a1d5.jar
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/share/fk-3p-storm/lib/log4j-slf4j-impl-2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/tmp/b71d3d86dfb711e7b93202010a21a1d5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Running: java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/usr/share/fk-3p-storm -Dstorm.log.dir=/usr/share/fk-3p-storm/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /usr/share/fk-3p-storm/lib/slf4j-api-1.7.7.jar:/usr/share/fk-3p-storm/lib/reflectasm-1.10.1.jar:/usr/share/fk-3p-storm/lib/objenesis-2.1.jar:/usr/share/fk-3p-storm/lib/disruptor-3.3.2.jar:/usr/share/fk-3p-storm/lib/log4j-core-2.1.jar:/usr/share/fk-3p-storm/lib/storm-core-1.0.1.jar:/usr/share/fk-3p-storm/lib/storm-rename-hack-1.0.1.jar:/usr/share/fk-3p-storm/lib/servlet-api-2.5.jar:/usr/share/fk-3p-storm/lib/clojure-1.7.0.jar:/usr/share/fk-3p-storm/lib/log4j-over-slf4j-1.6.6.jar:/usr/share/fk-3p-storm/lib/log4j-slf4j-impl-2.1.jar:/usr/share/fk-3p-storm/lib/asm-5.0.3.jar:/usr/share/fk-3p-storm/lib/minlog-1.3.0.jar:/usr/share/fk-3p-storm/lib/log4j-api-2.1.jar:/usr/share/fk-3p-storm/lib/kryo-3.0.3.jar:/tmp/b71d3d86dfb711e7b93202010a21a1d5.jar:/usr/share/fk-3p-storm/conf:/usr/share/fk-3p-storm/bin -Dstorm.jar=/tmp/b71d3d86dfb711e7b93202010a21a1d5.jar storm.TestTopology
hello
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/share/fk-3p-storm/lib/log4j-slf4j-impl-2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/tmp/b71d3d86dfb711e7b93202010a21a1d5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
574  [main] INFO  o.m.d.cluster - Cluster created with settings {hosts=[10.32.181.152:27300], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.mongodb.connection.InternalStreamConnectionFactory.<init>(InternalStreamConnectionFactory.java:45)
	at com.mongodb.connection.DefaultClusterableServerFactory.create(DefaultClusterableServerFactory.java:64)
	at com.mongodb.connection.BaseCluster.createServer(BaseCluster.java:364)
	at com.mongodb.connection.SingleServerCluster.<init>(SingleServerCluster.java:52)
	at com.mongodb.connection.DefaultClusterFactory.createCluster(DefaultClusterFactory.java:181)
	at com.mongodb.Mongo.createCluster(Mongo.java:738)
	at com.mongodb.Mongo.createCluster(Mongo.java:732)
	at com.mongodb.Mongo.<init>(Mongo.java:298)
	at com.mongodb.Mongo.<init>(Mongo.java:293)
	at com.mongodb.Mongo.<init>(Mongo.java:289)
	at com.mongodb.MongoClient.<init>(MongoClient.java:191)
	at com.mongodb.MongoClient.<init>(MongoClient.java:166)
	at com.mongodb.MongoClient.<init>(MongoClient.java:156)
	at storm.TestTopology.main(TestTopology.java:20)
Caused by: java.lang.NullPointerException
	at com.mongodb.connection.ClientMetadataHelper.getDriverVersion(ClientMetadataHelper.java:117)
	at com.mongodb.connection.ClientMetadataHelper.getDriverInformation(ClientMetadataHelper.java:214)
	at com.mongodb.connection.ClientMetadataHelper.addDriverInformation(ClientMetadataHelper.java:195)
	at com.mongodb.connection.ClientMetadataHelper.<clinit>(ClientMetadataHelper.java:65)
	... 14 more

Comment by Jeffrey Yemin [ 12/Dec/17 ]

I attempted to reproduce this and got these results:

~/Downloads (master)$ apache-storm-1.1.1/bin/storm jar stormtest-shaded.jar storm.TestTopology
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jeff/Downloads/stormtest-shaded.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Running: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/Users/jeff/Downloads/apache-storm-1.1.1 -Dstorm.log.dir=/Users/jeff/Downloads/apache-storm-1.1.1/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /Users/jeff/Downloads/apache-storm-1.1.1/lib/slf4j-api-1.7.21.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/minlog-1.3.0.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-api-2.8.2.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/kryo-3.0.3.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/servlet-api-2.5.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/objenesis-2.1.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-over-slf4j-1.6.6.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/asm-5.0.3.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-slf4j-impl-2.8.2.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/storm-core-1.1.1.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/reflectasm-1.10.1.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/ring-cors-0.1.5.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/clojure-1.7.0.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/disruptor-3.3.2.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-core-2.8.2.jar:/Users/jeff/Downloads/apache-storm-1.1.1/lib/storm-rename-hack-1.1.1.jar:stormtest-shaded.jar:/Users/jeff/Downloads/apache-storm-1.1.1/conf:/Users/jeff/Downloads/apache-storm-1.1.1/bin -Dstorm.jar=stormtest-shaded.jar -Dstorm.dependency.jars= -Dstorm.dependency.artifacts={} storm.TestTopology
hello
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/jeff/Downloads/apache-storm-1.1.1/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jeff/Downloads/stormtest-shaded.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
754  [main] INFO  o.m.d.cluster - Cluster created with settings {hosts=[10.32.181.152:27300], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}

Can you suggest what might be different about my invocation? Can you include the full output of the command?

Comment by akshay mendole [ 12/Dec/17 ]

This time I wrote a simple main class that does not try to submit any topology to storm. In the previous case, storm would create its own jar and pack all the required classes in stormjar.jar, but now I have simply created a driver class that does nothing but initialised the mongo client.
After submitting "storm jar stormtest-shaded.jar storm.TestTopology". I get the following stack trace.

Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mongodb.connection.InternalStreamConnectionFactory.<init>(InternalStreamConnectionFactory.java:45)
at com.mongodb.connection.DefaultClusterableServerFactory.create(DefaultClusterableServerFactory.java:64)
at com.mongodb.connection.BaseCluster.createServer(BaseCluster.java:364)
at com.mongodb.connection.SingleServerCluster.<init>(SingleServerCluster.java:52)
at com.mongodb.connection.DefaultClusterFactory.createCluster(DefaultClusterFactory.java:181)
at com.mongodb.Mongo.createCluster(Mongo.java:738)
at com.mongodb.Mongo.createCluster(Mongo.java:732)
at com.mongodb.Mongo.<init>(Mongo.java:298)
at com.mongodb.Mongo.<init>(Mongo.java:293)
at com.mongodb.Mongo.<init>(Mongo.java:289)
at com.mongodb.MongoClient.<init>(MongoClient.java:191)
at com.mongodb.MongoClient.<init>(MongoClient.java:166)
at com.mongodb.MongoClient.<init>(MongoClient.java:156)
at storm.TestTopology.main(TestTopology.java:20)
Caused by: java.lang.NullPointerException
at com.mongodb.connection.ClientMetadataHelper.getDriverVersion(ClientMetadataHelper.java:117)
at com.mongodb.connection.ClientMetadataHelper.getDriverInformation(ClientMetadataHelper.java:214)
at com.mongodb.connection.ClientMetadataHelper.addDriverInformation(ClientMetadataHelper.java:195)
at com.mongodb.connection.ClientMetadataHelper.<clinit>(ClientMetadataHelper.java:65)
... 14 more

I have also attached the jar for your reference
stormtest-shaded.jar

Comment by Jeffrey Yemin [ 12/Dec/17 ]

One of these two methods is returning null:

  • java.net.JarURLConnection#getManifest
  • java.util.jar.Manifest#getMainAttributes

It looks like the Java driver is being vendored by Storm rather than deployed in its own jar file. Please either attach or let us know where we can download stormjar.jar (referenced in the stack trace above) so that we can investigate further.

Update

Code inspection reveals that java.util.jar.Manifest#getMainAttributes can never return null, so the only remaining culprit is java.net.JarURLConnection#getManifest

Comment by akshay mendole [ 12/Dec/17 ]

I saw similar issue JAVA-2449 reported this year

Generated at Thu Feb 08 08:57:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.