Trouble with JAXB

I spent two days figuring out what had gone wrong with my simple JAX-WS web service. The service I wrote was previously deployed using Axis2 1.4.1 engine running on IBM's Websphere Application Server (Community Edition) version 1.1. However, I recently had to port my application over to version 2 and that's when problems started to surface.

Putting a web service using Axis2 was easy. Using Maven and the Axis2 tool plugin, you can compile and package the code into an AAR archive file. The package is then uploaded and deployed on the web services engine using its built-in administrative console application. Client artifacts can then be generated using the axis2-wsdl2code-maven-plugin.

WASCE v2 comes with Axis2 built into its core libraries. The Axis2 admin console isn't present together with the app server. To create and deploy web services, you will need to use JAX-WS annotations to decorate your service class. You may or may not wish to code your own WSDL and corresponding configuration files, but that isn't necessary as WASCE takes care of WSDL and configuration file generation. Simply pack your web service within a Java EE webapp and deploy it using WASCE admin console. After that, generate client artifacts using the JAX-WS maven plugin.

There were no problems with deploying the web service and creating the client artifacts. However, when the service was called, an IllegalArgumentException was thrown; an exception class I created "does not have a no-arg default constructor".

A bit of googling led me to understand that Throwables have a method that returns an array of StackTraceElement. This class does not declare a default no-args constructor and the was the root of the problem. To fix this problem, I tried adding the @WebFault annotation to Exception classes I created. This made my classes valid errors that could be thrown by my web service, and this solution seemed to work.

WASCE v2.0.1 uses Axis2 v1.3 instead of v1.4.1, which I was using earlier. Perhaps this issue was resolved in the latter version.

 

 

 

 

Reblog this post [with Zemanta]

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Sorry about foisting WSCE2 on

Sorry about foisting WSCE2 on you.

Challenges are opportunities for learning

Hey Andrew. No worries. It's the right way forward, and I gained from the experience! :)

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.