How do I resolve org.apache.http.ssl with AEM? - java

Ultimately, I'm trying to use AWS S3 libraries in Java code to enable server-side S3 uploads with AEM, but I'm running into problems just getting the dependencies installed and/or recognized by AEM. Every time I add a new dependency, five more issues pop up.
In this bundle I'm attempting to build, This is the error I'm seeing:
The instructions in my pom.xml are this:
<instructions>
<Embed-Transitive>true</Embed-Transitive>
<Export-Package>
com.amazonaws.HttpMethod,
com.amazonaws.services.s3.*
</Export-Package>
<Embed-Dependency>
gson,
aws-java-sdk-s3,
aws-java-sdk-core,
aws-java-sdk-kms,
jackson-core,
jackson-databind,
jackson-annotations,
jackson-dataformat-cbor,
ion-java,
httpclient,
brooklyn-karaf-httpcomponents-extension
</Embed-Dependency>
</instructions>
I did some googling and found this:
https://mvnrepository.com/artifact/org.apache.brooklyn/brooklyn-karaf-httpcomponents-extension/0.11.0-20170403.1534
I thought that this dependency would fix my problem, so I put it into my list of dependencies, but the package still shows up in red.
All of my dependencies:
<dependencies>
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr</artifactId>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>
<dependency>
<groupId>biz.aQute</groupId>
<artifactId>bndlib</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<!-- Other Dependencies -->
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.api</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-s3 -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.115</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-core -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.115</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-kms -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-kms</artifactId>
<version>1.11.115</version>
</dependency>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-cbor -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-cbor</artifactId>
<version>2.6.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/software.amazon.ion/ion-java -->
<dependency>
<groupId>software.amazon.ion</groupId>
<artifactId>ion-java</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.brooklyn/brooklyn-karaf-httpcomponents-extension -->
<dependency>
<groupId>org.apache.brooklyn</groupId>
<artifactId>brooklyn-karaf-httpcomponents-extension</artifactId>
<version>0.11.0-20170403.1534</version>
</dependency>
</dependencies>

