gpt4 book ai didi

java - 在java中部署Web服务

转载 作者:行者123 更新时间:2023-12-01 05:48:58 25 4
gpt4 key购买 nike

我有一个java网络服务。其实际操作并不重要。但重要的是返回值。它返回一个我创建的名为 GetReturnCapsule 的类。


/**
* Web service operation
*/
@WebMethod(operationName = "get")
public GetReturnCapsule get(@WebParam(name = "company")
final String company, @WebParam(name = "timeStamp")
final long timeStamp, @WebParam(name = "hash")
final int hash)
{
...stuff
}

这是返回胶囊代码。它几乎只是一些数据的包装。


public class GetReturnCapsule
{
long timeStamp;
List ips;
int hash;

public GetReturnCapsule(long timeStamp,Listips,int hash)
{
this.timeStamp = timeStamp;
this.ips = ips;
this.hash = hash;
}

public long getTimeStamp()
{
return timeStamp;
}

public int getHash()
{
return hash;
}

public List getIPs()
{
return ips;
}

}

Web 服务编译正确。但是,当我尝试部署它时,它从 Glashfish 收到以下错误。


SEVERE: Class [ com/compunetix/vsd/stix/server/webservices/GetReturnCapsule ] not found. Error while loading [ class com.compunetix.vsd.stix.server.webservices.GetIp ]
SEVERE: Class [ com/compunetix/vsd/stix/server/webservices/GetReturnCapsule ] not found. Error while loading [ class com.compunetix.vsd.stix.server.webservices.GetIp ]
SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbDeployer prepare method
SEVERE: Exception while preparing the app
SEVERE: Exception while preparing the app : Unable to load EJB module. DeploymentContext does not contain any EJB Check archive to ensure correct packaging for C:\Documents and Settings\dvargo\My Documents\STix1030Netbeans\STixWebService\build\web
SEVERE: Class [ com/compunetix/vsd/stix/server/webservices/GetReturnCapsule ] not found. Error while loading [ class com.compunetix.vsd.stix.server.webservices.GetIp ]
SEVERE: Class [ com/compunetix/vsd/stix/server/webservices/GetReturnCapsule ] not found. Error while loading [ class com.compunetix.vsd.stix.server.webservices.GetIp ]
SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbDeployer prepare method
SEVERE: Exception while preparing the app
SEVERE: Exception while preparing the app : Unable to load EJB module. DeploymentContext does not contain any EJB Check archive to ensure correct packaging for C:\Documents and Settings\dvargo\My Documents\STix1030Netbeans\STixWebService\build\web

我的主要问题是,是否可以使用 Java Web 服务实际返回自定义类。我的第二个问题是,知道如何根据这些错误消息解决此问题吗?

最佳答案

是的,您可以使用 Java Web 服务返回自定义类。至于你的第二个问题,看来你的耳朵缺少一种依赖。看看这个post .

关于java - 在java中部署Web服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5183680/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com