java.lang.NoClassDefFoundError: org/yaml/snakeyaml/constructor/BaseConstructor - java

When I am trying to run flutter app in simulator i get error:
java.lang.NoClassDefFoundError: org/yaml/snakeyaml/constructor/BaseConstructor
at org.testng.internal.YamlParser.parse(YamlParser.java:16)
at org.testng.internal.YamlParser.parse(YamlParser.java:10)
at org.testng.xml.Parser.parse(Parser.java:168)
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:311)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:46)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
Caused by: java.lang.ClassNotFoundException: org.yaml.snakeyaml.constructor.BaseConstructor
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 6 more
Process finished with exit code -1

You are missing the JAR file for snakeyaml from the classpath. However, judging from the stacktrace, you are not running a flutter app at this point. It looks like that the exception is occurring in the testng launcher.
So I suspect that the problem is a version conflict between the versions of snakeyaml required by the test framework and something you are testing. Here is an example Q&A from a different context:
java.lang.NoClassDefFoundError: org/yaml
The work-around in that case was to exclude nestng's transitive snakeyaml dependency; see above link for the details. (You will most likely need to map from the Maven POM syntax to the equivalent Gradle syntax.)

Related

How to use Eclipse ClassPath via CMD or Bash?

I have one app which I want to dockerize. But first, I need to run it via console(cmd or bash). When I run it from Eclipse everything is okay, but when I run it from bash(java -jar project-18.5.0-SNAPSHOT.jar) I get this error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.hp.spacecat.util.PropertyUtil.<clinit>(PropertyUtil.java:35)
at com.hp.spacecat.SpaceCat.main(SpaceCat.java:76)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
I have that jar in m2 and he has this LogFactory class. Mvn clean install is success. But for some reason I can't run it via console. I don't know is there some way to get that classpath from Eclipse or there is another way to solve this.
Similar questions about this logging exception didn't help me.

Jar can not resolve org.apache.commons import

I am not particularly well experienced with Java at all and try to get a jar file running on my Ubuntu machine (https://sites.google.com/site/communitydetectionslpa/home).
However once I run the jar file with the command suggested by developers I receive the following error:
java -jar GANXiSw.jar -i test.ipairs
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/map/MultiKeyMap
at Net.<init>(Net.java:38)
at SLPAw.<init>(SLPAw.java:146)
at SLPAw.main(SLPAw.java:2050)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.MultiKeyMap
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
Apparently java is not able to import the org.apache.commons class properly. After some researching I checked if I have libcommons-collections3-java installed, which however is the case.
I read something about adding the library explicitly to my CLASSPATH, which however I also read to be not good practice.
What is the best approach to fix my issue?

"No dependency satisfies type class org.neo4j.kernel.api.index.SchemaIndexProvider" when building über-jar

I have manually downloaded and added the libraries log4j, jsoup and neo4j for a project in Intellij Idea.
Before adding neo4j, I could build a jar as an artifact with all the libraries extracted to it so i could directly copy it somewhere and run with java -jar file.jar.
When I run the application in IntelliJ Idea it always works!
Now i get the following error when running the jar:
Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:314)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:268)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:316)
at java.util.jar.JarVerifier.update(JarVerifier.java:228)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
at java.util.jar.JarFile.getInputStream(JarFile.java:450)
at sun.misc.JarIndex.getJarIndex(JarIndex.java:137)
at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:839)
at sun.misc.URLClassPath$JarLoader$1.run(URLClassPath.java:831)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.URLClassPath$JarLoader.ensureOpen(URLClassPath.java:830)
at sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:803)
at sun.misc.URLClassPath$3.run(URLClassPath.java:530)
at sun.misc.URLClassPath$3.run(URLClassPath.java:520)
at java.security.AccessController.doPrivileged(Native Method)
at sun.misc.URLClassPath.getLoader(URLClassPath.java:519)
at sun.misc.URLClassPath.getLoader(URLClassPath.java:492)
at sun.misc.URLClassPath.getNextLoader(URLClassPath.java:457)
at sun.misc.URLClassPath.getResource(URLClassPath.java:211)
at java.net.URLClassLoader$1.run(URLClassLoader.java:365)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
I already searched for the error and found that a library seems to be signed and I can't just pack it into another jar, because it thinks it was modified then.
The suggested solution was to exclude the signing files through the build system.
I tried to manually delete the BCKEY.dsa and the BCKEY.sf files (only signing files in META-INF folder) in the resulting jar but then I get the following error:
Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.impl.factory.CommunityFacadeFactory, /home/xuiqzy/Documents/uni/4.Semester/PRG_practicum/WikiXtractor/data
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:144)
at org.neo4j.kernel.impl.factory.CommunityFacadeFactory.newFacade(CommunityFacadeFactory.java:40)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:108)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:100)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.lambda$createDatabaseCreator$0(GraphDatabaseFactory.java:89)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:183)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:65)
at de.bened.wikixtractor.DatabaseManager.initialize(DatabaseManager.java:43)
at de.bened.wikixtractor.Main.main(Main.java:83)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.NeoStoreDataSource#5c67716' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:444)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107)
at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:99)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:434)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:140)
... 8 more
Caused by: org.neo4j.kernel.impl.util.UnsatisfiedDependencyException: No dependency satisfies type class org.neo4j.kernel.api.index.SchemaIndexProvider
at org.neo4j.kernel.impl.util.Dependencies.resolveDependency(Dependencies.java:71)
at org.neo4j.kernel.impl.util.Dependencies.resolveDependency(Dependencies.java:67)
at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:418)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:434)
... 13 more
I also searched that error, a META-INF/services/org.neo4j.kernel.extension.KernelExtensionFactory file exists in my jar, there are also the jars lucene-analyzers-commen, lucene-codecs, lucene-core, lucene-queryparser, neo4j-lucene-index and neo4j-lucene-upgrade all integrated in the über-jar and the build in IntelliJ Idea seems to have enough dependencies, too.
So I'm a bit clueless why the jar doesn't work as opposed to the build in the IDE.
Long term I'm willing to switch to a build system but for now:
Is there a way to get the jar to run?
Any help or pointers in the right direction are appreciated! :)