The easiest way to install AWS dependencies in your AEM instance is to use the official AEM Oak S3 connector which is available from Adobe's public repository. This is also assuming that you are not using S3 datastore in your instance otherwise all of these files and Jars would already be there. For the sake of this answer, I'll refer to v1.4.8. You can see more details on installing and configuring S3 datastore over here however, this answer is not focusing on S3 data store configuration, it's just there to provide all the libraries in your instance.
This approach is recommended as it keeps your AEM instance compatible with Adobe's AEM official hotfixes and service packs which normally use older versions of AWS SDK as compared to ones available from AWS Developer site.
To install the AWS S3 libraries, do the following steps:
Download the latest com.adobe.granite.oak.s3connector-.zip from the repository.
Unpack the zip into a temporary folder.
From your temporary folder, copy all the files under jcr_root/libs/system/install to `crx-quickstart/install' folder. You should see some folders named as 1,5,15. If you examine these, they contain several jar files including the AWS SDK.
DO NOT copy the config files as they will setup your AEM instance to connect to S3 data store which is NOT what you want at this stage.
Start/restart your instance and wait for it to complete.
To verify that you have all the files:
Goto /system/console/bundles.
Check that AWS SDK For Java for OSGicom.amazonaws.aws-java-sdk-osgi is active.
Click on this bundle and see all the imports and exports which will include the libraries you need for your code to work.
Following this approach ensures that your existing datastore is preserved and AEM compatible AWS SDK is properly installed in your system.

it is dependency issue with your "httpclient" dependency.. you should try lower version of httpclient.
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
use : 4.5.2 or below, and do not use any beta or redhat version

Related

java.lang.ClassNotFoundException: org.spark_project.guava.collect.MapMaker

I am trying to integrate apache spark with spring-boot cassandra project. But while running the project it gives following error:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/spark_project/guava/collect/MapMaker] with root cause
java.lang.ClassNotFoundException: org.spark_project.guava.collect.MapMaker
I checked my maven dependencies and the mapmaker file was present there in the spark-network-common_2.11.jar within 'org/spark_project/guava/collect/'.
Here is the pom file dependencies I am using:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core -->
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-network-common -->
<!-- <dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-network-common_2.10</artifactId>
<version>1.3.0</version>
</dependency> -->
<!-- <dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-network-common_2.11</artifactId>
<version>2.2.1</version>
</dependency> -->
<!-- https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-mapping -->
<!-- <dependency> <groupId>com.datastax.cassandra</groupId> <artifactId>cassandra-driver-mapping</artifactId>
<version>3.5.0</version> </dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.datastax.spark/spark-cassandra-connector -->
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_2.11</artifactId>
<version>2.0.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-sql -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
The spark-network-common_2.11.jar comes along with the spark-core dependency, still I tried to add it separately, but even that didn't work.
What could be the problem that spring-boot can't identify the mapmaker file at runtime?
Any help is appreciated.
The package path of "org.spark_project.guava.collect.MapMaker" Heavily implies that the guava package has been relocated into the spark_project in order to avoid dependency hell.
Things like this are controlled by the build process, and can be easily overlooked sources of incompatibility between libraries.
My instinct is that you may be using mis-matching versions of libraries, that whilst technically may be compatible, arn't because of guava being relocated differently.
You have
<artifactId>spark-network-common_2.10</artifactId>
Commented out, when the other dependencies have 2.11 listed.
These represent the version numbers of the Scala Language+runtime used and should match across any projects that use Scala.
Which class / library is attempting to load the relocated Guava? This should give you a large hint towards which library is potentially outdated/mismatched.

javax.enterprise.inject.Vetoed Open web beans, which jar?

I'm wanting to try out Open Web Beans 1.6.2, but the jars it lists on it's website for adding CDI support to a Java SE application
openwebbeans-spi.jar
openwebbeans-impl.jar
geronimo-jcdi_1.0_spec.jar
geronimo-atinject_1.0_spec.jar
geronimo-interceptor_1.2_spec.jar
geronimo-annotation_1.2_spec.jar
Don't seem to contain the javax.enterprise.inject.Vetoed annotation, I've had to add cdi-api 1.2 as a dependency to resolve the issue, but I'm not sure if this is correct as all other CDI dependencies were resolved by the above? Here are the dependencies I have in my pom, is this correct?
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-interceptor_1.2_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.2_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
This link seems to suggest support for #Vetoed was added in Open Web Beans 1.5.0
Please upgrade geronimo-jcdi_1.0_spec to jcdi_1.1 version
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_1.1_spec</artifactId>
<version>1.0</version>
</dependency>
Although your problem is weird, because you have also following entry:
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency
which also contains #Vetoed and thus should be enough. Does maven ignore it somehow?

M2E Failed to load all dependencies

I am using Spring Tool Suite 3.6.3 and M2E eclipse plugin 1.4.1, when I opened the POM file from one of the project, I observed not all the dependencies are getting added, I have added depnedecy configuration for jaxws-rt with version 2.2.8 which has many dependencies as follows
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>javax.xml.soap-api</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>jsr181-api</artifactId>
</dependency>
<!-- Provided dependencies -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>policy</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.gmbal</groupId>
<artifactId>gmbal-api-only</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.staxex</groupId>
<artifactId>stax-ex</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.stream.buffer</groupId>
<artifactId>streambuffer</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.mimepull</groupId>
<artifactId>mimepull</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.fastinfoset</groupId>
<artifactId>FastInfoset</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.ha</groupId>
<artifactId>ha-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
</dependency>
<dependency>
<artifactId>woodstox-core-asl</artifactId>
<groupId>org.codehaus.woodstox</groupId>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.org.apache.xml.internal</groupId>
<artifactId>resolver</artifactId>
</dependency>
In STS when I open the POM, and navigates to the Dependency Hierarchy, I am not able to see policy, resolver and streambuffer dependencies.
But when I run mvn clean install from command prompt, all above mentioned jars gets added to .war file.
I think there is some issue with the m2e + STS, not sure why m2e is not able to get those missing dependencies.
I found the solution
The machine where we faced this issue, had java 1.6 executable copied in system32 folder, and when we removed those files and updated path to use jdk 1.7, issue got resolved....
I tried to search for compatible java version for m2e 1.4.1 but didn't found anything, for new m2e version i.e. 1.5 required java version is specified.

Unable to locate ListOrderedMap?

I have included all the 6 jars (beanutils, lang, logging, collections, ezmorph, json-lib). Its working fine in simple struts application. But in my struts application, although I have included all jar files, its shows a NoClassDefFoundError about ListOrderedMap.
I don't know how to make my app know that class. But I have included like other required jars for different functionality.
Please help me to resolve this issue.
Class ListOrderedMap is part of Apache Commons Collections (since version 3.0).
To be able to use it, you must have the JAR file that contains it on the classpath. The JAR file is most likely named commons-collections-3.2.1.jar (or something similar).
If you are creating a web application packaged in a WAR file, then you should put the library in the WEB-INF/lib folder inside the WAR file.
Yes, even tho there is NOW a newer v4.x for commons-collections, the 4.x do NOT work!
So, get the older highest version from v3.x, namely: v3.2.1
If you're using maven, like I am, here's my complete working dependencies list:
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<!-- <classifier>jdk15</classifier> -->
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.2.5</version>
</dependency>

Replacing JWSDP jar files with up-to-date equivalents from Maven repo

I inherited an old project that uses JWSDP, and would like to upgrade it to Maven 2 and Java 6.
The project uses the following JWSDP jar files:
jwsdp-jax-qname-1.5.jar
jwsdp-jaxrpc-api-1.5.jar
jwsdp-jaxrpc-impl-1.5-patched-1.10.jar
jwsdp-jaxrpc-spi-1.5.jar
jwsdp-namespace-1.5.jar
jwsdp-relaxngDatatype-1.5.jar
jwsdp-saaj-api-1.5.jar
jwsdp-saaj-impl-1.5.jar
jwsdp-xalan-1.5.jar
jwsdp-xercesImpl-1.5.jar
jwsdp-xsdlib-1.5.jar
As far as I understand, the up-to-date equivalents for these jars should be part of Glassfish , but which ones exactly do I need, and are they available in a Maven 2 repository?
If you just want to upgrade to the JWSPD 1.6 versions of the given artifacts, you'll need the following dependencies (that you can find in http://mvnrepository.com/):
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jax-qname</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc-api</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-impl</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>com.sun.xml.rpc</groupId>
<artifactId>jaxrpc-spi</artifactId>
<version>1.1.3_01</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>namespace</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml</groupId>
<artifactId>relaxngDatatype</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>saaj-api</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.sun.xml</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml</groupId>
<artifactId>xsdlib</artifactId>
<version>20050614</version>
</dependency>
But note that there is no further development of JWSPD 1.6. The replacement stack is Metro which is part of GlassFish v3.

Categories

Resources