简体   繁体   中英

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM