Skip to main content

Issues when calling a POJO web service (Axis2 JAX-WS)

2 replies [Last post]
Joined: 2008-11-03

There are two issues I am trying to fix:
1) I am trying to get a web service operation to return a List but when invoking the service from a client (or using SoapUI) I get the exception listed below (JAXB marshalling exception). I can return an array of Strings but not a List of Strings. Any idea how I might get JAXB to recognize collection classes?

2) When returning the values of an array I print out the values on the server side; in the case of method getStringNumbersNG() listed in the code below numbers 11, 12 and 13 get printed out. The client however prints out 1 as the array count it has received and 0 as the only number in it. (see the calls in the client to getNumbersNG() and getStringNumbersNG()). This must be something with the implementation of the client (used wsimport) because the results gotten with SoapUI are correct.

Thank you in advance for your help,

[ERROR] javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: java.util.List is not known to this context]
org.apache.axis2.AxisFault: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: java.util.List is not known to this context]
at org.apache.axis2.AxisFault.makeFault(
at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(
at org.apache.axis2.engine.AxisEngine.receive(
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: java.util.List is not known to this context]
... etc

public class NumbersNoGenerics {

public Integer getOneIntNumbers() {
System.out.println("int 42 is being returned");
return 42;

public List getNGList() {
List ret = new LinkedList();
System.out.println("List is being returned");
for(int i = 11; i < 14; i++) {
return ret;

public String[] getStringNumbersNG() {
String[] ret = new String[]{"11", "12", "13"};
System.out.println("Array of strings is being returned");
for(String s : ret) {
return ret;


public class NNGClient {
public static void main( String[] args ) {
NumbersNoGenericsService svcs = new NumbersNoGenericsService(); nngs = svcs.getNumbersNoGenericsPort();
Integer str = nngs.getOneIntNumbers();
System.out.println("got the following: " + str);

List nrs2 = nngs.getStringNumbersNG();
System.out.println("found " + nrs2.size() + " numbers");
for(int i =0; i < nrs2.size(); i++) {
System.out.println("Count Dracula says: " + nrs2.get(i));

//error occurs on this next line
List strs = nngs.getNGList();
System.out.println("found " + strs.size() + " numbers");
for(int i =0; i < strs.size(); i++) {
System.out.println("Count Chocula says: " + strs.get(i));

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2011-04-21

replace list with array, thats all for IBM Websphere 7.

Joined: 2008-11-03

Looks like there are some standard classes that JAXB 2.0 supports specifically and these are listed in in section 8.5.2 of the specification. Also the spec has the following:

8.5.4 Collections
The following collection must be supported:
- java.util.Map and its subtypes (e.g. java.util.HashMap)
- java.util.Collection and it’s subtypes (e.g. java.util.List)
The mapping of collection depends upon the annotations on the program elements and is specified in the mapping tables. This specification uses a collection type to be one of java.util.Collection (or a subtype derived
from it) , an array or an JavaBean index property.

I have no idea why I am getting this strange "javax.xml.bind.JAXBException: java.util.List is not known to this context" exception.