jenkins executor not building MasterToSlaveCallable

Trying to build a project in Jenkins
Some misconfiguration or something that has been broken , and cannot understand what.
The builds get executed but no command is printed on the Console Output.
It has to do with the executors. The jenkins log is:
java.lang.NoClassDefFoundError: jenkins/security/MasterToSlaveCallable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at jenkins.util.AntClassLoader.defineClassFromData(AntClassLoader.java:1138)
at hudson.ClassicPluginStrategy$AntClassLoader2.defineClassFromData(ClassicPluginStrategy.java:756)
at jenkins.util.AntClassLoader.getClassFromStream(AntClassLoader.java:1309)
at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1365)
at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1325)
at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1078)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: java.lang.ClassNotFoundException: jenkins.security.MasterToSlaveCallable
at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1375)
at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1325)
at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1078)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more
Thank you
A NoClassDefFoundError indicates a likely incompatibility between a Jenkins plugin and either another plugin or Jenkins core. I would double-check the versions of core and your plugins on the Jenkins management page to make sure you're not running any incompatible versions.

Cannot run the code due to java.lang.NoClassDefFoundError

I am investigating the jsprit library. For this I just created a new project in Eclipse and copied-pasted the demo example class. Then I added all jars to the path, including log4j-1.2.17.jar. Nevrtheless I cannot execute the demo code due to the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager
at jsprit.core.problem.vehicle.VehicleImpl$Builder.<clinit>(VehicleImpl.java:108)
at com.test.jsprit.main(jsprit.java:49)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
What does it actually mean and how to solve this issue? Does it mean that some other *.jar file is missed?
UPDATE:
The error occurs at the following line:
Builder vehicleBuilder = VehicleImpl.Builder.newInstance("vehicle");
You are using the wrong version of the log4j lib. You need the 2.x version.
See:
LogManager (Version 1.x)
LogManager (Version 2.x)
log4j-1.2.17.jar implements log4j version 1 and its pretty old. What you need is implementation of log4j 2 - add this as the dependency: link

Categories