I'm trying to use RestAssured to test a Rest API.
I'm getting a NoClassDefFoundError when setting RestAssured.baseURI in my setup method.
I've checked and I have httpclient-4.5.6.jar. I've also tried reverting to old versions to no avail.
Error:
java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient
at io.restassured.config.HttpClientConfig.defaultHttpClientFactory(HttpClientConfig.java:264)
at io.restassured.config.HttpClientConfig.<init>(HttpClientConfig.java:76)
at io.restassured.config.RestAssuredConfig.<init>(RestAssuredConfig.java:41)
at io.restassured.RestAssured.<clinit>(RestAssured.java:420)
Related
I am attempting to upgrade our application to Java 8 and am having some issues with maven and surefire. When I run all of my unit tests, a handful of them fail when using EasyMock.createMock with the following error: java.lang.NoClassDefFoundError: Could not initialize class com.sun.proxy.$Proxy33. Not all instances of EasyMock.createMock fail, and I can't find anything special about the classes we're mocking where it fails. Also, if I run the unit test inside of IntelliJ it works perfectly fine. It's only when running it via maven directly that it fails. I haven't been able to find anything that is causing this, but I'm assuming it has to be some sort of classpath issue. Any help would be greatly appreciated.
That is a strange error. The Proxy33 means you are mocking an interface. And that something failed at class loading.
Check if you have static initializers in your code. You can also add remote debug to maven and break on the exception.
I am having some trouble trying to run an in-memory hive while writing tests for a dropwizard swagger app. I have tried both hiverunner and hiveqlunit.
There are 2 types of tests. One is for testing dropwizard/swagger API endpoints using dropwizard integration testing (no need for hive here) and the other is for testing the hive integration where I need to hit the api and setup an in-memory hive to query and verify data is stored in hiveDB (psql).
The two in-memory hive dependencies (Note that I am using one at a time) always have some kind of conflict with the existing dropwizard and swagger dependencies. I am guessing it has something to do with jersey but I've tried a lot of things and still no luck.
I can run in-memory hive just fine and do all CRUD if I am not hitting the dropwizard/swagger api. But I just can't get the two services to play along at the moment.
Versions in Maven:
io.dropwizard:dropwizard-core version: 0.9.2
com.smoketurner:dropwizard-swagger version: 0.9.2-3
com.facebook.presto.hive:hive-apache-jdbc version: 0.13.1-3
com.klarna:hiverunner version: 3.0.0
OR
org.finra.hiveqlunit:hiveQLUnit version: 1.0
dropwizard-swagger uses org.reflections:reflections:jar:0.9.10 and com.klarna:hiverunner uses org.reflections:reflections:jar:0.9.8.
When I didn't exclude anything, I got the following:
java.lang.NoSuchMethodError: org.reflections.util.ClasspathHelper.forPackage(Ljava/lang/String;[Ljava/lang/ClassLoader;)Ljava/util/Collection;
So I tried excluding org.reflections:reflections from hiverunner and I got the 3 Exceptions:
java.lang.RuntimeException: javax.servlet.ServletException: io.dropwizard.jersey.setup.JerseyServletContainer-73437222#8a344094==io.dropwizard.jersey.setup.JerseyServletContainer,1,false
Caused by: A MultiException has 3 exceptions. They are:
1. java.lang.NullPointerException
2. java.lang.IllegalStateException: Unable to perform operation: method inject on com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$App
3. java.lang.IllegalStateException: Unable to perform operation: create on org.glassfish.jersey.message.internal.MessageBodyFactory
Then I tried excluding org.reflections:reflections from dropwizard-swagger and added a separate dependency for org.reflections:reflections by adding the following dependency to my pom.xml:
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
And got the following:
java.lang.NoClassDefFoundError: com/google/common/base/MoreObjects
So I added the latest guava (version 20.0) and then it gives me another error. This seems like dependency hell.
Has anyone ever encountered this problem before? It seems like dropwizard and hiverunner do not play along well. Maybe it has to do with the versioning of jersey 1 & 2.
I got some other error regarding jackson-databind, so I did some research and found out I had to have the same version for the following dependencies:
com.fasterxml.jackson.core:jackson-databind (from `dropwizard`)
com.fasterxml.jackson.module:jackson-module-scala (from `hiverunner/hiveqlunit`)
And now I am back to the previous 3 Exceptions...
Any help will be appreciated.
Edit: Found out that hiveqlunit is using the following:
com.sun.jersey:jersey-server:jar:1.9
Which is one of the last versions before moving to the following maven dependency:
org.glassfish.jersey.core:jersey-server
It is having conflicts with dropwizard's org.glassfish.jersey.core:jersey-server:jar:2.22.
How can i resolve this conflict?
I have problem with creating Spring Mediator who have inside Web Service Client. This mediator is crashed when try initializing Web Service object.
Error is:
"Uncaught exception
{org.apache.axis2.transport.base.threads.NativeWorkerPool}
javax.xml.ws.spi.FactoryFinder$ConfigurationError: Provider
org.apache.cxf.jaxws.spi.ProviderImpl not found".
I tried to add jars like "cxf-rt-frontend-jaxws" but without result. (To 'WSO2_HOME\repository\components\lib')
WSO2ESB version is 4.8.1.
Could you please explain me how to solve this.
If the jars are OSGi bundles, you should put them into
<WSO2_HOME>\repository\components\dropins\
1.Work well with spring-mongo in microservice.
2.Work well with spring-cassandra in microservice.
build project with gradle.
but when i add spring-cassandra into spring-mongo,there are errors.even just import spring-cassandra dependencies,without any cassandra
compile "org.springframework.data:spring-cql:1.5.0.M1"
compile "org.springframework.data:spring-data-cassandra:1.5.0.M1"
compile "com.datastax.cassandra:cassandra-driver-core:3.0.1"
The error trace is too long.just take a summary.
throw exceptions
` ``
org.springframework.beans.factory.BeanCreationException
com.datastax.driver.core.exceptions.NoHostAvailableException
not caused by one class.when i run the test with gradle.all testcase throw this exception.and spring boot application cannot start.which worked well before.
and i have not added any java code to call datastax driver to connect cassandra.dont know why there is an exception about cassandra connection.
solve this issue by putting mongo/cassandr repository/model into
different package
I am using Netbeans 6.8 , JDK 1.6 and downloaded Simple Validation API. When I try the code, it gives me errors referencing "org/openide" classes.
Could this be a compatibility issue? How can I resolve this?
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/openide/util/Lookup
at org.netbeans.validation.api.ui.swing.SwingComponentDecorationFactory.getDefault(SwingComponentDecorationFactory.java:154)
at org.netbeans.validation.api.ui.swing.SwingValidationGroup.<init>(SwingValidationGroup.java:82)
at org.netbeans.validation.api.ui.swing.SwingValidationGroup.create(SwingValidationGroup.java:87)