使用原生 Java SE 6 JAX-WS 实现而不是 JBoss WS 堆栈
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9677159/
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
Use native Java SE 6 JAX-WS implementation instead of JBoss WS stack
提问by Anthony Accioly
JBoss 6.0 Final is shipped with JBoss WS(Apache CXFstack by default), I know that I can replace the default implementation with the respective JBoss WS Native or Metro versions from JBossWS downloads site.
JBoss 6.0 Final 随JBoss WS(默认为Apache CXF堆栈)一起提供,我知道我可以用JBossWS 下载站点上的相应 JBoss WS Native 或 Metro 版本替换默认实现。
The problem is, I've a client jar library (binaries only unfortunately) which consumes some proprietary SOAP Web Services. When I use the client API from a Web Application deployed to JBoss I'm getting a lot of intermittent SOAP Faults (tested with both Apache CXF and JBoss Native stacks).
问题是,我有一个使用一些专有 SOAP Web 服务的客户端 jar 库(不幸的是只有二进制文件)。当我从部署到 JBoss 的 Web 应用程序使用客户端 API 时,我遇到了很多间歇性 SOAP 错误(使用 Apache CXF 和 JBoss Native 堆栈进行测试)。
Since the same Web Services seems to work fine when running from a standalone jar file (with no third party JAX-WS implementations), I was thinking about disabling the JBoss WS stack in favor of the native JAX-WS RI stack provided with Java SE 6.
由于从独立的 jar 文件(没有第三方 JAX-WS 实现)运行时,相同的 Web 服务似乎工作正常,我正在考虑禁用 JBoss WS 堆栈以支持 Java SE 提供的本机 JAX-WS RI 堆栈6.
I know that JBoss Metro WS stack should be close enough to what is shipped with Java SE 6, but I would really appreciate if I could go with the native Java SE version.
我知道 JBoss Metro WS 堆栈应该足够接近 Java SE 6 附带的堆栈,但如果我能使用原生 Java SE 版本,我将不胜感激。
So, is this feasible? Can someone point the way?
那么,这可行吗?有人可以指路吗?
采纳答案by Yves Martin
Here is a procedure to remove JBossWS-CXF client and server stack from JBoss 6.1.0.Final.
Replace <configuration>
by the server configuration you use, probably default
.
这是从 JBoss 6.1.0.Final 中删除 JBossWS-CXF 客户端和服务器堆栈的过程。替换<configuration>
为您使用的服务器配置,可能是default
.
- Remove the following files and directory structure
- 删除以下文件和目录结构
common/deploy/jbossws-console.war lib/endorsed/jbossws-cxf-factories.jar server/<configuration>/deploy/jbossws-console-activator-jboss-beans.xml server/<configuration>/deployers/jbossws.deployer/ server/<configuration>/deployers/jbossws-jaxrpc.deployer/
common/deploy/jbossws-console.war lib/endorsed/jbossws-cxf-factories.jar server/<configuration>/deploy/jbossws-console-activator-jboss-beans.xml server/<configuration>/deployers/jbossws.deployer/ server/<configuration>/deployers/jbossws-jaxrpc.deployer/
- Edit and remove the two following parts from
server/<configuration>/deployers/switchboard-jboss-beans.xml
- 编辑并删除以下两个部分
server/<configuration>/deployers/switchboard-jboss-beans.xml
<entry> <key>javax.xml.ws.WebServiceContext</key> <value><inject bean="org.jboss.switchboard.WebServiceContextResourceProvider"/></value> </entry> ... and ... <inject bean="org.jboss.switchboard.WebServiceRefResourceProvider"/>
<entry> <key>javax.xml.ws.WebServiceContext</key> <value><inject bean="org.jboss.switchboard.WebServiceContextResourceProvider"/></value> </entry> ... and ... <inject bean="org.jboss.switchboard.WebServiceRefResourceProvider"/>
As a result, the WebService server stack is no longer available, neither the jbossws console.
结果,WebService 服务器堆栈不再可用,jbossws 控制台也不再可用。
To be sure to use JAX-WS Metro implementation from your JavaSE version running JBoss, you have also to remove from Class-Path any jar related to CXF and JAX-WS:
为了确保在运行 JBoss 的 JavaSE 版本中使用 JAX-WS Metro 实现,您还必须从 Class-Path 中删除与 CXF 和 JAX-WS 相关的任何 jar:
lib/endorsed/jboss-jaxws-api_2.2_spec.jar lib/endorsed/stax-api.jar lib/endorsed/jboss-jaxb-api_2.2_spec.jar common/lib/jboss-jaxb-api_2.2_spec.jar common/lib/jboss-jaxws-api_2.2_spec.jar common/lib/jboss-jaxrpc-api_1.1_spec.jar common/lib/cxf-*.jar lib/wstx-lgpl.jar lib/jaxb-impl.jar lib/jaxb-xjc.jar
lib/endorsed/jboss-jaxws-api_2.2_spec.jar lib/endorsed/stax-api.jar lib/endorsed/jboss-jaxb-api_2.2_spec.jar common/lib/jboss-jaxb-api_2.2_spec.jar common/lib/jboss-jaxws-api_2.2_spec.jar common/lib/jboss-jaxrpc-api_1.1_spec.jar common/lib/cxf-*.jar lib/wstx-lgpl.jar lib/jaxb-impl.jar lib/jaxb-xjc.jar
At that point, JBoss 6.1 even starts faster.
在这一点上,JBoss 6.1 甚至启动得更快。
回答by Alessio Soldano
Just for the sake of fully understanding what being done above, at the end of the process you have an application server without any WS server side functionality besides the programmatic endpoint API usage (Endpoint.publish(..)), which would not start the ws endpoint on the JBoss AS anyway. No JSR109 support at all, no EJB3 WS endpoint functionality, etc.
只是为了完全理解上面所做的事情,在流程结束时,您有一个应用程序服务器,除了编程端点 API 使用 (Endpoint.publish(..)) 之外,没有任何 WS 服务器端功能,它不会启动无论如何,JBoss AS 上的 ws 端点。根本没有 JSR109 支持,没有 EJB3 WS 端点功能等。
回答by Leszek Grucha?a
For further researchers, I wanted to share my additional steps on how to remove all old JAXB and CXF from JBoss 6.1 and add new versions of them (it's enhanced Yves Martinanswer):
对于进一步的研究人员,我想分享关于如何从 JBoss 6.1 中删除所有旧的 JAXB 和 CXF 并添加它们的新版本的附加步骤(这是增强的Yves Martin回答):
To be removed:
即将被删除:
common/deploy/jbossws-console.war
server/<configuration>/deploy/jbossws-console-activator-jboss-beans.xml
server/<configuration>/deployers/jbossws.deployer/
server/<configuration>/deployers/jbossws-jaxrpc.deployer/
client/cxf-*.jar
client/jaxws-*.jar
client/jaxb-impl.jar
client/jaxb-xjc.jar
client/wstx-lgpl.jar
client/jbossws-*.jar
client/stax-api.jar
client/activation.jar
lib/wstx-lgpl.jar
lib/jaxb-impl.jar
lib/jaxb-xjc.jar
common/lib/jboss-jaxb-api_2.2_spec.jar
common/lib/jboss-jaxws-api_2.2_spec.jar
common/lib/jboss-jaxrpc-api_1.1_spec.jar
common/lib/cxf-*.jar
common/lib/jaxws-*.jar
common/lib/jbossws-*.jar (except common/lib/jbossws-spi.jar)
lib/endorsed/activation.jar
lib/endorsed/jboss-jaxb-api_2.2_spec.jar
lib/endorsed/jbossws-cxf-factories.jar
lib/endorsed/jboss-jaxws-api_2.2_spec.jar
lib/endorsed/stax-api.jar
From the configuration file at: server//deployers/switchboard-jboss-beans.xml
来自配置文件:server//deployers/switchboard-jboss-beans.xml
remove following lines:
删除以下几行:
<entry>
<key>javax.xml.ws.WebServiceContext</key>
<value><inject bean="org.jboss.switchboard.WebServiceContextResourceProvider"/></value>
</entry>
<inject bean="org.jboss.switchboard.WebServiceRefResourceProvider"/>
If you want to upgrade JAXB + CXF to 2.6.3, add these libraries:
如果要将 JAXB + CXF 升级到 2.6.3,请添加以下库:
lib/jaxb-xjc-2.1.13.jar
lib/endorsed/activation-1.1.1.jar
lib/endorsed/jaxb-api-2.2.6.jar
lib/endorsed/jaxws-api-2.2.6.jar
lib/endorsed/stax2-api-3.1.1.jar
lib/endorsed/saaj-api-1.3.4.jar
lib/endorsed/cxf-api-2.6.3.jar
common/lib/cxf-api-2.6.3.jar
If you have Java 6 project, new JAXB will infer with this one from JRE, so we have to endorse the new version. Here's how to do it for maven:
如果你有 Java 6 项目,新的 JAXB 会从 JRE 推断出这个,所以我们必须认可新版本。下面是如何为 maven 做到这一点:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<maxmem>512m</maxmem>
<compilerArguments>
<endorseddirs>${project.build.directory}/endorsed</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Djava.endorsed.dirs=${project.build.directory}/endorsed</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jax.version}</version>
</artifactItem>
<artifactItem>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>${jax.version}</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/endorsed</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<configuration>
<fork>once</fork>
<additionalJvmArgs>-Djava.endorsed.dirs=${project.build.directory}/endorsed</additionalJvmArgs>
<!-- rest of the normal codegen configuration options -->
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jax.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${jax.version}</version>
</dependency>
</dependencies>
</plugin>
On your IDE you have to tell it to compile using new JAXB libraries. In case of IDEA you can do it here:
在您的 IDE 上,您必须告诉它使用新的 JAXB 库进行编译。如果是 IDEA,您可以在这里进行:
IDEA -> Settings -> Compiler -> Java Compiler
in "Additional command line parameters" add:
-endorseddirs /<your_absolut_path_to_project>/target/endorsed/