java.lang.ClassNotFoundException: com.amazonaws.ClientConfigurationFactory - java

I am using aws since last 6 months and I developed application that puts batch request to firehose. It was working fine till today but when I redeployed in my local system it is saying java.lang.ClassNotFoundException: com.amazonaws.ClientConfigurationFactory. I know what this error means. But my question is why I got this exception today? I am using following dependency in my project:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<!-- <version>1.10.72</version> --> // I used this version today only for testing purpose
<version>1.10.6</version>
</dependency>
<!-- <dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.10.71</version>
</dependency> -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.10.37</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-kinesis</artifactId>
<version>RELEASE</version>
</dependency>
And I searched ClientConfigurationFactory class but don't find anywhere (anywhere means in my dependency).
My question is where is this class located and why I got this error only today? Because I did not face this error in my initial development (6 months before). I have not changed any dependencies/code today. And I am not using this class in my project (I have doubt aws-sdk may have been using inside).
Note: I can not ask Do I missed any dependency? Because it was working fine before.
Please comment if you have any doubt. Thanks.

This is most likely because you have a mismatch of AWS SDK versions you are including. You are using a combination of SDK version 1.10.6, 1.10.71, 1.10.37 and RELEASE. You are asking for trouble mixing the versions like you are doing. Change all those to the same version and your problem will likely go away.

Related

Generating a client from WSDL and java version error

I have the task to built a java JAR that works fine with JAVA 6. The functionality is not complex, it just needs to call a SOAP WS (the WSDL was provided to me) and then exit with 0 or -1 wether the WS return ok or not ok. Seems easy.
I'm using Eclipse IDE, so I was able to generate the client from the WSDL and the schema provided and I only had to built the parameter object from the arguments the JAR receives and do some validations on dates, quantities and stuff like that. I'm using Maven to manage the dependencies because at first, the auto generated client didn't work well and it kept throwing error as "class not found" or "class not def", so I added the following dependencies in order to solve all of these errors:
<dependencies>
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.ibm.informix</groupId>
<artifactId>ifxjdbc</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.ibm.informix</groupId>
<artifactId>ifxjdbcx</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
I tested it on my local machine and it worked well, from Eclipse console and from my Windows CMD console...
The thing is this JAR is part of a bigger process, so my workmates are going to execute it on another machine. When I export it and they try to execute it throws a version error on some classes like ProviderImpl (which is a class I didn't create of course, it's some dependency):
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/sun/xml/ws/spi/ProviderImpl : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:648)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:272)
at java.net.URLClassLoader.access$000(URLClassLoader.java:68)
at java.net.URLClassLoader$1.run(URLClassLoader.java:207)
at java.net.URLClassLoader$1.run(URLClassLoader.java:201)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:200)
at java.lang.ClassLoader.loadClass(ClassLoader.java:325)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:296)
at java.lang.ClassLoader.loadClass(ClassLoader.java:270)
at javax.xml.ws.spi.FactoryFinder.safeLoadClass(FactoryFinder.java:170)
at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:50)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:110)
at javax.xml.ws.spi.Provider.provider(Provider.java:102)
at javax.xml.ws.Service.<init>(Service.java:76)
at com.mvc.model.services.webservices.proposals.ProposalsService_Service.<init>(ProposalsService_Service.java:39)
at mainpackage.MainClass.setEndpoint(MainClass.java:69)
at mainpackage.MainClass.main(MainClass.java:44)
This how I deduced that on my local environment, my jar was using the correct java version for its dependencies automatically (I have a couple of jdks installed and default one is newer than Java 6), but the production environment my team is on only have Java 6.
So my question is: how can I solve this? Why did the generate client from Eclipse used this class even if I have the build path of the project configured to Java 6?
I already tried using older versions, but it's impossible for the rt one because there are no Java 6 version or I couldn't find it. I also tried specifying the maven compiler version in the pom.xml, but it didn't do nothing for me. So i'm out of options, because they can't change the Java version of that environment.
Thank you everyone.

Porting from Java 8 to 11: com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found, how to change implementation?

