Use native Java SE 6 JAX-WS implementation instead of JBoss WS stack
Asked Answered
I

3

7

JBoss 6.0 Final is shipped with JBoss WS (Apache CXF stack by default), I know that I can replace the default implementation with the respective JBoss WS Native or Metro versions from JBossWS downloads site.

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).

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.

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.

So, is this feasible? Can someone point the way?

Iodize answered 13/3, 2012 at 1:27 Comment(3)
I just got the same need for my project. I am investigatingHorvitz
Be sure to post your progress, I'm quite stuck with this problem.Iodize
In fact, I get into troubles because JBossWS-CXF found Spring in my application and requires it in JBoss ClassLoader. Then my client generated from WSDL by JavaSE wsimport failed to load its classes... As I use WS as client only, I look for that same option.Horvitz
H
7

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.

  • 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/
  • Edit and remove the two following parts from 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"/>

As a result, the WebService server stack is no longer available, neither the jbossws console.

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:

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.

Horvitz answered 14/3, 2012 at 21:42 Comment(2)
It works! Thank you very much Yves, I could perform the same steps (just didn't need to remove the jbossws-console part because I couldn't find it) and was able to use native RI implementation for version 6.0.0 final.Iodize
For God's sake people: MOD THIS ANSWER UP! THANK YOU YVES!Coral
A
4

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 Martin answer):

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

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:

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:

<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:

IDEA -> Settings -> Compiler -> Java Compiler

in "Additional command line parameters" add:

-endorseddirs /<your_absolut_path_to_project>/target/endorsed/
Agitator answered 6/11, 2012 at 9:48 Comment(2)
Thank you very much for your contribution Leszek, specially the steps to configure endorsed libraries with Maven (I have struggled with the same thing).Iodize
Sorry but the question is about removing CXF from JBoss so that JAX-WS Annotation are processed by JavaSE internal/Metro stack. It is not about upgrading CXF inside JBoss...Horvitz
B
0

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.

Belanger answered 3/4, 2012 at 13:32 Comment(1)
That is true. If you do not use JBoss as WS endpoint but only as WS client, you may be interested in using JavaSE JAX-WS RI implementation... (instead of CXF which gets both roles endpoint+client when loaded)Horvitz

© 2022 - 2024 — McMap. All rights reserved.