I'm working on studens project, which will need to read data send from AtMega via USB (using virtual serial port). To access serial port I'm using NeuronRobotics' nrjavaserial (https://github.com/NeuronRobotics/nrjavaserial), which is a fork of RXTX. To manage my dependencies I'm using maven. Here's what I get when I run CommPortIdentifier.getPortIdentifiers(); (or whichever static CommPortIdentifier function):
java.lang.UnsatisfiedLinkError: C:\Users\Grześ\AppData\Local\Temp\libNRJavaSerial_Grze?_0\libNRJavaSerial.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at gnu.io.NativeResource.loadResource(NativeResource.java:142)
at gnu.io.NativeResource.inJarLoad(NativeResource.java:40)
at gnu.io.NativeResource.loadLib(NativeResource.java:60)
at gnu.io.NativeResource.load(NativeResource.java:28)
at gnu.io.SerialManager.<init>(SerialManager.java:10)
at gnu.io.SerialManager.getInstance(SerialManager.java:16)
at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:87)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
at pl.edu.pwr.aerospace.enginebench.serial.SerialCommunicator.getAvaliablePorts(SerialCommunicator.java:34)
at pl.edu.pwr.aerospace.enginebench.cli.Main.connectCommunicator(Main.java:35)
at pl.edu.pwr.aerospace.enginebench.cli.Main.main(Main.java:21)
java.lang.UnsatisfiedLinkError: C:\Users\Grześ\AppData\Local\Temp\libNRJavaSerial_Grze?_0\libNRJavaSerial.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at gnu.io.NativeResource.loadResource(NativeResource.java:142)
at gnu.io.NativeResource.inJarLoad(NativeResource.java:40)
at gnu.io.NativeResource.loadLib(NativeResource.java:60)
at gnu.io.NativeResource.load(NativeResource.java:28)
at gnu.io.SerialManager.<init>(SerialManager.java:10)
at gnu.io.SerialManager.getInstance(SerialManager.java:16)
at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java:87)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
at pl.edu.pwr.aerospace.enginebench.serial.SerialCommunicator.getAvaliablePorts(SerialCommunicator.java:34)
at pl.edu.pwr.aerospace.enginebench.cli.Main.connectCommunicator(Main.java:35)
at pl.edu.pwr.aerospace.enginebench.cli.Main.main(Main.java:21)
java.lang.ExceptionInInitializerError thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver
Here are my dependencies:
<dependencies>
<dependency>
<groupId>com.neuronrobotics</groupId>
<artifactId>nrjavaserial</artifactId>
<version>3.12.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
Strangly, this only happens during debugging, when I run program normally it works like charm. Any ideas why?
I found that people had similar problems with other libraries, however solutions for all of them was to move DLLs or update classpath, but as I'm using maven I suspect in this case the solution will be different.
I managed to fix my problem. The root cause of this problem, was my username - "Grześ", which contains non-standard character 'ś'. As you may see in the first line of exception info:
java.lang.UnsatisfiedLinkError: C:\Users\Grześ\AppData\Local\Temp\libNRJavaSerial_Grze?_0\libNRJavaSerial.dll: Can't find dependent libraries
The path contains question mark in place of this character. Changing my username in Windows properties fixed this issue
Related
I was trying out Log4j2 so I created a Java project in eclipse. My code is same as Log4j2 Manual Automatic Configuration part. I have added log4j-api-2.17.2.jar and log4j-core-2.17.2.jar in the classpath. When I run the application I get following error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager
at demo.one.MainClass.<clinit>(MainClass.java:8)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
I have checked some related questions but didn't find those useful.
In case you use maven, make sure to include Log4j core to the project:
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.18.0</version>
</dependency>
Since, it's a NoClassDefFoundError, that means your JRE is not able to find out the necessary jar(class) artifact holding definition for org.apache.logging.log4j.LogManager.
Look for differences between build and runtime classpaths.
I get the following error when I try to create a ChronicleMap:
Exception in thread "main" net.openhft.chronicle.hash.ChronicleHashRecoveryFailedException: java.lang.UnsatisfiedLinkError: C:\Users\sando\AppData\Local\Temp\jna-109203563\jna13551597900255569913.dll: Can't find dependent libraries
at net.openhft.chronicle.map.ChronicleMapBuilder.openWithExistingFile(ChronicleMapBuilder.java:1877)
at net.openhft.chronicle.map.ChronicleMapBuilder.createWithFile(ChronicleMapBuilder.java:1701)
at net.openhft.chronicle.map.ChronicleMapBuilder.recoverPersistedTo(ChronicleMapBuilder.java:1655)
at net.openhft.chronicle.map.ChronicleMapBuilder.createOrRecoverPersistedTo(ChronicleMapBuilder.java:1638)
at net.openhft.chronicle.map.ChronicleMapBuilder.createOrRecoverPersistedTo(ChronicleMapBuilder.java:1629)
at com.mycompany.app.App.createIndexOneFile(App.java:54)
at com.mycompany.app.App.createIndexOne(App.java:31)
at com.mycompany.app.App.main(App.java:23)
Caused by: java.lang.UnsatisfiedLinkError: C:\Users\sando\AppData\Local\Temp\jna-109203563\jna13551597900255569913.dll: Can't find dependent libraries
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2430)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2487)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2617)
at java.base/java.lang.Runtime.load0(Runtime.java:765)
at java.base/java.lang.System.load(System.java:1834)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:851)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:826)
at com.sun.jna.Native.<clinit>(Native.java:140)
at net.openhft.chronicle.hash.impl.util.jna.WindowsMsync.<clinit>(WindowsMsync.java:34)
at net.openhft.chronicle.hash.impl.VanillaChronicleHash.msync(VanillaChronicleHash.java:853)
at net.openhft.chronicle.hash.impl.VanillaChronicleHash.msync(VanillaChronicleHash.java:841)
at net.openhft.chronicle.map.ChronicleMapBuilder.commitChronicleMapReady(ChronicleMapBuilder.java:464)
at net.openhft.chronicle.map.ChronicleMapBuilder.openWithExistingFile(ChronicleMapBuilder.java:1871)
... 7 more
Using this code:
String indexOnePath = "D:\\trabajo\\dbpedia\\dbpedia_files\\indexOne.bin";
File indexOneFile = new File(indexOnePath);
indexOne = ChronicleMap
.of(String.class, String.class)
.name("indexOne")
.entries(27191196)
.averageValue("<http://dbpedia.org/resource/Robert_Koch>")
.averageKey("Battle of Ardrianople")
.createOrRecoverPersistedTo(indexOneFile, true);
My pom.xml dependency looks like this:
<dependency>
<groupId>net.openhft</groupId>
<artifactId>chronicle-map</artifactId>
<version>3.19.4</version>
</dependency>
I am using the Java SDK 11.0.6 on Windows 10.
It seems to create the file, but then the exception appears. If I use create insteaad of createOrRecoverPersistedTo, there seems to be no problem.
Latest released version of Chronicle-Map depends on fairly old jna version (4.2.1) which doesn't work well with recent Windows. You can try last snapshot version (3.19.5-SNAPSHOT) as we haven't released it yet, or try overriding jna version in maven, e.g. add this to your dependency-management section:
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.5.0</version>
</dependency>
I am getting the below error when I am trying to create amazon S3 client. It worked earlier and after I have done few code changed from then on I am seeing this error. I feel it could be of some dependency conflict but unable to find it out. Try many things but nothing could help.
java.lang.NoSuchMethodError: org.apache.http.conn.ssl.SSLConnectionSocketFactory.<init>(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/HostnameVerifier;)V
at com.amazonaws.http.conn.ssl.SdkTLSSocketFactory.<init>(SdkTLSSocketFactory.java:56)
at com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory.getPreferredSocketFactory(ApacheConnectionManagerFactory.java:91)
at com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory.create(ApacheConnectionManagerFactory.java:65)
at com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory.create(ApacheConnectionManagerFactory.java:58)
at com.amazonaws.http.apache.client.impl.ApacheHttpClientFactory.create(ApacheHttpClientFactory.java:51)
at com.amazonaws.http.apache.client.impl.ApacheHttpClientFactory.create(ApacheHttpClientFactory.java:39)
at com.amazonaws.http.AmazonHttpClient.<init>(AmazonHttpClient.java:301)
at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:164)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:523)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:503)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:485)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:457)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:439)
at com.ge.hc.cloud.e2e.workflows.steps.BasicWorkflowSteps.<clinit>(BasicWorkflowSteps.java:72)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:386)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
at net.thucydides.core.steps.StepFactory.webEnabledStepLibrary(StepFactory.java:201)
at net.thucydides.core.steps.StepFactory.createProxyStepLibrary(StepFactory.java:164)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:117)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:109)
at net.thucydides.core.steps.StepFactory.getNewStepLibraryFor(StepFactory.java:77)
at net.thucydides.core.steps.StepFactory.getStepLibraryFor(StepFactory.java:72)
at net.thucydides.core.steps.StepAnnotations.instantiateAnyUnitiaializedSteps(StepAnnotations.java:52)
at net.thucydides.core.steps.StepAnnotations.instanciateScenarioStepFields(StepAnnotations.java:41)
at net.thucydides.core.steps.StepAnnotations.injectScenarioStepsInto(StepAnnotations.java:23)
at net.serenitybdd.jbehave.SerenityStepFactory.createInstanceOfType(SerenityStepFactory.java:80)
at org.jbehave.core.steps.StepCreator.stepsInstance(StepCreator.java:83)
at org.jbehave.core.steps.StepCreator$ParametrisedStep.perform(StepCreator.java:595)
at org.jbehave.core.embedder.StoryRunner$FineSoFar.run(StoryRunner.java:566)
Appreciate any kind of help.
I faced the similar issue. I was using AWS JavaV2 SDK software.amazon.awssdk with version 2.19.14.
The Amazon Java SDK jar that I had imported had a dependency on org.apache.httpcomponents. Once I imported the dependency and built the project again, I was able to create the client.
My pom.xml looked something like this.
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssm</artifactId>
</dependency>
</dependencies>
While trying to marshal the java object to xml i am getting below exception .
java.lang.ClassNotFoundException: org.apache.oro.text.regex.MalformedPatternException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at org.castor.xml.AbstractInternalContext.getRegExpEvaluator(AbstractInternalContext.java:325)
at org.exolab.castor.xml.validators.PatternValidator.initEvaluator(PatternValidator.java:262)
at org.exolab.castor.xml.validators.PatternValidator.validate(PatternValidator.java:200)
at org.exolab.castor.xml.validators.StringValidator.validate(StringValidator.java:302)
at org.exolab.castor.xml.validators.StringValidator.validate(StringValidator.java:340)
at org.exolab.castor.xml.FieldValidator.validateInstance(FieldValidator.java:324)
at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:271)
at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:1072)
at org.exolab.castor.xml.Validator.validate(Validator.java:135)
at org.exolab.castor.xml.Marshaller.validate(Marshaller.java:2594)
at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:826)
at in.mywebapp.util.XMLUnmarshaller.getStatusRequestParam(XMLUnmarshaller.java:266)
Not sure which jar is missing .
you are probably missing oro.jar. You can add maven dependency
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
</dependency>
or download the jar from maven repository
Please make sure oro jar file is in classpath. It is not there. So, class loading is failing
I've developed some code that executes a quartz job.At first the code was outside the tomcat and it executes very well, but when I tried to embed the same code inside a web application I get java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution.
I'm using quartz 2.1.5 and it's already in the class path.
Here is the stack trace:
Exception in thread "DefaultQuartzScheduler_QuartzSchedulerThread" java.lang.NoClassDefFoundError: org/quartz/DisallowConcurrentExecution
INFO: Illegal access: this web application instance has been stopped already. Could not load org.quartz.DisallowConcurrentExecution. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
at org.quartz.impl.JobDetailImpl.isConcurrentExectionDisallowed(JobDetailImpl.java:390)
java.lang.IllegalStateException
at org.quartz.simpl.RAMJobStore.acquireNextTriggers(RAMJobStore.java:1447)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1273)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
Caused by: java.lang.ClassNotFoundException: org.quartz.DisallowConcurrentExecution
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.quartz.impl.JobDetailImpl.isConcurrentExectionDisallowed(JobDetailImpl.java:390)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at org.quartz.simpl.RAMJobStore.acquireNextTriggers(RAMJobStore.java:1447)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264)
make sure you have only 1 quartz-all-.jar in your classpath (maybe you have 2 : 1 in Tomcat lib folder + 1 in your war)
NoClassDefFoundErrors point to a missing JAR or class on the classpath. In this case the problem is likely that in Tomcat you have quartz-<ver>.jar on your classpath when you actually need quartz-all-<ver>.jar.
for them who use maven can use the new version by add
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.1.7</version>
</dependency>
It should be keep the .jar file inside of the project location. Import .jar file from the outside from the location which the project have is the reason for getting this error. also verified that if the project is a maven project, then it should include the maven dependency in the pom.xml to add the dependency to the project
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org</groupId>
<artifactId>quartz_job</artifactId>
<version>2.2.1</version>
</dependency>