CXF - ClassCastException (SEIStub/ClientProxy)

流过昼夜 提交于 2019-11-28 12:18:49
sdoca

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> 

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();

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.

scj

Remove JAX-WS Libraries from buildpath, so this can resolves my problem that is (ClassCastException) SEIStub to ClientProxy.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!