CXF - ClassCastException (SEIStub / ClientProxy)

I am trying to create a client jar file to access a web service. I include a jar in a servlet / war that makes client web services call. I get the following error:

INFO: 2011 Apr 14 14:57:32,780 MDT [http-thread-pool-8181(4)] ERROR my.package.ClientServlet - Caught 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.package.Client.<init>(Client.java:54) at my.package.ClientServlet.testService(TestServlet.java:118) 

I came across this post http://yaytay.wordpress.com/2010/03/06/lsned-29-persuading-jdk-6-to-use-cxf-classes-rather-than-its-own-avoiding-seistub / , which says that to fix the problem you need to include cxf-rt-frontend-jaxws as the dependency that I am doing. So this is not the problem / solution in my case.

My jar pom client has these dependencies:

 <properties> <cxf.version>2.3.3</cxf.version> </properties> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-ws-security</artifactId> <version>${cxf.version}</version> </dependency> </dependencies> 

The servlet war contains the following in its lib:

 asm-3.3.jar bcprov-jdk15-1.45.jar commons-logging-1.1.1.jar cxf-api-2.3.3.jar cxf-common-schemas-2.3.3.jar cxf-common-utilities-2.3.3.jar cxf-rt-bindings-soap-2.3.3.jar cxf-rt-bindings-xml-2.3.3.jar cxf-rt-core-2.3.3.jar cxf-rt-databinding-jaxb-2.3.3.jar cxf-rt-frontend-jaxws-2.3.3.jar cxf-rt-frontend-simple-2.3.3.jar cxf-rt-ws-addr-2.3.3.jar cxf-rt-ws-security-2.3.3.jar cxf-tools-common-2.3.3.jar geronimo-javamail_1.4_spec-1.7.1.jar jaxb-impl-2.1.13.jar log4j-1.2.14.jar neethi-2.0.4.jar my-client-cxf-1.0.jar serializer-2.7.1.jar slf4j-api-1.4.2.jar slf4j-log4j12-1.4.2.jar stax2-api-3.0.2.jar woodstox-core-asl-4.0.8.jar wsdl4j-1.6.2.jar wss4j-1.5.11.jar xalan-2.7.1.jar xml-resolver-1.2.jar XmlSchema-1.4.7.jar xmlsec-1.4.4.jar 

I also read a few posts that talk about the javax.xml.ws.spi.Provider file, but could not find links that describe in detail what needs to be called, contain and place.

Can someone point me in the right direction?

+6
java cxf classcastexception
Apr 14 2018-11-21T00:
source share
4 answers

The solution was to include the sun-web.xml file (or glassfish-web.xml) in the WEB-INF war. See How to Choose CXF over Metro on Glassfish

EDIT

The content of glassfish-web.xml:

 <?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> 
+7
Dec 07 2018-11-11T00:
source share

If all else fails, you can use reflection to override the service delegate.

  QName qName = new QName(wsTargetNamespace, wsName); service = new YourServiceScheduler(loc, qName); Field delegateField = Service.class.getDeclaredField("delegate"); delegateField.setAccessible(true); ServiceDelegate previousDelegate = (ServiceDelegate)delegateField.get(service); if(!previousDelegate.getClass().getName().contains("cxf")) { ServiceDelegate serviceDelegate = ((Provider) Class.forName("org.apache.cxf.jaxws.spi.ProviderImpl").newInstance()) .createServiceDelegate(loc, qName, service.getClass()); log.info("The " + getClass().getSimpleName() + " delegate is changed from " + "[" + previousDelegate + "] to [" + serviceDelegate + "]"); delegateField.set(service, serviceDelegate); } port = service.getYourServiceSoap(); 
+2
Aug 08 '15 at 10:39 on
source share

I tried CXF in the past and came across strange exceptions like this one. I assume you have already tried the CXF mailing list .

I would try to go slower: start with a working example from the CFX distribution and make one change at a time until you run into a problem.

+1
Apr 15 2018-11-11T00:
source share

Remove the JAX-WS libraries from the build path, so this may solve my problem, which is ( ClassCastException ) SEIStub to ClientProxy.

+1
Sep 19 '14 at 2:27
source share



All Articles