Deploying JAX-WS webservice as War in Apache Tomca

2019-07-12 14:02发布

问题:

I have developed a webservice using JAXWS and able to run it from the eclipse on Tomcat 7 without any problem.

But my question is how to deploy it in Apache a war file. When ever I give Run On Server it ends up with exception SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoClassDefFoundError: org/glassfish/ha/store/api/BackingStoreException

And If I log into Apache and try to run from there, I can see this FAIL - Application at context path /IPWSv2 could not be started

This is my 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>

And I have this mapping in my web.xml

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

It works if I run it with the enpoint publisher,

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

}

Following is the stack trace:

   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'

I googled for this but not able to find how to deploy this.

Can any body please suggest me to resolve this?

Thanks in advance

回答1:

I solved it by copying the file ha-api.jar of JAX-WS dependencies and pasting it in $CATALINA_HOME\lib



回答2:

  1. Go http://jax-ws.java.net/.
  2. Download JAX-WS RI distribution.
  3. Unzip it and copy following JAX-WS dependencies to Tomcat library folder “{$TOMCAT}/lib“:

    jaxb-impl.jar, jaxws-api.jar, jaxws-rt.jar, gmbal-api-only.jar, management-api.jar, stax-ex.jar, streambuffer.jar, policy.jar.

Cheers!