java.lang.NoClassDefFoundError error when running my project - java

I have been struggling to get this to work and I think i can use some help. I am working on a Java project where the pom.xml has a bunch of dependencies some of which are themselves indirectly dependent on this jar:
com.sun.jersey:jersey-core:1.17.1 like this:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.0.1</version>
</dependency>
And I need this particular jar in my pom because I want to use the new features in jax-rs api:
javax.ws.rs:javax.ws.rs-api:2.0.The problem is when I build my project I get this error:
Found duplicate classes in [com.sun.jersey:jersey-core:1.17.1,javax.ws.rs:javax.ws.rs-api:2.0] :
[WARNING] javax.ws.rs.ApplicationPath
[WARNING] javax.ws.rs.Consumes
[WARNING] javax.ws.rs.CookieParam
[WARNING] javax.ws.rs.DELETE
[WARNING] javax.ws.rs.DefaultValue
[WARNING] javax.ws.rs.Encoded
[WARNING] javax.ws.rs.FormParam
[WARNING] javax.ws.rs.GET
[WARNING] javax.ws.rs.HEAD
[WARNING] javax.ws.rs.HeaderParam
...
..
I tried to fix this by excluding com.sun.jersey:jersey-core:1.17.1 from dependencies which were including it by checking the dependency tree.
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.0.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</exclusion>
</exclusions>
</dependency>
Now the project builds fine but when I try to run it I get this error:
java.lang.NoClassDefFoundError: com/sun/jersey/core/util/FeaturesAndProperties
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.7.0_51]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531) ~[na:1.7.0_51]
at java.lang.Class.getDeclaredMethods(Class.java:1855) ~[na:1.7.0_51]
at com.google.inject.internal.ProviderMethodsModule.getProviderMethods
(ProviderMethodsModule.java:81) ~[guice-3.0.jar:na]
at com.google.inject.internal.ProviderMethodsModule.configure
(ProviderMethodsModule.java:73) ~[guice-3.0.jar:na]
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
~[guice-3.0.jar:na]
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:232)
~[guice-3.0.jar:na]
at com.google.inject.spi.Elements.getElements(Elements.java:101) ~[guice-3.0.jar:na]
at com.google.inject.spi.Elements.getElements(Elements.java:92) ~[guice-3.0.jar:na]
It seems like jersey core was needed but how do I get around this problem?

You can't mix JAX-RS / Jersey versions
Jersey version 1 is the reference implementation for JAX-RS 1. Jersey version 1 uses the com.sun.jersey group / package prefix.
Jersey version 2 is the reference implementation for JAX-RS 2. Jersey version 2 uses the org.glassfish.jersey group / package prefix
If you have both Jersey versions, or both JAX-RS versions on your classpath, you'll get lots of NoClassDefFoundError, NoSuchMethodError or similar.
If possible use JAX-RS / Jersey version 2

For me this actually means I had somehow mixed things and was using
$ mvn dependency:list | grep jersey
[INFO] com.sun.jersey:jersey-client:jar:1.11:compile
[INFO] com.sun.jersey:jersey-core:jar:1.0.2:compile
(conflict within jersey 1.x)

Jersey is the reference implementation of JAX-RS, so you don't need the latest version of JAX-RS API (javax.ws.rs:javax.ws.rs-api:2.0) but the latest version of Jersey which is 2.8 (see https://jersey.java.net/).

Related

Maven multi modules project [duplicate]

When I run my applicaiton from Eclipse it runs without any errors for servlet api 3.1.0 and 3.0.1.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
I use tomcat 8.0.21 for eclipse. I have set up tomcat8 on ubuntu machine which runs on tomcat 8.0.14 stable version.
Unfortunately, I get the following error message if I use servlet api 3.1.0. But it works for the older version 3.0.1.
root cause
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: [50] in the generated java file: [/var/lib/tomcat8/work/Catalina/localhost/ROOT/org/apache/jsp/WEB_002dINF/view/templates/login_002dtemplate_jsp.java]
The method getDispatcherType() is undefined for the type HttpServletRequest
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
Why do I get this error? How to fix this?
You're not supposed to provide Servlet API along with the web application archive if the target runtime already provides the API out the box. Tomcat as being a JSP/Servletcontainer already provides JSP, Servlet and EL APIs out the box. When you provide them along with your webapp anyway, then you may run into classloading conflicts caused by duplicate different versioned classes in the runtime classpath coming from both the webapp and the server.
Add <scope>provided</scope> to those dependencies already provided by the target runtime.
See also:
How do I import the javax.servlet API in my Eclipse project?
For Maven users there are several good answers here that you might want to check out.
I'm still in the dark ages, and am not using a dependency manager for my Tomcat project. If you're like me and have this issue, here's how I solved it: It seems tomcat provides the javax.servlet classes, so these don't need to be in your project's lib file. (I originally had the servlet-api-2.5.jar in my /WEB-INF/lib directory.) However you'll probably still need it to compile (I did), so you should move it to a location included in your java classpath. You may also need to tell your IDE where to look.
Hope that helps.
Method ServletRequest#getDispatcherType() was introduced to the Servlet Spec since version 3.0. The following error means that you are using an older version (e.g., 2.5) of javax.servlet-api in your application.
The method getDispatcherType() is undefined for the type HttpServletRequest
To solve this issue, you could follow the following two steps:
First of all, add <scope>provided</scope> to dependency javax.servlet-api
You should add <scope>provided</scope> to the dependency, because your Tomcat container will provide the dependency at runtime. And at the same time, ensure that you are using Tomcat 7 or higher, which supports Servlet Spec 3.0 or higher.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
Second of all, exclude any older version of javax.servlet-api
You need to ensure that any older version (e.g., 2.5) of javax.servlet-api is not included transitively. You can use mvn dependency:tree to find out. See below an example:
$ mvn dependency:tree
...
[INFO] +- com.google.oauth-client:google-oauth-client-servlet:jar:1.20.0:compile
[INFO] | +- com.google.oauth-client:google-oauth-client:jar:1.20.0:compile
[INFO] | +- com.google.http-client:google-http-client-jdo:jar:1.20.0:compile
[INFO] | +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] | \- javax.jdo:jdo2-api:jar:2.3-eb:compile
[INFO] | \- javax.transaction:transaction-api:jar:1.1:compile
...
In this case, javax.servlet-api version 2.5 is included transitively by a dependency called google-oauth-client-servlet. We need to exclude it in pom.xml, like below:
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-servlet</artifactId>
<version>1.20.0</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
That's it.

