【问题标题】:Web Service Error: class xxx nor any of its super class is known to this contextWeb 服务错误:此上下文已知类 xxx 或其任何超类
【发布时间】:2012-03-01 06:50:37
【问题描述】:

我们在 Web Sphere 7.0.0.19 服务器上托管了一个 JAX-WS 服务。该服务是使用@WebService 注释实现的。如果我们点击服务请求 WSDL,我们成功地将 XML 返回给我们。但是,如果我们调用 Web 服务方法,它会返回以下错误:

javax.xml.ws.soap.SOAPFaultException: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: class com.penske.newreuse.vo.ApplicationConfigVO nor any of its super class is known to this context.]
    at     com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:171)
    at     com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:94)
    at     com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:240)
    at     com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210)
    at     com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103)

查看我们的日志记录,我们的代码被成功调用,并且我们返回了预期的数据。但是,当数据被编组以发送回客户端时,就会发生故障。

ApplicationConfigVO 类在一个单独的 jar 文件中,我们尝试将其拉出并直接将源包含在服务中,没有任何变化。

我在 ApplicationConfigVO 对象中添加了@XmlSeeAlso(ApplicationConfigVO.class),但仍然没有变化。


这是网络服务代码:

@WebService(serviceName="WebServiceConfigService")
public class WebServiceConfig {

private static Logger log = Logger.getLogger(WebServiceConfig.class);

public ApplicationConfigVO[] loadWsControlMode(int applicationId,String appsId) throws  Exception {
    log.info("loadWsControlMode WebService Invoked  Application ID :"+ appsId);
    List returnList = null;
    ApplicationConfigVO[] resultArray = null;

    try {
        ApplicationConfigVO modelObj = new ApplicationConfigVO();
        modelObj.setApplicationId(applicationId);
        IApplicationConfigDAO daoObj = DAOFactory.getApplicationConfigDAO();
        returnList = daoObj.loadWsControlMode(modelObj);

        if(null != returnList && returnList.size()>0){
            resultArray = new ApplicationConfigVO[returnList.size()];
            //Populate the ApplicationConfigVO array from arraylist
            modelObj = new ApplicationConfigVO();
            for(int i=0;i<returnList.size();i++){
                modelObj = (ApplicationConfigVO)returnList.get(i);
                resultArray[i] = modelObj;
            }//End of for loop
        }
    } catch (Exception e) {
        log.error(DAWebServiceUtil.stackTraceToString(e));
        throw e;
    }
    return resultArray;
}

这是 ApplicationConfigVO 类:

public class ApplicationConfigVO implements Serializable{

private int applicationId;
private String webServiceControlMode = null;
private int webServiceId;
private String webServiceName = null;
private int webServiceMethodId;
private int opModeId;
private String webServiceMethodDesc = null;

private int dataBaseTypeId;
private String dataBaseTypeDesc = null;

    ...  //  various getters and setters following java bean rules
}

【问题讨论】:

  • 我认为,loadWsControlMode()方法需要用@WebMethod注解。
  • 好吧,我忘了提一件事,在我们的 Windows 本地环境中,我们没有遇到任何问题。这只发生在我们在 Linux 上运行的完整环境中。
  • 好吧,我尝试了很多方法都无济于事。所以我下注了,我修改了返回 List 而不是 ApplicationConfigVO[] 的方法。在这一点上,我认为这是一个类加载器问题,但我不能确定。在任何一种情况下,切换到列表最终都会更容易,希望没有其他事情会困扰我们。

标签: web-services wsdl websphere jax-ws axis2


【解决方案1】:

好吧,我尝试了很多事情都无济于事。所以我下注了,我修改了方法以返回一个 List 而不是 ApplicationConfigVO[]。在这一点上,我认为这是一个类加载器问题,但我不能确定。在任何一种情况下,切换到列表最终都更容易,希望没有其他事情会困扰我们

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-27
    • 2012-12-13
    • 2014-07-03
    • 2013-09-13
    相关资源
    最近更新 更多