morphia icon indicating copy to clipboard operation
morphia copied to clipboard

ReflectionUtils.readFromNestedJar throwing NPE

Open saikrishna-chunchu opened this issue 7 years ago • 3 comments

I am getting below NPE exception in my project. It looks like, morpia is unable to read the dependency Jars that are part of my project. Unfortunately, I didn't find a decent amount of logs in this section of the code to gather more information.

Failed to initialize mongodb connection java.lang.NullPointerException: in is null at java.util.zip.ZipInputStream.(ZipInputStream.java:101) at java.util.zip.ZipInputStream.(ZipInputStream.java:80) at java.util.jar.JarInputStream.(JarInputStream.java:76) at java.util.jar.JarInputStream.(JarInputStream.java:62) at dev.morphia.utils.ReflectionUtils.readFromNestedJar(ReflectionUtils.java:554) at dev.morphia.utils.ReflectionUtils.getClasses(ReflectionUtils.java:523) at dev.morphia.Morphia.mapPackage(Morphia.java:243)

Morphia Version: 1.5.5
Driver Version (mongo-java-driver): 

saikrishna-chunchu avatar Nov 22 '19 17:11 saikrishna-chunchu

Can you try with 1.5.8? I want to say I've fixed things in that area lately but I might be confusing things with the 2.0 branch. I'll dig it in to a bit myself, too.

evanchooly avatar Nov 25 '19 02:11 evanchooly

I am not observing this issue with 1.5.8. Thanks.

What is the root cause of this issue? The major difference I see between these two releases(in this section of the code ) is, how we read the classes(using classGraph library instead of custom logic).

saikrishna-chunchu avatar Nov 25 '19 20:11 saikrishna-chunchu

That was it primarily. The old code had always been fragile and I'd never much cared for it. It'd been the fantasy of a few years now to replace it. That day finally arrived. :) glad to hear it fixed things for you.

evanchooly avatar Nov 25 '19 20:11 evanchooly