我正在尝试让JAX-WS使用嵌入式tomcat 7.0。
我按照一些教程谈论了标准的Tomcat(例如http://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat/),但是我无法找到一个特定的Tomcat emebedded。
我在服务器上成功运行了自己的servlet,但在尝试使用包含所有JAX-WS注释的类(以及其他所有内容:web.xml中的WSServletContextListener + WSServlet,WEB中的sun-jaxws.xml)启动它时-INF),我收到以下错误:
INFO: Initializing ProtocolHandler ["http-bio-80"]
2 oct. 2012 14:48:20 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
2 oct. 2012 14:48:20 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27
2 oct. 2012 14:48:21 org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
INFO: No global web.xml found
2 oct. 2012 14:48:28 com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
INFO: WSSERVLET12 : initialisation du processus découte de contexte JAX-WS
2 oct. 2012 14:48:28 com.sun.xml.ws.transport.http.servlet.WSServletContextListener parseAdaptersAndCreateDelegate
SEVERE: WSSERVLET11 : fail analyzing descriptor : javax.xml.ws.WebServiceException: execution descriptor "/WEB-INF/sun-jaxws.xml" is missing
javax.xml.ws.WebServiceException: Le descripteur d'exécution "/WEB-INF/sun-jaxws.xml" is missing
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.parseAdaptersAndCreateDelegate(WSServletContextListener.java:125)
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:152)
它看起来像路径问题,但我不明白缺少什么,因为正确加载了同一文件夹WEB-INF文件夹中的web.xml ... 这是我的应用程序的启动代码: 试试{
Tomcat tomcat = new Tomcat();
tomcat.setBaseDir(".");
tomcat.setPort(80);
tomcat.getHost().setAppBase("src/main/webapp");
Context context = tomcat.addWebapp("/Test", ".");
File configFile = new File(tomcat.getHost().getAppBase() + "/META-INF/context.xml");
context.setConfigFile(configFile.toURI().toURL());
tomcat.enableNaming();
StandardServer server = (StandardServer)tomcat.getServer();
AprLifecycleListener listener = new AprLifecycleListener();
server.addLifecycleListener(listener);
tomcat.start();
tomcat.getServer().await();
} catch (Exception e) {
e.printStackTrace();
}
感谢您的帮助或建议......