I am trying to launch a war with Glassfish 3.1.1, which uses the CXF web service client library and the Jersey web service client library. To force Glassfish to use CXF instead of Metro as an implementation of JAX-WS, I include the glassfish-web.xml
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> <class-loader delegate="false" /> </glassfish-web-app>
This has an undesirable effect causing problems for my client in Jersey:
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 Jersey libraries are included in the war (and are not expected to be featured in Glassfish), I do not understand this.
If I do not include the glassfish-web.xml
, 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)
Can these two libraries be used to deploy (and work) in the same war?
sdoca source share