Runtime Exception when using WildFly Swarm + Hoverfly Java
See original GitHub issueWhen running some tests using Hoverfly Java where some other JAXRS provider (like Resteasy in Wildfly Swarm) in classpath you get next exception:
java.lang.ExceptionInInitializerError
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:182)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:176)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:162)
at com.sun.jersey.api.client.Client.init(Client.java:343)
at com.sun.jersey.api.client.Client.access$000(Client.java:119)
at com.sun.jersey.api.client.Client$1.f(Client.java:192)
at com.sun.jersey.api.client.Client$1.f(Client.java:188)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
at com.sun.jersey.api.client.Client.<init>(Client.java:188)
at com.sun.jersey.api.client.Client.<init>(Client.java:160)
at com.sun.jersey.api.client.Client.create(Client.java:673)
at io.specto.hoverfly.junit.core.Hoverfly.<init>(Hoverfly.java:73)
at io.specto.hoverfly.junit.rule.HoverflyRule.<init>(HoverflyRule.java:93)
at io.specto.hoverfly.junit.rule.HoverflyRule.inCaptureMode(HoverflyRule.java:142)
at io.specto.hoverfly.junit.rule.HoverflyRule.inCaptureMode(HoverflyRule.java:131)
at org.music.ServiceVirtualizationTest.<clinit>(ServiceVirtualizationTest.java:16)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
at java.lang.reflect.Field.get(Field.java:393)
at org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)
at org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)
at org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)
at org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)
at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)
at org.junit.runners.ParentRunner.run(ParentRunner.java:362)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.jboss.resteasy.spi.ResteasyProviderFactory
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:152)
at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:120)
at javax.ws.rs.core.MediaType.valueOf(MediaType.java:179)
at com.sun.jersey.core.header.MediaTypes.<clinit>(MediaTypes.java:65)
... 38 more
Caused by: java.lang.ClassNotFoundException: org.jboss.resteasy.spi.ResteasyProviderFactory
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:114)
at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:207)
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:135)
... 41 more
This class of JAXRS providers might happen in other scenarios where for example tests are executed within the container. I suggest ( I can help on that) on changing client from JAXRS to one more neutral implementation like OkHttp + gson/jackson
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
IllegalArgumentException while starting Wildfly-Swarm ...
A weird exception is throwing while I'm attempting to run my wildfly-swarm instance. Following is the error that I'm getting;
Read more >Chapter 4. Component-testing microservices
Component tests should be designed to verify the functionality of and between a microservice's internal modules, with one exception: the external ...
Read more >Testing Java Microservices - Amazon AWS
Using Arquillian, Hoverfly,. AssertJ, JUnit, Selenium, and Mockito. Alex Soto Bueno. Andy Gumbrecht. Jason Porter. SAMPLE CHAPTER. MANNING ...
Read more >2017 - One Jar To Rule Them All
public void should_send_an_email() throws Exception {. // given ... Hoverfly Java is a wrapper around Hoverfly, that let's you use it in Java...
Read more >WildFly Swarm Documentation
WildFly Swarm is a framework based on the popular WildFly Java application server to enable the creation of small, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Of course, I am going to start working on this.
I’ve tried the latest snapshot version (0.3.9-SNAPSHOT), it fixed the problem. Thank you for your PR @lordofthejars. Closing this issue now.