在Apache Tomcat中将JAX-WS Web服务部署为War

时间:2013-06-04 06:03:19

标签: java web-services apache jaxb jax-ws

我使用JAXWS开发了一个web服务,并且可以在Tomcat 7上的eclipse中运行它而没有任何问题。

但我的问题是如何在Apache中部署一个war文件。当我给Run On Server时,它最终会出现异常 SEVERE:WSSERVLET11:无法解析运行时描述符:java.lang.NoClassDefFoundError:org / glassfish / ha / store / api / BackingStoreException

如果我登录Apache并尝试从那里运行,我可以看到 FAIL - 无法启动上下文路径/ IPWSv2上的应用程序

这是我的sun-jaxws.xml:

 <?xml version="1.0" encoding="UTF-8"?>
   <endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
    <endpoint name="IPWSServiceV1" implementation="com.ipws.insurpay.ipwsv1.IPWSServiceV1"
    url-pattern="/IPWSServiceV1" />
</endpoints>

我在web.xml中有这个映射

 <servlet-mapping>
    <servlet-name>IPWSServiceV1</servlet-name>
    <url-pattern>/IPWSServiceV1</url-pattern>
</servlet-mapping>

如果我使用enpoint发布商

运行它,它就有效
public static void main(String[] args) {
     Endpoint.publish("http://host/Project-Name/IPWSServiceV1",
             new IPWSServiceV1());

}

以下是堆栈跟踪:

   Jun 4, 2013 11:18:02 AM org.apache.catalina.core.StandardContext startInternal
 SEVERE: Context [/IPWSv2] startup failed due to previous errors
 Jun 4, 2013 11:18:07 AM org.apache.catalina.startup.HostConfig deployDirectory
 INFO: Deploying web application directory C:\Program Files\Apache Software       Foundation\Tomcat 7.0\webapps\docs
 Jun 4, 2013 11:18:07 AM org.apache.catalina.startup.HostConfig deployDirectory
 INFO: Deploying web application directory C:\Program Files\Apache Software   Foundation\Tomcat 7.0\webapps\manager
 Jun 4, 2013 11:18:08 AM org.apache.catalina.startup.HostConfig deployDirectory
 INFO: Deploying web application directory C:\Program Files\Apache Software   Foundation\Tomcat 7.0\webapps\ROOT
Jun 4, 2013 11:18:08 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jun 4, 2013 11:18:08 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jun 4, 2013 11:18:08 AM org.apache.catalina.startup.Catalina start
 INFO: Server startup in 7668 ms
 Jun 4, 2013 11:22:54 AM org.apache.catalina.core.ApplicationContext log
 INFO: HTMLManager: init: Associated with Deployer    'Catalina:type=Deployer,host=localhost'
 Jun 4, 2013 11:22:54 AM org.apache.catalina.core.ApplicationContext log
 INFO: HTMLManager: init: Global resources are available
 Jun 4, 2013 11:22:54 AM org.apache.catalina.core.ApplicationContext log
 INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
 Jun 4, 2013 11:22:56 AM org.apache.catalina.core.ApplicationContext log
 INFO: HTMLManager: start: Starting web application '/IPWSv2'
 Jun 4, 2013 11:22:57 AM com.sun.xml.ws.transport.http.servlet.WSServletContextListener    parseAdaptersAndCreateDelegate
SEVERE: WSSERVLET11: failed to parse runtime descriptor:     java.lang.NoClassDefFoundError: org/glassfish/ha/store/api/BackingStoreException
 java.lang.NoClassDefFoundError: org/glassfish/ha/store/api/BackingStoreException
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.<init>  (ServletAdapter.java:95)
at     com.sun.xml.ws.transport.http.servlet.ServletAdapterList.createHttpAdapter(ServletAdapterList.java:77)
at com.sun.xml.ws.transport.http.servlet.ServletAdapterList.createHttpAdapter(ServletAdapterList.java:53)
at com.sun.xml.ws.transport.http.HttpAdapterList.createAdapter(HttpAdapterList.java:77)
at com.sun.xml.ws.transport.http.HttpAdapterList.createAdapter(HttpAdapterList.java:71)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:266)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:152)
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.parseAdaptersAndCreateDelegate(WSServletContextListener.java:131)
at com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer.onStartup(WSServletContainerInitializer.java:65)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5274)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1256)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:714)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:219)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:193)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


Caused by: java.lang.ClassNotFoundException:    org.glassfish.ha.store.api.BackingStoreException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 38 more
Jun 4, 2013 11:22:57 AM org.apache.catalina.core.StandardContext startInternal
  SEVERE: Context [/IPWSv2] startup failed due to previous errors
Jun 4, 2013 11:22:57 AM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'

我用Google搜索但未能找到如何部署它。

任何人都可以建议我解决这个问题吗?

提前致谢

2 个答案:

答案 0 :(得分:3)

我通过复制JAX-WS依赖项的ha-api.jar文件并将其粘贴到$ CATALINA_HOME \ lib

中解决了这个问题。

答案 1 :(得分:1)

  1. 转到http://jax-ws.java.net/
  2. 下载JAX-WS RI发行版。
  3. 解压缩并将以下JAX-WS依赖项复制到Tomcat库文件夹“{$ TOMCAT} / lib”:

    JAXB-impl.jar中, JAXWS-api.jar文件, JAXWS-rt.jar中, gmbal-API only.jar, 管理-api.jar文件, STAX-ex.jar, streambuffer.jar, policy.jar。

  4. 干杯!