我在 NetBeans 中创建了一个简单的 Java EE 项目(文件 -> 新项目 -> Java Web -> Web 应用程序)。
在新创建的项目中,我添加了一个名为“CesaService”的 Web 服务。这是来源:
package com.convista.jcesa.webservice;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService(serviceName = "CesaService")
public class CesaService {
@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "name") String txt) {
return "Hello " + txt + " !";
}
}
NetBean 然后生成以下文件:
太阳jaxws.xml:
<?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
<endpoint implementation="com.convista.jcesa.webservice.CesaService" name="CesaService" url-pattern="/CesaService"/>
</endpoints>
网页.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>CesaService</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CesaService</servlet-name>
<url-pattern>/CesaService</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
我的服务器是随附的 Tomcat 7.0.22.0。当我启动项目时,我收到以下错误:
Schwerwiegend: WSSERVLET11: failed to parse runtime descriptor: javax.xml.ws.WebServiceException: class com.convista.jcesa.webservice.jaxws.Hello do not have a property of the name name
javax.xml.ws.WebServiceException: class com.convista.jcesa.webservice.jaxws.Hello do not have a property of the name name
at com.sun.xml.ws.server.sei.EndpointArgumentsBuilder$DocLit.<init>(EndpointArgumentsBuilder.java:531)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.createArgumentsBuilder(EndpointMethodHandler.java:133)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.<init>(EndpointMethodHandler.java:106)
at com.sun.xml.ws.server.sei.SEIInvokerTube.<init>(SEIInvokerTube.java:82)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:219)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:505)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:124)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.xml.bind.JAXBException: name is not a valid property on class com.convista.jcesa.webservice.jaxws.Hello
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor(JAXBContextImpl.java:971)
at com.sun.xml.ws.server.sei.EndpointArgumentsBuilder$DocLit.<init>(EndpointArgumentsBuilder.java:520)
... 16 more
Jun 13, 2012 2:31:35 PM org.apache.catalina.core.StandardContext startInternal
Schwerwiegend: Error listenerStart
Jun 13, 2012 2:31:35 PM org.apache.catalina.core.StandardContext startInternal
Schwerwiegend: Context [/FST] startup failed due to previous errors
Jun 13, 2012 2:31:35 PM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextDestroyed
Information: WSSERVLET13: JAX-WS context listener destroyed
Jun 13, 2012 2:31:36 PM org.apache.catalina.core.StandardContext reload
Information: Reloading Context with name [/FST] is completed
你知道是什么原因造成的吗?我不想上课com.convista.jcesa.webservice.jaxws.Hello
,也不明白它在哪里被引用。
提前致谢!