java.lang.NoClassDefFoundError:
org/junit/internal/AssumptionViolatedException at
org.spockframework.runtime.JUnitSupervisor.error(JUnitSupervisor.java:92)
at
org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:318)
at
org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:297)
at
org.spockframework.runtime.BaseSpecRunner.runSpec(BaseSpecRunner.java:90)
at
org.spockframework.runtime.BaseSpecRunner.run(BaseSpecRunner.java:81)
at org.spockframework.runtime.Sputnik.run(Sputnik.java:63) 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)
I have a simple test case that calls a method,
def 'some test for empty Lists'(){
setup:
List<Object> clauses=new ArrayList<Object>()
when:
String someString=builder.buildString(clauses, "someName", "AND");
then:
noExceptionThrown()
someString==""
}
Assume builder is injected via spring. I can't make out why this happens. It happens only for a few test cases.
Any help is much appreciated :) I use spock 0.6 with groovy 1.8.
The solution for spock 1.0 with jUnit 4.12
As soon as I added hamcrest-core-1.3 to my test classpath the error disappeared.
What was the problem?
I observed the same error described in the question, but I managed to get spock 1.0 groovy 2.4 to work with junit-4.12.
The problem was that junit-4.12 depends on hamcrest.
In fact org.junit.internal.AssumptionViolatedException implements the interface org.hamcrest.SelfDescribing.
I've got the same error with spock tests using a simple Eclipse java project with these versions:
spock-core-1.0-groovy-2.3
junit-4.12
The exception was thrown only when there was a test failures, but was working for the successful ones
I've found that it was a Junit version compatibility matter. i resolved it using junit-4.7 and also tested the following versions:
junit-4.6 => ok
junit-4.5 => ok
junit-4.4 => ko
junit-4.0 => ko
Hope it helps
I had the same compatibility issue while trying to run my spocks in STS:3.6.4 and JBoss Developer Studio Version: 7.1.1.GA.
It was resolved using junit-4.7 instead of junit-4.12
Other instructions can be found at https://code.google.com/p/spock/wiki/GettingStarted#Eclipse
Related
I am trying to add tests using latest (5.7.0) Mockito and using Mockito.mockStatic(...)
to mock class with static methods which works fine . However when I have class with static block it is unable to create mock and fais with java.lang.InternalError: class redefinition failed: invalid class .
Is this supported in latest mockito versions or still I have to live with other alternatives like powermock.
I did face the same error and couldn't find answer in the internet, so I see that it is 1 month old question but might help someone.
The problem was that mocked class (or classes that this static block used) was not in the classpath. Before you can mock the method all static blocks or fields initializators will be run, and it causes the problem.
You can verify what class is missing in your classpath by simply trying to use this static method before mocking it. You should get java.lang.NoClassDefFoundError with a class name.
When you resolve this problem, everything should work.
I had this issue, and for me it was due to an Error being thrown from instrumentation.retransformClasses called from org.mockito.internal.creation.bytebuddy.inlineBytecodeGenerator. Somewhere between there and findOrInsert in net.bytebuddy.TypeCache, the Throwable looses its context (for mockito-core 4.1.0 and bytebuddy 1.12.0)
In my case, the error being thrown was a NoClassDefFoundError for Jetty Servlet. This ultimately turned out to be a dodgy local build of a different maven module I had been working on, so clearing out my ~/.m2 and downloading a legit version fixed that right up.
You might be able to catch the Error being thrown in inlineBytecodeGenerator and taking a look at what's really going on, if this is in fact the same problem.
My app keeps crashing. Can't figure out where the issue is. I'm not even using okttp3 library.
Currently, I'm only using retrofit 1.9 and otto 1.3.8
java.lang.NoSuchMethodError: No virtual method callEnqueue(Lokhttp3/Call;Lokhttp3/Callback;Z)V in class Lokhttp3/internal/Internal; or its super classes (declaration of 'okhttp3.internal.Internal' appears in /data/app/com.myproj.sample-2/base.apk)
at okhttp3.ws.WebSocketCall.enqueue(WebSocketCall.java:108)
at io.socket.engineio.client.transports.WebSocket.doOpen(WebSocket.java:73)
at io.socket.engineio.client.Transport$1.run(Transport.java:75)
at io.socket.thread.EventThread.exec(EventThread.java:50)
at io.socket.engineio.client.Transport.open(Transport.java:70)
at io.socket.engineio.client.Socket.probe(Socket.java:458)
at io.socket.engineio.client.Socket.onOpen(Socket.java:471)
at io.socket.engineio.client.Socket.onHandshake(Socket.java:512)
at io.socket.engineio.client.Socket.onPacket(Socket.java:485)
at io.socket.engineio.client.Socket.access$900(Socket.java:30)
at io.socket.engineio.client.Socket$5.call(Socket.java:299)
at io.socket.emitter.Emitter.emit(Emitter.java:117)
at io.socket.engineio.client.Transport.onPacket(Transport.java:127)
at io.socket.engineio.client.transports.Polling$2.call(Polling.java:124)
at io.socket.engineio.parser.Parser.decodePayload(Parser.java:251)
at io.socket.engineio.client.transports.Polling._onData(Polling.java:134)
at io.socket.engineio.client.transports.Polling.onData(Polling.java:106)
at io.socket.engineio.client.transports.PollingXHR$5$1.run(PollingXHR.java:113)
at io.socket.thread.EventThread$2.run(EventThread.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Solved it with the help of this post.
Just add the following to your gradle dependecies.
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
Try these dependencies :
implementation 'com.shopify.mobilebuysdk:buy3:3.2.3'
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
Hope this may help you.
When running unitTest on AndroidStudio (1.4), my below test fail as per title i.e. java.lang.NoSuchMethodError: org.assertj.core.api.Assertions.assertThat(Ljava/util/Map;)Lorg/assertj/core/api/MapAssert;
#Test
public void mapTest() {
Map<String, String> map = new HashMap<>();
map.put("Key1", "Value1");
map.put("Key2", "Value2");
Assertions.assertThat(map).isNotNull();
}
When I run it from command line using gradlew command, it passed. I'm already pointing my Java to jdk1.8.0_66.jdk. Anyone knows why?
(p/s: I get the latest AndroidStudio 2.0 Preview 5, my test fails massively. So I decided to stay with the older version of Android Studio).
Trying to search for help and found this link https://github.com/joel-costigliola/assertj-core/issues/395. Apparently he also face the same issue on IDE. Any clue what's the cause?
I would double check the classpath.
Use assertj core 1.7.1 - it's a version depending on java 6 whcih I'm sure is Android compatible.
Hope it helps
I´ve deployed an EAR on a Websphere Application Server 7. In my code there is a part where I try to unmarshall a XML file into an object. I get this error when trying to do that:
java.lang.NoClassDefFoundError: com.ibm.xtq.bcel.util.SyntheticRepository (initialization failure)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:140)
at com.ibm.xtq.bcel.classfile.JavaClass.<init>(JavaClass.java:109)
at com.ibm.xtq.bcel.classfile.JavaClass.<init>(JavaClass.java:228)
at com.ibm.xtq.bcel.generic.ClassGen.getJavaClass(ClassGen.java:174)
at com.ibm.fcg.bcel.FcgClassGenBCEL.dump2(Unknown Source)
at com.ibm.fcg.bcel.FcgClassGenBCEL.dump(Unknown Source)
at com.ibm.xml.xlxp2.jaxb.unmarshal.codegen.fcg.FCGDeserializationStubGenerator.generate(FCGDeserializationStubGenerator.java:249)
at com.ibm.xml.xlxp2.jaxb.codegen.AbstractGeneratedStubFactory.generateByteCode(AbstractGeneratedStubFactory.java:96)
at com.ibm.xml.xlxp2.jaxb.unmarshal.codegen.fcg.FCGStubFactory.generateStubByteCode(FCGStubFactory.java:46)
at com.ibm.xml.xlxp2.jaxb.codegen.AbstractGeneratedStubFactory.getStubClassConstructor(AbstractGeneratedStubFactory.java:154)
at com.ibm.xml.xlxp2.jaxb.unmarshal.codegen.AbstractGeneratedDeserializationStubFactory.createStub(AbstractGeneratedDeserializationStubFactory.java:58)
at com.ibm.xml.xlxp2.jaxb.unmarshal.impl.DeserializationContext.startComplexType(DeserializationContext.java:662)
at com.ibm.xml.xlxp2.jaxb.unmarshal.impl.DeserializationContext.handleRootElementEvent(DeserializationContext.java:303)
at com.ibm.xml.xlxp2.jaxb.unmarshal.impl.JAXBDocumentScanner.produceRootElementEvent(JAXBDocumentScanner.java:186)
at com.ibm.xml.xlxp2.scan.DocumentScanner.scanRootElement(DocumentScanner.java:2234)
at com.ibm.xml.xlxp2.scan.DocumentScanner.scanProlog(DocumentScanner.java:1726)
at com.ibm.xml.xlxp2.scan.DocumentScanner.nextEvent(DocumentScanner.java:1316)
at com.ibm.xml.xlxp2.scan.DocumentScanner.parseDocumentEntity(DocumentScanner.java:1168)
at com.ibm.xml.xlxp2.jaxb.unmarshal.impl.JAXBDocumentScanner.unmarshal(JAXBDocumentScanner.java:125)
at com.ibm.xml.xlxp2.jaxb.unmarshal.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:120)
at com.inditex.lois.core.ws.utilidades.services.impl.AdaptadorServiceImpl.transformarXMLenObjeto(AdaptadorServiceImpl.java:137)
As far as I know that class is part of IBM JDK and cannot be found in runtime. Is there anything I have to modify in my ear or, as I guess, its all about configuring/modifiying WAS configuration (or even applying a patch if this is a bug).
Any help? Thanks a lot.
(Sorry for my english :) )
This exception means that the class com.ibm.xtq.bcel.util.SyntheticRepository is found, but failed static initialization. If there is no other message in the log about this, then this is the time to open a PMR with IBM. Static initializers in internal WebSphere code should never fail during normal usage course.
Same here, there is an APAR:
http://www-01.ibm.com/support/docview.wss?uid=swg1IV41639
Problem conclusion
This defect will be fixed in:
6.0.0 SR14
6.0.1 SR6
7.0.0 SR5
.
The fix resolved the AccessControlException. SyntheticRepository
class can be initialized properly, hence NoClassDefFoundError
does not occur.
When I try to run the code below from Eclipse/STS I get the following exception:
Caught: groovy.lang.MissingMethodException: No signature of method:
groovy.json.JsonBuilder.message() is applicable for argument types:
(ie.makalu.scripts.TestJsonBuilder$_run_closure1) values:
[ie.makalu.scripts.TestJsonBuilder$_run_closure1#d05c13]
but when I run it from the shell it works fine. Can anyone suggest why that may be?
I've tried this in Groovy 1.8.6 and Groovy 2.0 using STS version 2.9.2
package ie.makalu.scripts
import groovy.json.JsonBuilder
def json = new JsonBuilder()
json.message {
header {
from('mrhaki') // parenthesis are optional
to 'Groovy Users', 'Java Users'
}
body "Check out Groovy's gr8 JSON support."
}
println json.toString()
I would advise against using Eclipse STS - it seems to me that too many people are constantly having issues with it. Instead I would install standard Eclipse or Eclipse for Java Development (anything from a eclipse community but not a specialized STS stuff) and install Groovy (and if you need Grails) plugin on top. It works much better and you are free to install any additional plugin that might not be working under STS version.
Also I would suggest to try IntelliJ, it has nice integration with Groovy (and Grails).