I'm trying to port an old Java 8 webapp containing JAX-WS based webservices to Java 11 and Tomcat 9 on Windows 10. Note that this app is not using Maven or any other dependency management and there are reasons against a conversion.
After adding the jaxws-rt library, I'm getting the following error:
java.lang.Error: javax.xml.soap.SOAPException: Unable to create SAAJ meta-factoryProvider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
at com.sun.xml.ws.api.SOAPVersion.<init>(SOAPVersion.java:193)
at com.sun.xml.ws.api.SOAPVersion.<clinit>(SOAPVersion.java:91)
at com.sun.xml.ws.api.BindingID.<clinit>(BindingID.java:342)
at com.sun.xml.ws.spi.ProviderImpl.createEndpoint(ProviderImpl.java:107)
at javax.xml.ws.Endpoint.create(Endpoint.java:162)
at javax.xml.ws.Endpoint.create(Endpoint.java:116)
...
The internal infix already shouldn't be there, as this seems to be a Java 8 package stripped from Java 11. I've tried the following:
adding the libs saaj-api-1.3.5.jar and saaj-impl-1.5.1.jar
starting Tomcat with -Djavax.xml.soap.SAAJMetaFactory=com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl, which point to a location in saaj-impl-1.5.1.jar
creating a file <MyWebapp>/META-INF/services/javax.xml.soap.SAAJMetaFactory with contents com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl (which btw. is also contained in saaj-impl-1.5.1.jar)
all to no avail. It keeps asking for that internal implementation which isn't there anymore.
How do I tell Java to use the correct implementation and, if possible, how can I find out who is causing this implementation to show up anyway?
This worked for me.
I needed to add following dependencies.
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.5.1</version>
</dependency>
I also needed to set property.
System.setProperty("javax.xml.soap.MetaFactory","com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl");

Problem to find the right JIRA Java SDK version

[1] I am having a hard time finding the right JIRA SDK version. I want this StatusCategory class, but I do not find the right jar file containing it.
https://docs.atlassian.com/DAC/javadoc/jira/reference/com/atlassian/jira/issue/status/category/StatusCategory.html
[2] I downloaded the Atlassian JIRA SDK according to their description, but I do not find the jar file in there. Maybe I looked wrong?
https://marketplace.atlassian.com/apps/1210950/atlassian-plugin-sdk-windows/version-history
[3] I also tried to find the JAR file using mvnrespository.com, but no luck, all dependencies are scoped with provided.
https://mvnrepository.com/artifact/com.atlassian.jira/jira-api
[4] Previously, I used an old version of the JIRA API, which worked, but it does not contain the StatusCategory class, which I want.
<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-core -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-api -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>5.1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.atlassian.fugue/fugue -->
<dependency>
<groupId>io.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>4.7.2</version>
</dependency>
Am I the only person who finds this whole JIRA Java SDK thing kind of messy ;-)?
It works by going down the route [2].
You create a JIRA plugin using their archetype generator by invoking atlas-create-jira-plugin.bat.
Let / be the installation folder of the JIRA SDK. You use the settings.xml in /apache-maven-3.5.4/conf/settings.xml and use /repository as your m2 repository. You can override these settings per-project in IntelliJ.

Maven - Unable to resolve dependency conflict b/w google-vision beta & aws-sdk sub-components

