I am trying to deploy a war to Glassfish 3.1.1 that makes use of a CXF webservice client library and a Jersey webservice client library. In order to get Glassfish to use CXF instead of Metro as the JAX-WS implementation, I am including a glassfish-web.xml
file with the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN'
'http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd'>
<glassfish-web-app>
<!-- Need this to tell Glassfish not to load the JAX-WS RI classes so it will
use the CXF ones instead -->
<class-loader delegate="false" />
</glassfish-web-app>
This has the undesirable effect of causing problems for my Jersey client:
2011 Oct 19 15:04:16,994 MDT [http-thread-pool-80(3)] ERROR my.company.MyServlet - Error testing JerseyClient
java.lang.NoSuchMethodError: com.sun.jersey.core.spi.component.ProviderServices.<init>(Ljava/lang/Class;Lcom/sun/jersey/core/spi/component/ProviderFactory;Ljava/util/Set;Ljava/util/Set;)V
at com.sun.jersey.api.client.Client.init(Client.java:242)
at com.sun.jersey.api.client.Client.access$000(Client.java:118)
at com.sun.jersey.api.client.Client$1.f(Client.java:191)
at com.sun.jersey.api.client.Client$1.f(Client.java:187)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
at com.sun.jersey.api.client.Client.<init>(Client.java:187)
at com.sun.jersey.api.client.Client.<init>(Client.java:170)
at com.sun.jersey.api.client.Client.create(Client.java:679)
at my.company.MyJerseyClient.<init>(MyJerseyClient.java:93)
Since the Jersey libraries are included in the war (and not expected to be provided in Glassfish), I don't understand this.
If I don't include the glassfish-web.xml
file, the Jersey client works fine, but I get this error on the CXF client:
2011-10-19T15:00:53.993-0600|WARNING|glassfish3.1.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=32;_ThreadName=Thread-2;|StandardWrapperValve[my-servlet]: PWC1406: Servlet.service() for servlet my-servlet threw exception
java.lang.ClassCastException: com.sun.xml.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy
at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:93)
at my.company.MyCXFClient.<init>(MyCXFClient.java:53)
Is it possible to get these two libraries to deploy (and work) in the same war?