[英]Can not deploy Java Web Service to Glassfish
I am trying to deploy a simple web service to Glassfish. 我正在尝试将简单的Web服务部署到Glassfish。 Here is the web service class: 这是Web服务类:
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: 当我尝试通过Netbeans部署Web服务时,出现以下错误:
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? 是我不能使用Task作为参数吗?
JAX-WS does not allow interfaces as method parameters. JAX-WS不允许将接口用作方法参数。 Try replacing Task with a class. 尝试用一个类替换Task。
Not only JAX-WS does not allow interfaces, it even makes no sense in your case. 不仅JAX-WS不允许使用接口,在您的情况下甚至都没有意义。 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
. 您需要一个具体的类作为参数,并且该类需要使用@XmlRootElement
进行注释。 If you want your endpoint to support different tasks, you will need more operations with different names to achieve that. 如果您希望端点支持不同的任务,则需要使用不同的名称进行更多的操作才能实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.