What's the minimum classpath for an Axis2 client? - java

I want to build an Axis2 client (I'm only accessing a remote web service, I'm not implementing one!) with Maven2 and I don't want to add 21MB of JARs to my project. What do I have to put in my pom.xml to compile the code when I've converted the WSDL with ADB?

The minimum jars for the client are:
activation-1.1.jar
axiom-api-1.2.8.jar
axiom-impl-1.2.8.jar
axis2-adb-1.5.1.jar
axis2-kernel-1.5.1.jar
axis2-transport-http-1.5.1.jar
axis2-transport-local-1.5.1.jar
commons-codec-1.3.jar
commons-httpclient-3.1.jar
commons-logging-1.1.1.jar
httpcore-4.0.jar
mail-1.4.jar
neethi-2.0.4.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.3.jar
STAX jars below are not part of Axis2 1.5.1 release and will be needed if your JDK version is less than 6:
stax-1.2.0.jar
stax-api-1.0.1.jar

(Note: This response was provided by Aaron Digulla himself. What follows is the exact text of his own answer.)
In maven2, the minimum dependency set to make an ADB client work ("ADB" as in the way you created the Java classes from the WSDL) is this:
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.4.1</version>
</dependency>
Hmmm... it seems I can't flag that as the correct answer. Can someone please copy this so I can flag his post?

Had to add the transports, too
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.5.4</version>
</dependency>

Minimal dependency for a working client in summary
axiom-api-1.2.14.jar
axiom-impl-1.2.14.jar
axis2-adb-1.6.3.jar
axis2-kernel-1.6.3.jar
axis2-transport-http-1.6.3.jar
axis2-transport-local-1.6.3.jar
commons-codec-1.3.jar
commons-httpclient-3.1.jar
commons-logging-1.1.1.jar
httpcore-4.0.jar
mail-1.4.jar
neethi-3.0.2.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.7.jar
Listed below the minimal dependencies with details
client stub uses the ServiceClient Class generated with %AXIS2_HOME%\bin\WSDL2Java tool against a given WSDL (for generating you would need all axis jars on classpath, achieved most easily by setting AXIS_HOME)
Classes required by Client stub at COMPILE time
axiom-api-1.2.14.jar -- required at compilation time by client stub for org.apache.axiom.om.OMElement, org.apache.axiom.soap.SOAPEnvelope, org.apache.axiom.soap.SOAPFactory, org.apache.axiom.om.OMNamespace
axis2-adb-1.6.3.jar -- required at compilation time by client stub for org.apache.axis2.databinding.ADBException
axis2-kernel-1.6.3.jar -- required at compilation time by client stub for org.apache.axis2.AxisFault Class
Classes required for successful invocation of Client stub at RUN time
axiom-impl-1.2.14.jar (without this org.apache.axiom.om.OMException: No meta factory found for feature 'default'; this usually means that axiom-impl.jar is not in the classpath)
axis2-transport-http-1.6.3.jar (without this org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.http.CommonsHTTPTransportSender)
axis2-transport-local-1.6.3.jar (without this org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.local.LocalTransportSender)
commons-codec-1.3.jar (without this java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException)
commons-httpclient-3.1.jar (without this org.apache.axis2.deployment.DeploymentException: org/apache/commons/httpclient/HttpException)
commons-logging-1.1.1.jar (without this java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory)
httpcore-4.0.jar (without this java.lang.NoClassDefFoundError: org/apache/http/HttpResponseFactory)
mail-1.4.jar (without this java.lang.NoClassDefFoundError: javax/mail/internet/ParseException)
neethi-3.0.2.jar (without this java.lang.NoClassDefFoundError: org/apache/neethi/PolicyComponent)
wsdl4j-1.6.2.jar (without this java.lang.NoClassDefFoundError: javax/wsdl/WSDLException)
XmlSchema-1.4.7.jar (without this java.lang.ClassNotFoundException: org/apache/ws/commons/schema/XmlSchema)
org.apache.axis2.AxisFault: Connection refused: connect -> ERROR ONLY if the web service is not up or accessible for some other reason
Note the exact version(s), however behavior would be generic enough subject to packaging changes across version, hence, mentionined the FQCNs above-
Axis Version - 1.6.3
Tomcat Version - Apache Tomcat/7.0.64
Servlet version - 3.0
java.runtime.version - 1.7.0_79-b15

