[英]Calling a JAX-WS RI 2.2 service from Tomcat6 with java6
I am trying to access a JAX-WS 2.2 service from Tomcat6 with Java6. 我正在尝试使用Java6从Tomcat6访问JAX-WS 2.2服务。 For what I have researched there is a problem with this, as Java tries to use first some of its default javax.xml.ws libraries which doesn't have the
WebFault.messageName
method. 对于我所研究的问题,这是有问题的,因为Java首先尝试使用其某些默认的javax.xml.ws库,但这些库没有
WebFault.messageName
方法。 So it fails with this error: 因此它失败并显示以下错误:
GRAVE: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
at com.sun.xml.ws.model.RuntimeModeler.processExceptions(RuntimeModeler.java:1162)
...
The solution seems to be creating an "endorsed" directory in JAVA_HOME/jre/lib/ (or in TOMCAT_HOME) and putting there the required libraries. 解决方案似乎是在JAVA_HOME / jre / lib /(或TOMCAT_HOME)中创建一个“认可”目录,并将所需的库放在其中。
However, some people say the library needed is webservices-api.jar
, for example, here (#Issue 3): 但是,有些人说所需的库是
webservices-api.jar
,例如,在这里(#问题3):
https://www.fromdev.com/2010/01/trying-to-run-jax-ws-sample-application.html https://www.fromdev.com/2010/01/trying-to-run-jax-ws-sample-application.html
And other people talk about jaxb-api-2.2.jar
and jaxws-api.jar
, for example here: 其他人在这里谈论
jaxb-api-2.2.jar
和jaxws-api.jar
:
Grizzly - java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName 灰熊-java.lang.NoSuchMethodError:javax.xml.ws.WebFault.messageName
I have downloaded all three of them and placed them in both directories (inside JAVA_HOME and TOMCAT_HOME). 我已经下载了所有三个文件,并将它们放在两个目录中(在JAVA_HOME和TOMCAT_HOME内部)。
My problems: 我的问题:
· I have no issues accessing this service from a standalone java6 application, both from Netbeans or running the .jar from command-line, it fails only from Tomcat. ·从NetBeans或从命令行运行.jar的独立Java6应用程序访问此服务都没有问题,仅从Tomcat失败。 So I am not sure if the stated above is the cause of my problems.
因此,我不确定上述问题是否是造成我问题的原因。 Because, shouldn't it also fail from command line?
因为,它也不应该在命令行中失败吗?
· I am not being able to test the above solutions, because Tomcat does not seem to know the "endorsed" directory. ·我无法测试上述解决方案,因为Tomcat似乎不知道“认可”目录。 When I run this in the standalone application:
当我在独立应用程序中运行此命令时:
System.out.println(System.getProperty("java.endorsed.dirs"));
It prints: 它打印:
/usr/lib/jvm/jdk1.6.0_45/jre/lib/endorsed
However, Tomcat prints a blank line. 但是,Tomcat打印空白行。
I have tried to modify tomcat6.conf
, with this (and restarting, of course): 我试图用此方法修改
tomcat6.conf
(当然,然后重新启动):
JAVA_OPTS=" -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed -Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory -Djava.awt.headless=true -Xms1024m -Xmx1024m -XX:PermSize=1024m -XX:MaxPermSize=1024m" JAVA_OPTS =“ -Djava.endorsed.dirs = / usr / share / tomcat6 / endorsed -Djavax.sql.DataSource.Factory = org.apache.commons.dbcp.BasicDataSourceFactory -Djava.awt.headless = true -Xms1024m -Xmx1024m -XX :PermSize = 1024m -XX:MaxPermSize = 1024m“
But it still doesn't seem to know that property. 但它似乎仍然不知道该财产。
So, how can I tell Tomcat where the endorsed directory is located? 那么,如何告诉Tomcat认可目录位于何处? Do you think that my problem can be another than the stated, as it works from a standalone application?
您是否认为我的问题可能与上述问题不同,因为它可以在独立应用程序中工作?
So, the solution: 因此,解决方案:
Do you think that my problem can be another than the stated, as it works from a standalone application?
您是否认为我的问题可能与上述问题不同,因为它可以在独立应用程序中工作?
No, that was exactly the problem. 不,那正是问题所在。
how can I tell Tomcat where the endorsed directory is located?
如何告诉Tomcat认可目录位于何处?
It seems that setting this option in tomcat6.conf: 似乎在tomcat6.conf中设置此选项:
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
is not enough. 是不足够的。 It is required to create a variable called JAVA_ENDORSED_DIRS.
需要创建一个名为JAVA_ENDORSED_DIRS的变量。 So these two lines are needed in tomcat6.conf:
因此,tomcat6.conf中需要这两行:
JAVA_ENDORSED_DIRS="/usr/share/tomcat6/endorsed"
JAVA_OPTS="-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS [-Djava....]"
Not really well documented issue, I think. 我认为这还没有很好地记录在案的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.