开发者

Deploying web services in java

I have a开发者_运维百科 java web service. The actual operations of it are not important. But what is important is the return value. It is returning a class I created called 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
    }

Here is the return capsule code. Its pretty much just a wrapper for some data.


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;
    }

}

The webservice compiles correctly. However, when I try to deploy it, it get the following error from 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


My main question is, can is it possible to actually return a custom class using java web services. My second question is, any idea on how I can fix this based off of these error messages?


Yes you can return custom classes with java web services. As for your second question, it looks like you are missing a dependency in your ear. Check out this post.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