FuelSDK-Java icon indicating copy to clipboard operation
FuelSDK-Java copied to clipboard

seistub cannot be cast to org.apache.cxf.frontend.clientproxy

Open cqsapient opened this issue 7 years ago • 21 comments

I am trying to use the fuelsdk in an osgi environment. I am getting this error -

java.lang.ClassCastException: com.sun.xml.internal.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy

This is because OSGi loads the system bundle before the bundle in which fuelsdk's dependency has been embedded. I have been suggested to create the client using -

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.setServiceClass(HelloWorld.class); factory.setAddress("http://localhost:9000/helloWorld"); soapClient = (Client) factory.create();

I would like to know which class should I use in factory.setServiceClass();

and

which address should I use in factory.setAddress( ) ; is it the endpoint address ? -- https://webservice.s6.exacttarget.com/Service.asmx

Help is highly appreciated Thanks

cqsapient avatar Nov 17 '16 10:11 cqsapient

@cqsapient you are correct about URl. And as for service class, I am not sure what is your requirement. But for starter let me tell you, ET_Client is the base class that is being inherited by all objects which are used for transaction. Please let me know, if that helps and do let me know your requirement for further help.

amagar088 avatar Nov 17 '16 20:11 amagar088

Thanks for your comment. For service class; I want to know what service class should I set in

factory.setServiceClass()

for the API calls(retrieve; add; update) to work properly. It is the normal client creation using JaxWsProxyFactoryBean ; I am looking for the service class which I can set here for client creation.

cqsapient avatar Nov 17 '16 22:11 cqsapient

@cqsapient, please correct me if I am wrong, but basically you want to create a client (a single one) through which you can handle all request, right ? If you intend to do the above, use ETSoapObject. Just a tweak, in the code snippet above, you need to replace "(Client)" with "(ETSoapObject)" to make it work

amagar088 avatar Nov 17 '16 22:11 amagar088

When I use ETClient as the service class;

factory.setServiceClass(ETClient.class);

I get the error -

Exception in thread "main" java.lang.IllegalArgumentException: com.exacttarget.fuelsdk.ETClient is not an interface at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:624) at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:592) at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:244) at java.lang.reflect.WeakCache.get(WeakCache.java:141) at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:455) at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:738) at org.apache.cxf.common.util.ProxyHelper.getProxyInternal(ProxyHelper.java:47) at org.apache.cxf.common.util.ProxyHelper.getProxy(ProxyHelper.java:96) at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:175) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142) at com.exacttarget.fuelsdk.ETSoapConnection.(ETSoapConnection.java:98) at com.exacttarget.fuelsdk.ETSoapConnection.(ETSoapConnection.java:153) at com.exacttarget.fuelsdk.ETClient.(ETClient.java:168) at com.exacttarget.fuelsdk.ETClient.(ETClient.java:110) at com.exacttarget.fuelsdk.ClientTesting.main(ClientTesting.java:11)

cqsapient avatar Nov 17 '16 23:11 cqsapient

Hi @amagar088 ,

When I set ETSoapObject in factory.setServiceClass(ETSoapObject.class);

I get the same error --

Exception in thread "main" java.lang.IllegalArgumentException: com.exacttarget.fuelsdk.ETSoapObject is not an interface at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:624) at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:592) at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:244) at java.lang.reflect.WeakCache.get(WeakCache.java:141) at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:455) at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:738) at org.apache.cxf.common.util.ProxyHelper.getProxyInternal(ProxyHelper.java:47) at org.apache.cxf.common.util.ProxyHelper.getProxy(ProxyHelper.java:96) at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:175) at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142) at com.exacttarget.fuelsdk.ETSoapConnection.(ETSoapConnection.java:98) at com.exacttarget.fuelsdk.ETSoapConnection.(ETSoapConnection.java:153) at com.exacttarget.fuelsdk.ETClient.(ETClient.java:168) at com.exacttarget.fuelsdk.ETClient.(ETClient.java:110) at com.exacttarget.fuelsdk.ClientTesting.main(ClientTesting.java:11)

When I use ETSoapObject in place of client;

soapClient = (ETSoapObject) factory.create();

I get compilation Error --

Type mismatch: cannot convert from ETSoapObject to Client

cqsapient avatar Nov 18 '16 01:11 cqsapient

Same. It's really annoying trying to work with this API - documentation is awful. So assuming I haven't missed something, here's what I've tried: You can look up tips from people on StackExchange who suggest: 1) use a different version, it might magically work 2) set XML options in META-INF directory, so as to stop the conflict. None of this has worked for me.

I was getting:

Exception processing SF export: null java.lang.NullPointerException at org.apache.cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:85) at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:218) at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:161) at org.apache.cxf.jaxws.ServiceImpl.(ServiceImpl.java:129) at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82) at javax.xml.ws.Service.(Service.java:77) at com.exacttarget.fuelsdk.internal.PartnerAPI.(PartnerAPI.java:49) at com.exacttarget.fuelsdk.ETSoapConnection.(ETSoapConnection.java:88) at com.exacttarget.fuelsdk.ETSoapConnection.(ETSoapConnection.java:178) at com.exacttarget.fuelsdk.ETClient.(ETClient.java:158)