Axis2 version 1.6.2 wouldn't work for me without axis2-xmlbeans (though this may have something to do with the fact that I'm also using the axis2-wsdl2code-maven-plugin plugin and xmlbeans as my data binding framework). I have the following POM:
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-xmlbeans</artifactId>
<version>1.6.2</version>
</dependency>

If your client is running on Java 6, consider using JAX-WS for consuming the WS. JAX-WS uses the JAXB standard for binding and you don't need a single extra jar for the client.

Actually, you only need the axis-abd dependency since the axis2-kernel is a sub-dependency of axis-abd.
Therefore you can sum it up with:
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.5.1</version>
</dependency>

In Axis2 version 1.5.1 the maven modules appear to have been restructured.
My Groovy scripts (Using ADB binding) have the following dependencies:
#Grapes([
#Grab(group='org.apache.axis2', module='axis2-kernel', version='1.5.1'),
#Grab(group='org.apache.axis2', module='axis2-adb', version='1.5.1'),
#Grab(group='org.apache.axis2', module='axis2-transport-local', version='1.5.1'),
#Grab(group='org.apache.axis2', module='axis2-transport-http', version='1.5.1'),
])
There's a logic to these. I could use an alternative binding framework when generating my stub or could use an alternative transport protocol to HTTP.
Example code in this answer

For those using Gradle, here I exclude unnecessary libraries:
dependencies {
ext.compileEx = { lib, exModules, exGroups ->
compile (lib) {
exModules.each { exclude module : "$it" }
exGroups.each { exclude group: "$it" }
}
}
List axisExModules = [ 'axiom-compat', 'jaxen', 'apache-mime4j-core' ]
List axisExGroups = [ 'javax.servlet', 'commons-fileupload', 'org.apache.woden',
'javax.ws.rs', 'org.apache.geronimo.specs', 'org.codehaus.woodstox' ]
compileEx ('org.apache.axis2:axis2-adb:1.6.3', axisExModules, axisExGroups)
compileEx ('org.apache.axis2:axis2-transport-local:1.6.3', axisExModules, axisExGroups)
compileEx ('org.apache.axis2:axis2-transport-http:1.6.3', axisExModules, axisExGroups)
}
Here is my original post in the Gradle forums.

Related

Connect SMB endpoint with Camel v3 and the camel-jcifs from camel-extra

I have the following maven versions in my pom.xml (among others):
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.apache-extras.camel-extra</groupId>
<artifactId>camel-jcifs</artifactId>
<version>2.25.2</version>
<exclusions>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
Camel spring-boot version = 3.7.0 and I want to connect to a SMB endpoint like this:
smb://sharedriveuser#server-instance.sub.domain.net/folder?initialDelay=0&delay=9000&autoCreate=false&noop=true&idempotent=true&password=ThePassWorD&filter=#csvFileFilter
I read the Camel 3 Migration Guide and found nothing regarding this camel-extras.
When trying to connect, I get an error like the password option is not supported anymore:
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: smb://sharedriveuser#server-instance.sub.domain.net/folder?initialDelay=0&delay=9000&autoCreate=false&noop=true&idempotent=true&password=xxxxxx&filter=#csvFileFilter due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{password=ThePassWorD}]
The actual documentation link google found many times, seems dead.
From Maven central, there is no version 3.x of the lib camel-jcifs and I am wondering if the lib is still compatible with Camel 3.x.x, otherwise is there another alternative with Camel 3?
I also tried to downgrade the camel-jcifs to 2.24.3 with the same error.
Camel-extras is a separated project from the Apache Camel. There is some work in place in the camel-extra repository to support camel 3[1], but it is still to be completed and there is no release in sight.
[1] https://github.com/camel-extra/camel-extra/commit/f028dfdfaa467958c58abea0d604f8fe2f17be04
There is now a pull request to add camel-jcifs to the 3.x version:
https://github.com/camel-extra/camel-extra/pull/39
You might also get my fork and build it yourself:
https://github.com/bebbo/camel-extra *
It got merged and is in the official repository:
https://github.com/camel-extra/camel-extra
To use it with quarkus, you have to convert some List types to arrays.

