I\'m trying to build a client jar file to access a webservice. I\'m including the jar in a servlet/war that makes the client webservice calls. I\'m getting the following e
Remove JAX-WS Libraries from buildpath, so this can resolves my problem that is (ClassCastException
) SEIStub to ClientProxy.
This error also happened while migrating to sbt 1.3.6 with OpenJdk 11.
But acually I was using:
"com.sun.xml.ws" % "jaxws-ri" % "xxx"
and replacing with apache's jaxws fixes the error:
"org.apache.cxf" % "cxf-rt-frontend-jaxrs" % "3.3.0"
If all else fails, you can use reflection to override the delegate of the service.
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();
The solution was to include a sun-web.xml (or glassfish-web.xml) file in the war WEB-INF. See How to pick CXF over Metro on Glassfish
EDIT
Contents 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>
I just had this issue while upgrading our application to Java 11. In the end it turned out that we had some weired dependency setup and two "conflicting" libs:
cxf-rt-frontend-simple vs. cxf-rt-frontend-jaxws
So I removed all the simple dependencies and replaced them with jaxws and now all is fine ->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
Credits to this blog post -> http://www.littlebigextra.com/exception-how-to-resolve-com-sun-xml-internal-ws-client-sei-seistub-cannot-be-cast-to-org-apache-cxf-frontend-clientproxy/
For further reading I recommend this thread on Java >8 migrations: Replacements for deprecated JPMS modules with Java EE APIs
I tried CXF in the past and came across strange exceptions like this one. I assume you already tried CXF mailing list.
I would try to go slow: start with a working example from the CFX distribution and make one change at a time until you get to the problem.