Reputation: 187
I wrote a tool (using spring boot) to get the details from HP QC v10. I'm using com4j API for this. Program works fine in eclipse but throws following Exception when I'm running code through jar (which I have created using maven install).
I have generated the wrapper for OTAClient.dll and made jar file of wrapper qcconn.jar. Also I have registered the dll files : OTAClient.dll, WebClient.dll and com4j-amd64.dll. I'm using jdk 8 (32 bit).
I checked jar file of my tool which was generated by maven install and it has both jar included in it : com4j.jar and qcconn.jar.
Exception is thrown when I ran jar file : java -jar mytool.jar
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:184) ~[spring-beans-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1295) ~[spring-beans-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
... 38 common frames omitted
Caused by: java.lang.ExceptionInInitializerError: null
at com.qc.ClassFactory.createTDConnection(ClassFactory.java:16) ~[qcconn-1.0.jar!/:na]
at com.qc.report.gen.app.qc.connection.QCTool.<init>(QCTool.java:23) ~[classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_201]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_201]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_201]
at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[na:1.8.0_201]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172) ~[spring-beans-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
... 40 common frames omitted
Caused by: java.lang.NullPointerException: null
at com4j.COM4J.loadNativeLibrary(COM4J.java:567) ~[com4j-1.0.jar!/:na]
at com4j.COM4J.<clinit>(COM4J.java:522) ~[com4j-1.0.jar!/:na]
... 47 common frames omitted
Exception in thread "Com4J shutdown hook" java.lang.NoClassDefFoundError: Could not initialize class com4j.COM4J
at com4j.COM4J$3.run(COM4J.java:476)````
Upvotes: 0
Views: 569
Reputation: 187
As I was using 32 bit JVM, everytime I was missing to register com4j-x86.dll. After registering it. It started to work. Also please make sure when running jar, following dll file should be present under same folder where jar is present : com4j-x86.dll, OTAClient.dll and WebClient.dll
Upvotes: 1