java junit and the exception java.lang.NoClassDefFoundError - java

I'm really confused. I have a project "PROJ" and test project "PROJ.TEST"
PROJ is using classes from external.jar
In PROJ.TEST I write a test that is testing class from PROJ but this class is using class from external.jar.
And here is the problem. I get an error:
java.lang.NoClassDefFoundError
Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
I have searched all the Internet to find the answer but couldn't find it. Even this great post http://blog.js-development.com/2010/06/android-instrumentation-test.html doesn't help me.
I tried many combinations with Java Build Path and nothing :(
Regards

The post Android Testing: External libraries probably contains the answer to your question and a step-by-step example.

Related

IntelliJ cucumber .ClassNotFoundException

I don't know if this question has been asked/answered yet. If so, I'm sorry. But I'm new to IntelliJ and there's a lot of foreign words I yet need to understand.
My problem is as follows:
I installed the complete IntelliJ package, created a new Java project and created a new class inside my src folder:
package de.itsme.hello;
public class Hello {
public static void main(String[] args) {
System.out.println("Hello");
}
}
So I try to run it and I get this Error:
Error: Could not find or load main class cucumber.api.cli.Main
Caused by: java.lang.ClassNotFoundException: cucumber.api.cli.Main
I tried adding cucumber-core:4.0.1 to the project's dependencies but then I got another exception:
Exception in thread "main" cucumber.runtime.CucumberException: No backends were found. Please make sure you have a backend module on your CLASSPATH.
at cucumber.runtime.BackendModuleBackendSupplier.get(BackendModuleBackendSupplier.java:39)
at cucumber.runner.SingletonRunnerSupplier.createRunner(SingletonRunnerSupplier.java:38)
at cucumber.runner.SingletonRunnerSupplier.get(SingletonRunnerSupplier.java:32)
at cucumber.runtime.Runtime.run(Runtime.java:75)
at cucumber.api.cli.Main.run(Main.java:26)
at cucumber.api.cli.Main.main(Main.java:8)
I don't need cucumber or at least not for now. Is there a way to make it either work or remove it from the project?
Thanks in advance!
Maybe you have the packet JDK installed incorrectly and this produces you an error. Or maybe your classspath is incorrect.

BodyEditorLoader.jar gives NoSuchMethodError

I was just starting to use the BodyEditorLoader.jar library but i got a NoSuchMethodError without any reason. Then i googled it and found a post on stackoverflow which wasn't useful and links were also broken but i came to know that the official library out there is buggy.
How do i fix this? Could not found the updated version of the library. Also some people provided the updated java file but how do i make it a library file as the library file contains the .class file and not the .java file.
Anyways here is the error:
java.lang.NoSuchMethodError: com.badlogic.gdx.utils.JsonReader.parse
and here is the code that gives the error:
BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("data/test.json"));
From question it's seems you have some buggy BodyEditorLoader class, you can inject gdx-utils jar inside your core module and after that you can access BodyEditorLoader class inside your project, May be it solve your problem.
dependencies {
compile group: 'com.github.itsabhiaryan', name: 'gdx-utils', version: '1.0.1-SNAPSHOT'
}
Don't forget to refresh all of your gradle module.

Error: Could not find or load main class ... in eclipse

I knew there are similar question posted already but none of it helped in resolving my issue. Currently I am working on a Scala project using eclipse.
Issue 1 : Unable to get Run As -> Scala application
Issue 2: When I run my program through Run Configurations, getting the following error
Error: Could not find or load main class NewStreaming
Code :
src/main/scala/NewStreaming.scala
object NewStreaming {
def main(args:Array[String]): Unit = {
...
...
}}
Issue 3: Able to do "mvn package", but when I execute the jar in hdp, with spark-submit, getting the following exception
java.lang.ClassNotFoundException: NewStreaming
Could you try to do a Rebuild / Clean of your Project? :)
I didn't use eclipse since a while. But I remember I got a problem of that kind.

org.testng.TestNGException: Cannot find class in classpath

I have tried to create the testing framework using this tutorial
While executing the code, I am getting the below exception. Please tell me what I need to do with my code and Java configuration.
org.testng.TestNGException:
Cannot find class in classpath: sampletest
Do you use Eclipse? Try Project->Clean and run again. I have seen similar behaviour before for various users.

java.lang.ClassNotFoundException with spymemcached

I'm getting this error trying to access a value on cache from a Web Service, but when I called the method directly on a test class it works fine.
some one got this error?
Pastebin: http://pastebin.com/8z7bsDcc
I've try with it withour results: http://code.google.com/p/spymemcached/issues/detail?id=155&colspec=stars%20id%20Milestone%20Priority%20Status%20Summary
Thanks.
I just answered a similar question over here:
java.lang.NoClassDefFoundError from every class every day
It was related to the pom.xml and how resources were included.
Make sure you all required jars are available in webservice classpath.
You will get ClassNotFoundException if required class is not available in classpath.

Categories