So I tried: http://stackoverflow.com/questions/6364333/jax-ws-when-apache-cxf-is-installed-it-steals-default-jdk-jax-ws-implementat/

Which says to: Create a file in: /src/main/resources/META-INF/services/javax.xml.ws.spi.Provider with contents: org.apache.cxf.jaxws.spi.ProviderImpl

On building:

Exception processing SF export: com.sun.xml.internal.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy

gharperhs2 avatar Nov 18 '16 17:11 gharperhs2

I will work and provide you the working example by Tuesday.

amagar088 avatar Nov 18 '16 17:11 amagar088

Should be obvious but- A toy project with no conflicting dependencies works just fine for me. This problem is only cropping up in a multi-module project where we're using maven-shade's automatic dependency detection to create one JAR file. It seems like using Jersey / glassfish in another part of your project is one common way to cause this issue.

gharperhs2 avatar Nov 18 '16 18:11 gharperhs2

It would be great, if you can point out some cross cutting points, that I should integrate in a sample project. I can work on that and provide you with a sample project

amagar088 avatar Nov 18 '16 18:11 amagar088

I don't know enough about Maven's internals, I have another dev looking into the issue and I'll see if he can post what he has discovered.

This issue has been posted on StackOverflow, as in the example I posted, which leads to some examples. I got here by googling "SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy" it seems to be a common problem, lots of examples out there.

Several of those examples mention Jersey/glassfish, which our project uses, so I suspect that's a contributor but I'm not 100%.

I also tried telling Glassfish or Sun not to interfere as per: http://stackoverflow.com/questions/2064068/how-to-pick-cxf-over-metro-on-glassfish ...but neither of those seemed to do anything.

gharperhs2 avatar Nov 18 '16 18:11 gharperhs2

Thanks for the input, i will try to implement a project taking into consideration on all the above mentioned points.

amagar088 avatar Nov 18 '16 18:11 amagar088

I am trying to complete the project ASAP but, due to unavoidable circumstances it might get a bit delay. Will post here once done with the project.

amagar088 avatar Nov 22 '16 16:11 amagar088

Our maven guru says: "following the second answer on here I got the SF job to run without throwing a nullpointerexcetpion" http://stackoverflow.com/questions/9069138/apache-cxf-client-loads-fine-in-eclipse-but-standalone-jar-throws-nullpointerexc

"The fix was adding the 'transformer' sections for the CFX configuration files in as part of the shade plugin settings"

...however I just found that ETSubscriber doesn't implement Attributes, which my client has to have, so Fuel SDK may be unusable for me anyway.

gharperhs2 avatar Nov 22 '16 16:11 gharperhs2

Attributes are being implemented in the objects in the sdk. Same has been to be done in java.

amagar088 avatar Nov 22 '16 21:11 amagar088

This will be built in near future.

amagar088 avatar Nov 22 '16 21:11 amagar088

Can you please try this code and let me know if that works.

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    factory.setServiceClass(Soap.class);
    factory.setAddress("https://webservice.exacttarget.com/Service.asmx");
    factory.setWsdlLocation("https://webservice.exacttarget.com/etframework.wsdl");
    Soap soapClient = (Soap)factory.create();

amagar088 avatar Dec 28 '16 19:12 amagar088

Using latest release 1.1.0 I get the same error when instantiating new ETClient(etConf):

com.sun.xml.internal.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy: java.lang.ClassCastException
java.lang.ClassCastException: com.sun.xml.internal.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy
	at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:128)
	at com.exacttarget.fuelsdk.ETSoapConnection.<init>(ETSoapConnection.java:90)
	at com.exacttarget.fuelsdk.ETSoapConnection.<init>(ETSoapConnection.java:179)
	at com.exacttarget.fuelsdk.ETClient.<init>(ETClient.java:158)

mariogalic avatar Feb 16 '17 17:02 mariogalic

This solution will help, though need to migrate to cxf from jaxws. https://stackoverflow.com/questions/6364333/jax-ws-when-apache-cxf-is-installed-it-steals-default-jdk-jax-ws-implementat

ratneshjd avatar Aug 22 '17 14:08 ratneshjd

I am facing the same issue. Neither of the solution helps. Any suggestions would be appreciated ?

akshaymalik03 avatar Aug 31 '18 00:08 akshaymalik03

Using fuelsdk 1.5.0, facing the same issue. Anyone has a resolution for this? highly appreciated your help! - Thanks java.lang.ClassCastException: com.sun.xml.internal.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:127) at com.exacttarget.fuelsdk.ETSoapConnection.(ETSoapConnection.java:103) at com.exacttarget.fuelsdk.ETSoapConnection.(ETSoapConnection.java:210) at com.exacttarget.fuelsdk.ETClient.buildClients(ETClient.java:219)

Srikanth-GitHub avatar Sep 08 '21 20:09 Srikanth-GitHub

Hi, any news on this issue?

Ionut-Mihai-Vladasel avatar Sep 20 '23 13:09 Ionut-Mihai-Vladasel