I'm trying to use google-vision to fetch text from an image (uploaded to AWS S3) and store it in AWS Dynamo DB. I'm encountering dependency conflicts on jackson-core as both google-api and aws-java-sdk are using two different versions.
Dependency Hierarchy
google-api-client: 1.22.0 uses jackson-core: 2.1.3
google-cloud-vision: 0.22.0-beta uses jackson-core: 2.1.3
aws-java-sdk: 1.11.106 uses jackson-core: 2.6.6
I tried "exclusions" and added explicit dependency in pom.xml to use jackson-core: 2.6.6. Google-vision api works fine with that change. However, AmazonDynamoDBClientBuilder fails with below error:
Exception in thread "main" java.lang.IllegalAccessError: tried to access method com.amazonaws.AmazonWebServiceClient.<init>(Lcom/amazonaws/client/AwsSyncClientParams;)V from class com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder.build(AmazonDynamoDBClientBuilder.java:60)
at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder.build(AmazonDynamoDBClientBuilder.java:26)
at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
at com.oneglint.ImageProcessing.AddItem.main(AddItem.java:133)
Following error is displayed when there was version conflict
Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:537)
at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:448)
at com.amazonaws.partitions.PartitionsLoader.<clinit>(PartitionsLoader.java:51)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:64)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:52)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:105)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:239)
at com.oneglint.ImageProcessing.AddItem.main(AddItem.java:132)
What am I missing here? Thanks for the help..
BTW, I'm using example code from github to achieve this. Here are the links:
DynamoDB example: https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/java/example_code/dynamodb
Google Vision DetectText example: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/vision/cloud-client/src/main/java/com/example/vision/Detect.java
Additional Details
Both the examples are working fine if executed as independent projects. The problem occurs ONLY when both PutItem (AWS) & Detect (google-vision) classes are brought together in a single project, with appropriate code changes.
You can only have one version of jackson-core in your project. The easiest way to fix a version is to use <dependencyManagement> to set a version.
Your main problem is that jackson-core: 2.6.6 is not compatible with AmazonDynamoDBClientBuilder. The usual strategy is to try all versions from 2.1.3 to 2.6.6 until one of them works. If not, you can try to find versions of your amazon and google jars that require the same Jackson-core-version. In any case, this stupid and boring try-and-error.
If you do not come to any working solution, you can try to shade classes with maven-shade-plugin (I have not tried this, probably difficult) or you need to change your project in a way that not both dependencies are required.
After a lot of trial and error approach, the issue is finally solved.
It appears that I added multiple versions of aws-java-sdk jars during the process and an opennlp jar was associated with the project for some other module.
I had removed conflicting versions of aws-java-sdk and unnecessary libraries. Also, removed the exclusions and retained only the dependency addition in <dependencymanagement> for jackson-core.
Dependencies in my final pom listed below:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.11.106</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.6</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-vision</artifactId>
<version>v1-rev358-1.22.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.22.0</version>
<exclusions>
<exclusion> <!-- exclude an old version of Guava -->
<groupId>com.google.guava</groupId>
<artifactId>guava-jdk5</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-vision</artifactId>
<version>0.22.0-beta</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
</dependency>
</dependencies>
Hope this helps others..

AWS Java SDK - NoSuchMethodError in Jackson when using Region methods

I'm trying to use the AWS Java SDK to access my Elastic Transcoder jobs. But, the jobs are done in a different region than my development machine. When I try to establish the ElasticTranscoderClient and set it's region I get the following error:
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.enable([Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/databind/ObjectMapper;
at com.amazonaws.partitions.PartitionsLoader.<clinit>(PartitionsLoader.java:54)
at com.amazonaws.regions.RegionMetadataFactory.create(RegionMetadataFactory.java:30)
at com.amazonaws.regions.RegionUtils.initialize(RegionUtils.java:66)
at com.amazonaws.regions.RegionUtils.getRegionMetadata(RegionUtils.java:54)
at com.amazonaws.regions.RegionUtils.getRegion(RegionUtils.java:107)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:233)
at com.amazonaws.client.builder.AwsClientBuilder.withRegion(AwsClientBuilder.java:222)
I will emphasis that this only happens when I try to use regions with the client (true for any AWS client I try to use)
Looking around online it seems that this is likely caused by the Jackson version not being sufficiently high, but I don't know how to fix this since it's the AWS SDK's dependency, not my project's.
Has anyone else had this issue? Is this really a dependency issue or is that just a red herring?
Edit: Using SDK Version 1.11.60
I ran into this as well. So far, the following in my pom.xml (my project uses maven) seems to fix it:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.125</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.5.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.3</version>
</dependency>
You can solve this issue by using aws sdk 2.0 for example software.amazon.awssdk:2.15.71

Categories