-
-
Notifications
You must be signed in to change notification settings - Fork 1
NullPointerException when trying to initialize the driver in uber jar #8
Description
I'm looking into using burningwave to help out a Java-based CLI tool which needs to support Java 16+. I've added this line of code inside my main method
org.burningwave.core.assembler.StaticComponentContainer.Modules.exportAllToAll();
If I include the burningwave core and jvm-driver jars in the classpath, everything seems to be working at first blush. However, my tool needs to be able to be called via
java -jar mytool.jar
and therefore any libraries needed to bootstrap it are "shaded" into the main "uber" jar. When I copy the class files, banner.bwb file and jvm-driver.properties file into my uber jar, I get this error.
io.github.toolfactory.jvm.util.ObjectProvider$BuildingException: Exception occurred while retrieving the implementation of class io.github.toolfactory.jvm.function.catalog.GetResourcesFunction (jvm architecture: x64, jvm version: 17, jvm vendor: Eclipse Adoptium)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObject(ObjectProvider.java:95)
at io.github.toolfactory.jvm.DriverAbst.getOrBuildResourcesRetriever(DriverAbst.java:436)
at io.github.toolfactory.jvm.DriverAbst.getResources(DriverAbst.java:884)
at org.burningwave.core.io.Resources.lambda$getAsInputStream$3(Resources.java:160)
at org.burningwave.core.io.Resources.getAsInputStream(Resources.java:165)
at org.burningwave.core.io.Resources.getAsInputStream(Resources.java:158)
at org.burningwave.core.assembler.StaticComponentContainer.showBanner(StaticComponentContainer.java:585)
at org.burningwave.core.assembler.StaticComponentContainer.<clinit>(StaticComponentContainer.java:363)
at cliloader.LoaderCLIMain.main(LoaderCLIMain.java:557)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObjectInternal(ObjectProvider.java:144)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObject(ObjectProvider.java:92)
... 8 more
Caused by: io.github.toolfactory.jvm.util.ObjectProvider$BuildingException: Exception occurred while retrieving the implementation of class io.github.toolfactory.jvm.function.catalog.DeepConsulterSupplyFunction (jvm architecture: x64, jvm version: 17, jvm vendor: Eclipse Adoptium)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObject(ObjectProvider.java:95)
at io.github.toolfactory.jvm.function.catalog.GetResourcesFunction$ForJava9.buildResourceFinder(GetResourcesFunction.java:129)
at io.github.toolfactory.jvm.function.catalog.GetResourcesFunction$Abst.<init>(GetResourcesFunction.java:56)
at io.github.toolfactory.jvm.function.catalog.GetResourcesFunction$ForJava7.<init>(GetResourcesFunction.java:92)
at io.github.toolfactory.jvm.function.catalog.GetResourcesFunction$ForJava9.<init>(GetResourcesFunction.java:123)
... 15 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObjectInternal(ObjectProvider.java:144)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObject(ObjectProvider.java:92)
... 19 more
Caused by: io.github.toolfactory.jvm.util.ObjectProvider$BuildingException: Exception occurred while retrieving the implementation of class io.github.toolfactory.jvm.function.catalog.GetDeclaredFieldFunction (jvm architecture: x64, jvm version: 17, jvm vendor: Eclipse Adoptium)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObject(ObjectProvider.java:95)
at io.github.toolfactory.jvm.function.catalog.DeepConsulterSupplyFunction$ForJava14.<init>(DeepConsulterSupplyFunction.java:168)
... 26 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObjectInternal(ObjectProvider.java:144)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObject(ObjectProvider.java:92)
... 27 more
Caused by: io.github.toolfactory.jvm.util.ObjectProvider$BuildingException: Exception occurred while retrieving the implementation of class io.github.toolfactory.jvm.function.catalog.GetDeclaredFieldsFunction (jvm architecture: x64, jvm version: 17, jvm vendor: Eclipse Adoptium)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObject(ObjectProvider.java:95)
at io.github.toolfactory.jvm.function.catalog.GetDeclaredFieldFunction$ForJava7.<init>(GetDeclaredFieldFunction.java:45)
... 34 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObjectInternal(ObjectProvider.java:144)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObject(ObjectProvider.java:92)
... 35 more
Caused by: io.github.toolfactory.jvm.util.ObjectProvider$BuildingException: Exception occurred while retrieving the implementation of class io.github.toolfactory.jvm.function.catalog.ConsulterSupplyFunction (jvm architecture: x64, jvm version: 17, jvm vendor: Eclipse Adoptium)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObject(ObjectProvider.java:95)
at io.github.toolfactory.jvm.function.catalog.GetDeclaredFieldsFunction$ForJava7.<init>(GetDeclaredFieldsFunction.java:55)
... 42 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObjectInternal(ObjectProvider.java:144)
at io.github.toolfactory.jvm.util.ObjectProvider.getOrBuildObject(ObjectProvider.java:92)
... 43 more
Caused by: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[])" because "input" is null
at io.github.toolfactory.jvm.util.Streams.copy(Streams.java:48)
at io.github.toolfactory.jvm.util.Streams.toByteArray(Streams.java:40)
at io.github.toolfactory.jvm.function.catalog.ConsulterSupplyFunction$ForJava9.<init>(ConsulterSupplyFunction.java:82)
... 50 more
It's really hard to tell what all is going on there. The StaticComponentContainer.showBanner portion of the outermost exception makes me think the issue is related to showing the banner.
Things I've tried
- Ensured the
org/burningwave/banner.bwbfile exists inside my uber jar - Tried to turn on the
banner.hidesetting but I'm not really sure how to do this (a system property would be MUCH easer than a properties file!)- I tried creating a
burningwave.static.propertiesfile in the root of my uber jar doesn't seem to get picked up - The docs say the properties file need to be located "in the base path of your class path" but I don't know what that means for my use case
- I tried using the
setFileName()method, but it's really unclear how that works. Is it expecting a path inside the jar? A relative path? An absolute path? Can it point anywhere on disk? Does it need a prefix likefile://? I tried passing several things tosetFileName(), including a non-existent path and it basically seems to just get ignored.
- I tried creating a
I really can't figure out how to debug any of this, and the stack traces in the error above are super confusing, lol.
And furthermore, even if I can get past this banner error, I still have other questions such as how I can incorporate the jvm-driver.properties file from both of the required jvm-driver jars which are dependencies into a single uber-jar.