java.util.List 是一个接口,JAXB 无法处理接口
2022-08-31 20:39:22
尝试部署应用程序时,我似乎遇到以下异常:
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
java.util.List is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at java.util.List
at private java.util.List foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse._return
at foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse
java.util.List does not have a no-arg default constructor.
this problem is related to the following location:
at java.util.List
at private java.util.List foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse._return
at foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse
我的代码运行良好,直到我将返回类型从List更改为List<List<RelationCanonical>>
下面是部分 Web 服务:
@Name("relationService")
@Stateless
@WebService(name = "RelationService", serviceName = "RelationService")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class RelationService implements RelationServiceLocal {
private boolean login(String username, String password) {
Identity.instance().setUsername(username);
Identity.instance().setPassword(password);
Identity.instance().login();
return Identity.instance().isLoggedIn();
}
private boolean logout() {
Identity.instance().logout();
return !Identity.instance().isLoggedIn();
}
@WebMethod
public List<List<RelationCanonical>> getRelationsFromPerson(@WebParam(name = "username")
String username, @WebParam(name = "password")
String password, @WebParam(name = "foedselsnummer")
String... foedselsnummer) {
......
......
......
}
我也尝试过删除@SOAPBinding并尝试默认,但出现相同的结果。感谢任何帮助
更新
我想指出一些事情。我将所有列表更改为ArrayList,然后编译。我之所以说编译而没有工作,是因为它表现得很奇怪。我得到一个对象类型:RelationServiceStub.ArrayList,但该对象没有get方法或也不表现为List。我也试图把它扔到一个列表中,但这不起作用。
请注意,这是在我使用Axis 2和wsdl2java之后,所以是的,现在它编译了,但我不知道如何获取数据。