Web services 加载应用程序时出现Glassfish 4.0异常,java.lang.IllegalStateException

Web services 加载应用程序时出现Glassfish 4.0异常,java.lang.IllegalStateException,web-services,glassfish,Web Services,Glassfish,我不熟悉web服务和glassfish。这是我的密码 package ws.mypkg; import java.util.ArrayList; import java.util.List; import javax.jws.WebMethod; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style; @WebService @SOAPB

我不熟悉web服务和glassfish。这是我的密码

package ws.mypkg;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

@WebService
@SOAPBinding(style=Style.RPC)
public class TestRPC {

    // This seems to cause the problem when a List is returned.
    public List<String> testRPC () {
        List<String> l = new ArrayList<String>();
        l.add("Hello");
        return l;
    }

    // This method work fine
    public String testRPC1 () {
        return "Testing RPC";
    }
}
我在尝试部署web服务时遇到以下错误

无法部署TestGF部署失败=部署期间发生错误:异常 加载应用程序时:java.lang.IllegalStateException:ContainerBase.addChild:start: org.apache.catalina.LifecycleeException:java.lang.RuntimeException:Servlet web服务 终结点“”失败。有关详细信息,请参阅server.log

服务器日志没有更多内容

当我注释掉SOAPBinding(style=style.RPC)

问题似乎在于第一种方法。如果排除第一个方法,则第二个方法可以很好地部署。当我从该方法返回一个列表并且我有
@SOAPBinding(style=style.RPC)


我正在使用Glassfish 4.0、jdk 1.7和Eclipse(与Spring 3.4捆绑在一起)

问题在于,您的方法返回类型是一个接口,
JAXB
无法使用接口,因为它不知道要使用哪个
列表
实现

要修复它,只需将方法的返回类型更改为
ArrayList
,如下所示:

public ArrayList<String> testRPC () {
    ArrayList<String> l = new ArrayList<String>();
    l.add("Hello");
    return l;
}
如果发生类似的错误,这将为您指明正确的方向

另请参见:


谢谢。我将列表更改为ArrayList。没问题。但当我运行时,响应似乎返回一个空对象。我所看到的一切。但是,如果去掉RPC样式,我会看到列表返回为Hello
public ArrayList<String> testRPC () {
    ArrayList<String> l = new ArrayList<String>();
    l.add("Hello");
    return l;
}
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 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