JUnit issue while using Mockito - junit

I have created multiple junit test cases with mocking the Cassandra CQLSession class using Mockito framework. When I run the individual test class the it works. but when i run the test suite as a whole, seeing below error for mockito
java.lang.NoClassDefFoundError: Could not initialize class com.datastax.oss.driver.api.core.CqlSession$MockitoMock$534112137 at jdk.internal.reflect.GeneratedSerializationConstructorAccessor5.newInstance(Unknown Source) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:48) at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73) at org.mockito.internal.creation.instance.ObjenesisInstantiator.newInstance(ObjenesisInstantiator.java:21) at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.doCreateMock(InlineByteBuddyMockMaker.java:360) at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.createMock(InlineByteBuddyMockMaker.java:318) at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:53) at org.mockito.internal.MockitoCore.mock(MockitoCore.java:61) at org.mockito.Mockito.mock(Mockito.java:1949)
Version details:
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '3.8.0'
testImplementation group: 'junit', name: 'junit', version: '4.13'
also tried with mockito version 4.0, still same error. pls let me know is there anything I missed.

Just incase some one facing the similar issue, issue resolved after the restart of eclipse .

I faced similar issue in my spring boot project. Upgrading Springboot starter parent from 2.6.7 to 2.7.0 fixed the issue.

Related

SOLVED Grails HelloWorld brakes down before i even start

Urlmappings
HelloController
Pls help i followed the "Hello-World-Instruction" on the grails homepage exactly but it throws an error (before i even start it breaks ;D)
tried looking for solution maybe it has to do with my Java Path?
I finished the helloWorld Tut on Tutorial then put "grails run-app" into the shell and then Error!
Linux debian based Distro
Grails Version: 5.1.2
JVM Version: 11.0.1
Groovy Version: 4.0.1 JVM: 11.0.14
Error creating bean 'compositeViewResolver'
enter image description here
enter image description here

Google-maps-services-java firebase

I have a working Java Firebase Admin SDK application. The moment I add google-maps-services to gradle I get this exception:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
at com.google.firebase.FirebaseApp.checkNotDeleted(FirebaseApp.java:317)
at com.google.firebase.FirebaseApp.getOptions(FirebaseApp.java:263)
at com.google.firebase.database.FirebaseDatabase.getInstance(FirebaseDatabase.java:75)
The two lines I added to build.gradle are:
compile group: 'com.google.maps', name: 'google-maps-services', version: '0.2.3'
compile 'org.slf4j:slf4j-nop:1.7.25'
Question: What am I doing wrong trying to use google-maps-services in a Java Firebase Admin SDK application?
I filed an issue here: https://github.com/googlemaps/google-maps-services-java/issues/355
Looks like this will be addressed in a new release.

Arquillian tomee

While executing a test case with arquillian on tomee-remote I m getting the following exception
org.apache.openejb.OpenEJBException: can't get appInfo
There seems to be no other exception related to the deployment .
Using the following maven dependencies
arquillian-junit-container 1.1.9
arquillian-tomee-remote
This got resolved .There was a conflicting openejb-core jar of version 4.7.1 in the classpath .Upon removing that it worked

Glassfish Embedded does not start

My glassfish 3.2 embedded was starting with Arquillian and Junit perfectly and now I've getting this Exception in eclipse.
I've replace .m2 repository and it doesn't start.
Anybody could help me:
java.lang.RuntimeException: Could not setup GlassFish Embedded Runtime
Caused by: org.glassfish.embeddable.GlassFishException: A MultiException has 2 exceptions.
1. java.lang.IllegalArgumentException: The scope name given in the descriptor (org.glassfish.hk2.api.PerLookup) did not match the scope annotation on the class (javax.inject.Singleton) in class CommandExecutorImpl
2. java.lang.IllegalArgumentException: Errors were discovered while reifying SystemDescriptor(
implementation=com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl
contracts={com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl,org.glassfish.embeddable.CommandRunner
at com.sun.enterprise.glassfish.bootstrap.StaticGlassFishRuntime.newGlassFish(StaticGlassFishRuntime.java:138)
at org.jboss.arquillian.container.glassfish.embedded_3_1.GlassFishContainer.setup(GlassFishContainer.java:138)
... 62 more
I've solved this question deleting all workspace project and eclipse .metadata and RemoteSystemsTempFiles folders, after that I've dowloaded all project with "Checkout Project" and the glassfish-embedded using Junit 4 have started normally.

Quartz Scheduler - NoClassDefFoundError

I am using Quratz 1.6.3 API in a Maven project. This is the error message I get when I run it:
java.lang.NoClassDefFoundError: org/apache/commons/collections/SetUtils
at org.quartz.JobDetail.(JobDetail.java:85)
.....
commons.collections 3.2 dependency is included in the project's pom.xml file. What could be the reason for this error?
Thanks in advance.
commons.collections 3.2.1 contains this class
org\apache\commons\collections\SetUtils.class
So the problem should be in your maven project. Double check that the commons.collections gets is the classpath (see logs). Or show the project configuration, so we would be able to help.