no such method jsch.JSch.setLogger

The below behavior occurs when i call the getSftpUtil(). I have also ensured that all the appropriate jars are in the maven project's external libraries and are available in the WEB-INF/lib folder of the project
code
net.sf.opensftp.SftpUtil util = SftpUtilFactory.getSftpUtil();
stacktrace
SftpUtilFactory: Trying to get SftpUtil class name from the system property net.sf.opensftp.SftpUtil
SftpUtilFactory - Trying to get SftpUtil class name from the system property net.sf.opensftp.SftpUtil
SftpUtilFactory: The system property net.sf.opensftp.SftpUtil is not set.
SftpUtilFactory - The system property net.sf.opensftp.SftpUtil is not set.
SftpUtilFactory: Use the default one.
SftpUtilFactory - Use the default one.
Caused by: java.lang.NoSuchMethodError: com.jcraft.jsch.JSch.setLogger(Lcom/jcraft/jsch/Logger;)V
at net.sf.opensftp.impl.SftpUtil.<clinit>(SftpUtil.java:110)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at net.sf.opensftp.SftpUtilFactory.getSftpUtil(SftpUtilFactory.java:184)
Based on jcraft's change log, setLogger is a method added to JSch.java in jsch-0.1.30. So the jar under your WEB-INF/lib should be an older version.
You can run
mvn dependency:tree
to see which of your dependencies is using the older version, and then exclude it with something like this:
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<exclusions>
<exclusion>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
</exclusion>
</exclusions>
</dependency>
You probably have another dependency refer to a more recent version of jsch, so your problem should be solved at this point. However, if that's not the case, you can add this to pom.xml:
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.50</version>
</dependency>
Well, I guess you are missing this dependency or the proper version:
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.49</version> <!--latest version -->

com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example

I tried running the quickstart-sample, and this dependency:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev78-1.15.0-rc</version>
</dependency>
from Drive wiki API page
Yet when I try to compile the code com.google.api.client.json.jackson.JacksonFactory; is missing.
To verify this you just need to do Step 2 & 3! Where can I find this class or how can I replace it in the sample?
Jackson library can be found
at http://repo2.maven.org/maven2/com/google/http-client/google-http-client-jackson/
For July 7, last version can be obtained by Maven
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson</artifactId>
<version>1.15.0-rc</version>
</dependency>
You may also need
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-java6</artifactId>
<version>1.15.0-rc</version>
</dependency>
Use this class for JacksonFactory instead of the previous one.
com.google.api.client.json.jackson2.JacksonFactory
Since version 1.11, jackson library has been moved out to separate jar to provide developers better choice of versions of each library. Please check readme.html of zip file you downloaded from google-api-java-client and you can check which specific jar file you want to include in your project.
http://mvnrepository.com/artifact/com.google.api.client/google-api-client/1.4.1-beta
This dependency will solve your problem:
<dependency>
<groupId>com.google.api.client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.4.1-beta</version>
</dependency>
For gradle.build =
compile group: 'com.google.http-client', name: 'google-http-client-jackson2', version: '1.11.0-beta'

Getting java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DEREncodable during PDF Encryption [duplicate]

