Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: Could not initialize class com.mashape.unirest.http.options.Options #35

Closed
strongme opened this issue May 19, 2014 · 7 comments

Comments

@strongme
Copy link

Hello !
$ Here i do have a problem that i can not work out .. for long time
$ I do have all dependencies that unirest-java needs,but i got traces like blow printing form (http://2.minime.sinaapp.com/):


java.lang.NoClassDefFoundError: Could not initialize class com.mashape.unirest.http.options.Options
at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:151)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:128)
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at org.strongme.minime.global.GlobalUtil.getAccessToken(GlobalUtil.java:224)
at org.strongme.minime.global.WeiXinService.getAccessToken(WeiXinService.java:19)
at org.strongme.minime.HomeController.home(HomeController.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:624)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)


What is going on ?

@subnetmarco
Copy link
Member

Just to be sure, are you currently using Unirest version 1.3.11 with the following dependencies installed (with the right versions):

<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.3.3</version>
</dependency>
<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpasyncclient</artifactId>
  <version>4.0.1</version>
</dependency>
<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpmime</artifactId>
  <version>4.3.3</version>
</dependency>
<dependency>
  <groupId>org.json</groupId>
  <artifactId>json</artifactId>
  <version>20140107</version>
</dependency>

@strongme
Copy link
Author

Yes i am 100% sure with those version (locally):

qq20140519160900

i am using SAE(something like GAE) [http://sae.sina.com.cn/] would it be possible that the sae provided the wrong version of the dependencies ?

Down below is the jars that SAE provide:

sae-local-xxx.jar(全局)
log4j.jar (全局)
derby.jar (kvdb服务)
mail.jar (mail服务)
activation.jar (mail服务)
commons-codec-1.4.jar (Storage,TaskQueue,FetchURL服务)
commons-logging-1.1.1.jar (Storage,TaskQueue,FetchURL服务)
httpclient-4.1.2.jar (Storage,TaskQueue,FetchURL服务)
httpclient-cache-4.1.2.jar (Storage,TaskQueue,FetchURL服务)
httpcore-4.1.2.jar (Storage,TaskQueue,FetchURL服务)
httpmime-4.1.2.jar (Storage,TaskQueue,FetchURL服务)
commons-beanutils-1.8.3.jar (Storage,TaskQueue,FetchURL服务)
commons-beanutils-bean-collections-1.8.3.jar (Storage,TaskQueue,FetchURL服务)
commons-beanutils-core-1.8.3.jar (Storage,TaskQueue,FetchURL服务)
commons-collections-3.2.1.jar (Storage,TaskQueue,FetchURL服务)
commons-lang-2.6.jar (Storage,TaskQueue,FetchURL服务)
ezmorph-1.0.6.jar (Storage,TaskQueue,FetchURL服务)
json-lib-2.4-jdk15.jar (Storage,TaskQueue,FetchURL服务)
commons-io-1.3.2.jar (Storage,TaskQueue,FetchURL服务)
mysql-connector-java-5.0.8-bin.jar(MySQL服务驱动包)

OR which version of Unirest does depend on the above versions ?

@shin-nien
Copy link

I'm seeing the same error when trying out Unirest from a Grails console and a different (dependency) looking error in a standalone Groovy app. Works in Java just fine, I wonder if it's something in Groovy's included runtime libs. I'll see if I can glean a bit more info and raise a separate issue.

@shin-nien
Copy link

I had a conflicting version of httpclient. Looks like you might have the same problem with the version that SAE is providing.

@strongme
Copy link
Author

So the problem source is the version of the httpclient ? between 4.3.3 and 4.1.2 ?
should i just delete the version 4.3.3 or i can not use the ## UNIREST,cause the version in SAE environment can not be changed manauly ~~ OH GOD

@shin-nien
Copy link

Yes that was the problem for me.

If SAE are providing those older jars at runtime and therefore out of your (pom.xml) control then I doubt you'll be able to use Unirest without some custom classloading magic.

@strongme
Copy link
Author

OH THANKS ,but i am blank to classloading STAFF, maybe i should take step into that magic world of ClassLoading . Haha

Thanks again , I'll take a try and see what happens . ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants