简体   繁体   中英

Can not deploy Java Web Service to Glassfish

I am trying to deploy a simple web service to Glassfish. Here is the web service class:

import com.dv.testrunner.extended.Task;
import com.medallion.etl.exception.StepExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

/**
 *
 * @author dvargo
 */
@WebService(serviceName = "Execute")
public class Execute
{
    /**
     * Web service operation
     */
    @WebMethod(operationName = "executeTask")
    public boolean executeTask(@WebParam(name = "task") Task task)
    {
        boolean setUp = task.setUp();
        boolean execute;
        try
        {
            execute = task.execute();
        }
        catch (StepExecutionException ex)
        {
            Logger.getLogger(Execute.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
        return setUp && execute;
    }
}

Task is a simple interface. Here is the interface:

package com.dv.testrunner.extended;

import com.medallion.etl.exception.StepExecutionException;

/**
 *
 * @author dvargo
 */
public interface Task
{

    public boolean execute() throws StepExecutionException;

    public boolean setUp();

}

When I try to deploy my web service via Netbeans, I get the following error:

java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: Servlet web service endpoint '' failure
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:138)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:680)

Does anyone have any ideas on what is happening and how I may fix it? Is it that I can not use Task as a parameter?

JAX-WS does not allow interfaces as method parameters. Try replacing Task with a class.

Not only JAX-WS does not allow interfaces, it even makes no sense in your case. How would you specify what the task is supposed to do? You need a concrete class as a parameter, and the class needs to be annotated with @XmlRootElement . If you want your endpoint to support different tasks, you will need more operations with different names to achieve that.

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