I'm trying to use iText Java.
When you run the example "how to sign" the following error occurs:
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.tsp.TimeStampTokenInfo
According "Getting Started with iText - How to sign a PDF using iText", I have to use the BouncyCastle.
I downloaded the file: bcprov-jdk15on-147.jar from BouncyCastle download page.
And added to the project: Java Build Path/Libraries/Add External JARs...
I added the following line:
Security.addProvider(new BouncyCastleProvider());
When you run the example the same error occurs.
So I downloaded another file: bcpkix-jdk15on-147.jar entitled "PKIX/CMS/EAC/PKCS/OCSP/TSP/OPENSSL"
And added to the project: Java Build Path/Libraries/Add External JARs...
Now I have two Jars.
When you run the example the following error occurs:
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.asn1.DEREncodable
I tried downloading the file "bcprov-ext-jdk15on-147.jar" but did not solve the problem.
I am using iText 5.2.1 and eclipse on Windows 7 64 bits.
iText marks bouncycastle dependencies as optional. If you require them, you need to add the dependencies in your own pom file.
To find out which dependency to include in your project, open the itextpdf pom.xml file of the version you are using (for example 5.3.2, here) and search for the 2 bouncycastle dependencies.
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.47</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
<version>1.47</version>
<optional>true</optional>
</dependency>
Copy them into your pom file and remove the optional option.
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.3.2</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.47</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
<version>1.47</version>
</dependency>
BouncyCastle libs are undergoing heavy API changes that broke the compatibility with other libs like iText.
Either
use a previous version of BouncyCastle libs. Old versions can be found here. However, you'll have to find the right version of iText that was compatible with this particular version of BC.
make your own build of iText (the SVN trunk has been fixed). iText can be build with Maven (there's a short readme file at the root of the SVN). Please note that it's at your own risk, there may be bugs in trunk.
wait for the next version of iText. From my experience, iText releases come every couple of months, sometime more often, sometimes less. I'm not an iText committer though, so I can't give you any ETA.
More information can be found in this thread
With itextpdf version 5.5.4 org.bouncycastle dependencies are marked as <optional>true</optional>. This means you MUST include those dependencies in your own pom, or you can run into classnotfound exceptions.
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.4</version>
</dependency>
<!-- Bouncycastle dependencies necessary as they are optional = true
in itextpdf ... but they're not-so-optional in reality -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.49</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.49</version>
</dependency>
from version of bcprov-jdk15on-147, class of DEREncodable is no longer exist under the path of org.bouncycastle.asn1. You can use version before 146 (including 146) to resolve this question.
It's strange that the jars available at bouncycastle.org don't seem to contain this class. Perhaps, you may want to use one from the locations listed in this page (link).
i have the same problem, but a fix it when i download the libreria and update those files on /WEBINF/LIB
Luckily, the dependency jars are being delivered along with the iText now.
Please check the repository link below and download extrajars.zip file
http://sourceforge.net/projects/itext/files/
For jruby-ers with the same failure, I updated to jruby-complete-9.1.13.0.jar from jruby-complete-1.6.6.jar and the problem seemed to resolve...FWIW...

Does JAXB work under Java 5?

Building with maven I get "package javax.xml.bind.annotation does not exist"
What do I need to make JAXB work with Java 5?
JAXB APIs are bundled in JDK1.6, but these are not available in JDK <1.6 (ex: JDK1.5).
I have a Java to XML code written in JDK1.6 and once I switched to JDK1.5, I got the following error:
*Exception in thread "main" java.lang.RuntimeException: javax.xml.bind.JAXBException
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
...
Caused by: javax.xml.bind.JAXBException
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]*
...
JDK1.5 doesnt contain the JAXB APIs and therefore I applied the following fix:
I used JDK1.5 and the following two JARS: jaxb-api-2.0.jar and jaxb-impl-2.0.jar in my classpath and the error was resolved.
I hope this helps.
Another Reference: http://www.mkyong.com/java/jaxb-hello-world-example/
You can download the reference implementation (RI) from http://jaxb.dev.java.net/.
I can't advise you on how to make it work with maven though - more trouble than it's worth, if you ask me.
Java6 included a slightly modified version of the RI, but the RI itself works just fine with Java5.
Using the following versions will work with JDK5:
<!--
versions after 2.2.4 requires jdk6, please refer
to https://java.net/jira/browse/JAXB-890
-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.4-1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<version>1.3.3</version>
</dependency>
It seems there are many versions and differing paths to get JAXB from a maven repository.
My best guess for the correct artifact is javax.xml.bind:jaxb-api:2.2
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2</version>
<scope>compile</scope>
</dependency>
Jaxb should work with Java 5 but it seems that there are more people having issues with it.
Could it be that are missing some jars?
Check out this forum post.

Categories

Resources