This Error is appears when i trying to run junit test on eclipse using cucumber
ava.lang.NoClassDefFoundError: cucumber/runtime/snippets/SummaryPrinter
at cucumber.api.junit.Cucumber.run(Cucumber.java:90)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: cucumber.runtime.snippets.SummaryPrinter
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
I got this error while upgrading the Cucumber version in my Maven based project.
Turn out that I updated <artifactId>cucumber-java</artifactId> version from 1.1.5 to 1.2.4, but I didn't update <artifactId>cucumber-junit</artifactId> - it was still on 1.1.5.
On the moment I updated both to the same version, this error was gone.
Class file that your code depends on and it is present at compile time but not found at runtime. Look for differences in your build time and runtime classpaths.
Update cucumber-core,cucumber-java and cucumber-junit to the same version ( i have used 1.1.5 version ).The issue is resolved for me.
Related
I have started using IntelliJ for my projects recently. I was trying to develop a simple maven project and got stuck into issue. I was trying to play around with kakfa-clients. Here is my dependencies
<dependencies>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.5.0</version>
</dependency>
</dependencies>
I tried doing maven clean and install. I see the following error after I execute the code.
C:\KB\SDA>java -cp target/SDA-1.0-SNAPSHOT.jar org.example.code.Demo
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/kafka/clients/producer/Producer
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.kafka.clients.producer.Producer
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
However I could see the kafka-clients:2.5.0 is available in the External Libraries folder
I would like to know what could have gone wrong. Any hint would definitely help.
Java version 8
IntellJ 2020.1
Kafka-Client itself is dependent on other dependencies. Have a look here https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients/2.5.0
Give a shot by including other jars in the classpath.
java -cp target/*.jar:. org.example.code.Demo
I have created webdriver test for project and it works fine.
Now I have added testpackage to Maven project and did some pom.xml changes then try to execute 1 test and i have following error
Class not found com.abc.xyz.con.TestExpressMode
java.lang.ClassNotFoundException:
com.abc.xyz.con.TestExpressMode at
java.net.URLClassLoader.findClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:688)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:421)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Now i did so much google and not able to fix this problem.
i have 1.8 jdk and developers have 1.6 i hope this is not a issue or?
Thanks
I have compile my xsd doc and begun to write junit tests for my wrapper.
When I call marshal I get the stack trace below. I was surprised to have an eclipse class not found. (org.eclipse.persistence.jaxb.JAXBContextFactory)
What am I missing from my classpath? Or is there something else I am missing?
I am running eclipse indigo 3.7.2.
My classpath include the following jars:
jaxb-api.jar, jaxb-impl.jar, jaxb-xjc.jar, jaxb1impl.jar, jsr173_1.0_api.jar,
My compiler is set to java 6 compatability.
1 [main] WARN com.bellsouth.snt.cnmp.dao.csp.CspInputMarshaller - Cannot marshal xml data
javax.xml.bind.JAXBException: Provider org.eclipse.persistence.jaxb.JAXBContextFactory not found
- with linked exception:
[java.lang.ClassNotFoundException: org.eclipse.persistence.jaxb.JAXBContextFactory]
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at com.bellsouth.snt.cnmp.dao.csp.CspInputMarshaller.jaxbMarshal(CspInputMarshaller.java:69)
at com.bellsouth.snt.cnmp.dao.csp.CspInputMarshaller.marshal(CspInputMarshaller.java:46)
at com.bellsouth.snt.cnmp.dao.csp.CspInputMarshallerTest.testGetUserRequest(CspInputMarshallerTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: org.eclipse.persistence.jaxb.JAXBContextFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at javax.xml.bind.ContextFinder.safeLoadClass(Unknown Source)
... 26 more
UPDATE: a manual workaround
The missing jar file is jaxb-impl.jar It is in my class path included from the jars in the ear project. If I add jaxb-impl.jar in the classpath ahead of the default classpath. it runs fine.
In other project in my same workspace I do not have this issue.
you may need the following dependencies, if you are using Maven,please refer to the following dependencies:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.6.8</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
I recently configured Web-driver in eclipse and also configured ant and I was able to execute a project.
Recently I created 1 more project and wrote first Java code and when I click on run button , it is not able to execute it even though it has no errors.
Here is the error it is throwing when I try to execute.
Class not found Dashboard
java.lang.ClassNotFoundException: Dashboard
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Make sure you have selenium-java-2.x.jar and JUnit/TestNG jar in you classpath. Also make sure your tests are in classpath.
To set a classpath right Click on Project -> Properties -> Java Build Path -> "Add JARs" or "Add External JARs".
I have tried a spring(3.1.0) project for the first time,but it gives me runtime errors.I have added log4j but still error occurs.and the org.springframework.beans.factory.xml.XmlBeanFactory is deprecated too.
please help me
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.<init>(DefaultSingletonBeanRegistry.java:83)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.<init>(FactoryBeanRegistrySupport.java:43)
at org.springframework.beans.factory.support.AbstractBeanFactory.<init>(AbstractBeanFactory.java:175)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:157)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.<init>(AbstractAutowireCapableBeanFactory.java:168)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.<init>(DefaultListableBeanFactory.java:158)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:77)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:66)
at com.vehicle.SpringDemoApp.main(SpringDemoApp.java:21)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 9 more<br/>
this is what i got
You need apache commons-logging in the classpath. Log4j is not commons-logging.
download commons logging jar from
http://commons.apache.org/logging/download_logging.cgi
You can check which class is in which Opensource (OSS) library here.
If you are using Maven, you can try adding the following dependency:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<classifier>api</classifier>
</dependency>