java 在 Tomcat 7 中部署 JAX-WS webapp
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11625809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Deploying JAX-WS webapp in Tomcat 7
提问by RickDavis
I am developing simple JAX-WS webservice. I am creating WAR file using ANT build script. The file when deployed to Tomcat 7 server, throws following exception and there is deployment error as follows.
我正在开发简单的 JAX-WS web 服务。我正在使用 ANT 构建脚本创建 WAR 文件。该文件在部署到 Tomcat 7 服务器时,抛出以下异常并出现如下部署错误。
JAXB 2.1 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/D:/DreamSoln/Server/apache-tomcat-7.0.29/webapps/WebserviceDemo/WEB-INF/lib/jaxb-impl.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.2 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader.
JAXB 2.1 API 正在从引导类加载器加载,但是这个 RI(来自 jar:file:/D:/DreamSoln/Server/apache-tomcat-7.0.29/webapps/WebserviceDemo/WEB-INF/lib/jaxb-impl. jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) 需要 2.2 API。使用背书目录机制将 jaxb-api.jar 放在引导类加载器中。
I have JDK 1.6 installed, I tried endorsed mechanism i.e. I created lib/endorsed directory and copied jaxb-api.jar and jaxws-api.jar in it. But still it does not work.
我安装了 JDK 1.6,我尝试了认可机制,即我创建了 lib/endorsed 目录并在其中复制了 jaxb-api.jar 和 jaxws-api.jar。但它仍然不起作用。
Do I need to remove jaxb-api.jar and jaxws-api.jar from WEB-INF/lib of my web-app?
我需要从我的网络应用程序的 WEB-INF/lib 中删除 jaxb-api.jar 和 jaxws-api.jar 吗?
What else needs to be done?
还需要做什么?
采纳答案by ggarciao
I think that you are not endorsing correctly the tomcat lib. The folder lib/endorsed
was used in previous version of tomcat (like Tomcat 5.5 if I remembered correctly) but in the new ones (Tomcat 6 and afterwards) the endorsed lib is usually at <TOMCAT_HOME>/endorsed
(if it does not exist, you have to create it).
我认为您没有正确认可 tomcat lib。该文件夹lib/endorsed
在以前版本的 tomcat 中使用(如果我没记错的话,就像 Tomcat 5.5),但在新版本(Tomcat 6 及更高版本)中,背书库通常位于<TOMCAT_HOME>/endorsed
(如果它不存在,则必须创建它)。
Actually, tomcat use the system property java.endorsed.dirs
to define the endorsed folder location. So please check this value in your tomcat installation.
实际上,tomcat 使用系统属性java.endorsed.dirs
来定义背书文件夹位置。所以请在你的 tomcat 安装中检查这个值。
How to check this? Printing this property in any servlet/listener that you have in your application.
如何检查这个?在您的应用程序中的任何 servlet/侦听器中打印此属性。
ExampleUsing a context listener (inspired from this blog)
使用上下文侦听器的示例(受此博客启发)
public class WebappLoadListener implements ServletContextListener {
public void contextDestroyed(ServletContextEvent arg0) {
}
public void contextInitialized(ServletContextEvent arg0) {
System.out.println("\n\n\n ENDORSED DIR: " +System.getProperty("java.endorsed.dirs"));
}
}
Hoping it helps,
希望有帮助,
回答by David Blevins
Yes, you should remove these from the webapp once they are in the endorsed dir.
是的,一旦它们位于认可的目录中,您应该从 webapp 中删除它们。
If you try the Java EE version of Tomcat, TomEE Plus, JAX-WS support is already integrated and JAXB 2.2 is in the endorsed dir.
如果您尝试使用 Java EE 版本的 Tomcat,TomEE Plus,则 JAX-WS 支持已经集成并且 JAXB 2.2 位于认可目录中。
回答by user1987452
Tomcat 7 does NOT support JAX-WS out of box. To enable JAX-WS on Tomcat you need
Tomcat 7 不支持开箱即用的 JAX-WS。要在 Tomcat 上启用 JAX-WS,您需要
- to include at least "catalina-ws.jar" in Tomcat's lib (not necessarly under "endorsed"!).
- 在 Tomcat 的库中至少包含“catalina-ws.jar”(不一定在“认可”之下!)。
"catalina-ws.jar" should be downloaded as "Tomcat extras", and it is not included in TC7's default download archive.
“catalina-ws.jar”应该作为“Tomcat extras”下载,它不包含在TC7的默认下载档案中。
- Include the "JAX-WS RI" libs in your web applications lib.
- 在您的 Web 应用程序库中包含“JAX-WS RI”库。
just try google "The Next Milestone: JAX-WS Web Service on Tomcat and JBoss", you would find more information about this topic.
只需尝试谷歌“下一个里程碑:Tomcat 和 JBoss 上的 JAX-WS Web 服务”,您就会找到有关此主题的更多信息。
(However for a Java EE container like JBoss 7, all libs are there already. )
(但是对于像 JBoss 7 这样的 Java EE 容器,所有的库都已经存在了。)