How to avoid dependency conflict when using dropwizard + jersey client

I have a DropWizard REST API written and works. One of the resource endpoints actually writes an email, however as soon as I add the following dependencies DropWizard starts to fail on start up
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.18.1</version>
</dependency>
The DropWizard dependency is:
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>0.8.1</version>
</dependency>
The error on startup is really long, summarised below
WARN [2015-05-01 20:06:08,887] org.glassfish.jersey.internal.Errors: The following warnings have been detected: WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 2
java.lang.NullPointerException
at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(AbstractJAXBProvider.java:113)
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:606)
....
MultiException stack 2 of 2
java.lang.IllegalStateException: Unable to perform operation: method inject on com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:395)
....
MultiException stack 3 of 3
java.lang.IllegalStateException: Unable to perform operation: create on org.glassfish.jersey.message.internal.MessageBodyFactory
...
I'm guessing DropWizard is using another conflicting dependency so how do I deal with this?
Thanks in advance
Dropwizard 0.8.x uses Jersey 2.x which naturally conflicts with your Jersey 1.x dependencies.
I think it might be fine with jersey-client as long as you don't have dropwizard-client dependency but jersey-core will conflict at many points with dropwizard's jersey which I don't think you can fix. And also I don't think you'd need jersey-core for sending email anyway.
If you do need jersey for this, try using Jersey 2.16 instead which is the version dropwizard is using.
I had the same problem (I'm using DW 0.9.2 and have unwanted transitive dependencies of both DW 0.7.2 and Jersey 1.x)
The solution was pretty simple: in the dependency that's bringing you those two family of libraries, declare an exclusion and it should work, for instance, this is how I did it in Gradle:
compile("com.example.culprit:culprit:1.2.3") {
exclude group: 'io.dropwizard'
exclude group: 'com.sun.jersey'
}
The syntax for Maven is pretty similar (more verbose actually ;-) )
Hope this helps someone.

NoSuchMethodError on startup in Java Jersey app

I've been getting a very strange error when trying to start a Jersey app on Tomcat. The same code works on other computers. I tried reinstalling tomcat, all my maven dependencies, even Eclipse and Java itself, no luck. It seems like a bad Jersey version is being loaded, I think?
Any pointers in the right direction will be appreciated.
Here's the effective pom: http://pastebin.com/NacsWTjz
And the actual pom: http://pastebin.com/H6sHe4ce
2015-02-13 13:43:40,870 [localhost-startStop-1] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/middleware-server] - StandardWrapper.Throwable
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:304)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4901)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5188)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Note: Please see above comments for further discussion and tips.
This error usual means that you have a both a JAX-RS 1 and JAX-RS 2 jar on the classpath. Jersey 2 uses JAX-RS 2 (javax.ws.rs-api-2.0.1.jar), but if you have the jsr311-api.jar also, which is JAX-RS 1, there is a javax.ws.rs.core.Application in each jar. But the jsr311-api Application doesn't have the method getProperties() (hence NoSuchMethodError).
I've come to the conclusion that all you need to do is add the above exclusion to the swagger dependency. The Jackson 2.0 provider (which depends on JAX-RS 1) seems to be overridden by a 2.4.1 provider (which uses the new version). So we don't need to add it ourselves. When it's overridden, it seems to leave behind the jsr311-api.jar. So if we exclude it, no one can attempt to use it, which looks to be the current problem
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core_2.10</artifactId>
<version>1.3.11</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
We are using jersey-json 1.9 which has a dependency on jersey-core which also happen to have a javax.ws.rs.core.Application class.
So our fix is to exclude the jersey-core from jersey-json:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.9</version>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</exclusion>
</exclusions>
</dependency>
the problem is related about "com.sun.jersey:jersey-core:jar:1.18.3" (or any 1.* version) because old versions of Jersey didn't have that "public Map getProperties()" method.
And one of your dependencies use Jersey version 1 (you can check that in running mvn dependency:tree and search all jersey-core version used)
Me I have resolved the problem deleting all com.sun.jersey dependancies (old api) and using the new one org.glassfish.jersey API
https://mvnrepository.com/artifact/org.glassfish.jersey.core

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.

What's the minimum classpath for an Axis2 client?

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.

Categories

Resources