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

Socket not created/ NoClassDefFoundError com.amazonaws.util.json.JSONObject #1292

Closed
kusharora02 opened this issue Sep 7, 2017 · 12 comments
Closed
Labels
guidance Question that needs advice or information.

Comments

@kusharora02
Copy link

Hi,

I am using kensis in spring boot project.

I am following the issue .. when I use aws-java-sdk version 1.10.x I am getting the following error.

java.lang.IllegalStateException: Socket not created by this factory

If I upgrade to 1.11.x. I am getting an error ofava.lang.NoClassDefFoundError: com/amazonaws/util/json/JSONObject on app startup.

can you please help on what is the right combination for aws-java-sdk and amazon-kinesis-client for an java spring boot app?

@kusharora02 kusharora02 changed the title Socket not created/ clas defnotfound com.amazonaws.util.json.JSONObject Socket not created/ NoClassDefFoundError com.amazonaws.util.json.JSONObject Sep 7, 2017
@dagnir
Copy link
Contributor

dagnir commented Sep 7, 2017

Hi, these look like two different instances of dependency version mismatches.

For the first instance (Socket not created by this factory), please refer to #1032

For the second instance (JSONObject) it sounds like you may have updated your kinesis dependency to 1.11.x but your core dependency is still on 1.10.x; both version need to be 1.11.x as we don't support mixing different versions of the core runtime and client modules.

@dagnir dagnir added the Question label Sep 7, 2017
@kusharora02
Copy link
Author

I am just using only two dependency in pom amazon-kinesis-client and aws-java-sdk(I am not sure if core is required to mention here.).

As 1032 issue ask to upgrade java sdk version to 1.11.95. If I do so my application does not even start it shows NoClassDefFoundError for JSON lib.

Do you want me to add core dependency also in my project, Please let me know if I am missing something here. Thanks in advance

@dagnir
Copy link
Contributor

dagnir commented Sep 7, 2017

Sorry I was slightly off in the last statement. It looks like your kinesis client is still on 1.10.x and the core is on 1.11.x

You don't need to have a dependency on aws-java-sdk-pom directly; you can remove this dependency. If all you need is the Kinesis client, you can just have a dependency on 1.11.x of aws-java-sdk-kinesis, and it will pull in the right version of the core.

@kusharora02
Copy link
Author

As per my requirement I need both the dependency.
currently I am using aws-java-sdk version of 1.11.136 and amazon-kinesis-client 1.2.1 in my SPRING BOOT Project but it shows me JSON no classdef error on app start.
If I create a simple AWS java project kinesis work fine if use sdk version as 1.10.x.

but If I do the same in spring boot project it shows me socket not created exception.

Does SPRING BOOT app is not compatible with aws java sdk 1.10.x ?
and as I can see in realese 1.11.x jackson dependency are removed kinesis does not wrk with 1.11.x.

So the issue I am facing is spring boot require 1.11.x and kinesis require 1.11.0 and my requirement is to create kinesis in java spring boot.

@dagnir
Copy link
Contributor

dagnir commented Sep 7, 2017

Okay, I see. Sorry for the confusion; I thought you were using the Kinesis SDK but it sounds like you're using KCL.

KCL 1.2.1 looks like it's using 1.9.x of the SDK internally, so again, your other SDK dependencies need to match as well. Are you able to update your KCL dependency?

What does your Spring Boot project POM look like? Do you have a direct dependency on the Apache HTTP client? The reason for java.lang.IllegalStateException: Socket not created by this factory is most likely that the version is incompatible with the SDK core runtime.

@kusharora02
Copy link
Author

pom.txt
Please see the attached pom file.

@kusharora02
Copy link
Author

kusharora02 commented Sep 7, 2017

I am getting error at the point when I call putRecord method of AmazonKinesisClient

java.lang.IllegalStateException: Socket not created by this factory

@dagnir
Copy link
Contributor

dagnir commented Sep 7, 2017

Can you paste the output of mvn dependency:tree?

@kusharora02
Copy link
Author

hi this is for aws-java-sdk version of 1.11.0 and amazon-kinesis-client 1.2.1.
dependencytree.txt

@dagnir
Copy link
Contributor

dagnir commented Sep 7, 2017

Thanks. I'm seeing some odd version in the output:

[INFO] |  \- com.amazonaws:aws-java-sdk-core:jar:1.11.0:compile
[INFO] |     +- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] |     +- org.apache.httpcomponents:httpclient:jar:4.5.3:compile
[INFO] |     |  +- org.apache.httpcomponents:httpcore:jar:4.4.6:compile
[INFO] |     |  \- commons-codec:commons-codec:jar:1.10:compile
[INFO] |     +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.8.8:compile
[INFO] |     \- joda-time:joda-time:jar:2.9.9:compile

This says your 1.11.0 of aws-java-sdk-core is using httpclient version 4.5.3 for example, but in 1.11.0, the version should be 4.5.2. See here: http://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk-pom/1.11.0/aws-java-sdk-pom-1.11.0.pom

Same for the other dependencies like joda-time and jackson.

Also, as I stated earlier, KCL 1.2.1 is built against version 1.9 of the SDK so there's bound to be conflicts if you want to use anything other than 1.9.x of aws-java-sdk. Is 1.2.1 of KCL a hard requirement? If not, I'd suggest moving to the latest version (1.8.1) which builds against 1.11.171 and use version 1.11.171 for aws-java-sdk to match.

@kusharora02
Copy link
Author

Thanks for all your help. No, using 1.2.1 is not an hard requirement. I have tested with above configuration and it is working fine for now. will update if I face some issue. Thanks for all your time.

@dagnir
Copy link
Contributor

dagnir commented Sep 8, 2017

Sounds good, I'll go ahead and close this.

@dagnir dagnir closed this as completed Sep 8, 2017
@srchase srchase added guidance Question that needs advice or information. and removed Question labels Jan 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

3 participants