salesforce-marketingcloud / FuelSDK-Java

Salesforce Marketing Cloud Java SDK
BSD 3-Clause "New" or "Revised" License
72 stars 123 forks source link

[BUG] FuelSdk is not compatible with Java 11 #117

Closed pc-dhutton closed 3 years ago

pc-dhutton commented 4 years ago

Describe the bug When upgrading the project SDK to Java 11 FuekSdk 1.5.0 does not work. It gives the below error.

java.lang.NoClassDefFoundError: javax/jws/WebService at org.apache.cxf.jaxws.support.JaxWsImplementorInfo.initialize(JaxWsImplementorInfo.java:273) at org.apache.cxf.jaxws.support.JaxWsImplementorInfo.(JaxWsImplementorInfo.java:60) at org.apache.cxf.jaxws.JaxWsClientFactoryBean.setServiceClass(JaxWsClientFactoryBean.java:43) at org.apache.cxf.frontend.ClientProxyFactoryBean.setServiceClass(ClientProxyFactoryBean.java:224) at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:445) at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:359) at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:350) at javax.xml.ws.Service.getPort(Service.java:169) at com.exacttarget.fuelsdk.internal.PartnerAPI.getSoap(PartnerAPI.java:63) at com.exacttarget.fuelsdk.ETSoapConnection.(ETSoapConnection.java:102) at com.exacttarget.fuelsdk.ETSoapConnection.(ETSoapConnection.java:210) at com.exacttarget.fuelsdk.ETClient.buildClients(ETClient.java:219) at com.exacttarget.fuelsdk.ETClient.(ETClient.java:197)

To Reproduce

Expected behavior new EtClient(config) should initialize with the log message below

2020-05-20 16:05:06 INFO  ReflectionServiceFactoryBean:388 - Creating Service {http://exacttarget.com/wsdl/partnerAPI}PartnerAPI from WSDL: jar:file:/Users/userName/.m2/repository/com/github/salesforce-marketingcloud/fuelsdk/1.5.0/fuelsdk-1.5.0.jar!/etframework.wsdl

Screenshots image

Code snippet

        ETConfiguration config = new ETConfiguration();
        config.set("clientId", clientId);
        config.set("clientSecret", clientSecret);
        config.set("authEndpoint", authEndpoint);
        config.set("endpoint", endpoint);
        config.set("soapEndpoint", soapEndpoint);
        config.set("useOAuth2Authentication", useOAuth2Authentication);
        config.set("applicationType", applicationType);
        fuelSdkEtclient = new ETClient(config);

Environment

The bug has the severity

Additional context This solution does not work https://stackoverflow.com/questions/53727322/migration-from-jdk-8-to-jdk-11-cxf-generated-sources-unknown-imports

lawrence-leung-mox commented 4 years ago

A coworker ran into the same issue just because he was on jdk11. Basically the javax.* that’s missing has been removed since java 9.

You could try importing separate dependency suggested here https://stackoverflow.com/a/54518582

Or we ended up reverting to java 8 and in the end skipping the use of this sdk all together.

Good luck

pc-dhutton commented 4 years ago

@lawrence-leung-mox Thank you for the reply. I tried adding the below library as stack overflow suggested and got a new error. I looked into that one for a bit and haven't found a clear solution.

<dependency>  
   <groupId>com.sun.xml.ws</groupId>  
   <artifactId>jaxws-ri</artifactId>
   <version>2.3.0</version>  
   <type>pom</type>
</dependency>

Error Message

java.lang.ClassCastException: class com.sun.xml.ws.client.sei.SEIStub cannot be cast to class org.apache.cxf.frontend.ClientProxy (com.sun.xml.ws.client.sei.SEIStub and org.apache.cxf.frontend.ClientProxy are in unnamed module of loader 'app') at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:128) 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) at com.exacttarget.fuelsdk.ETClient.(ETClient.java:197)

lawrence-leung-mox commented 4 years ago

@pc-dhutton trying to get it working with java 11 will probably take more time than considering falling back to using a HTTP Client and connecting to SFMC thru REST API, or perhaps even downgrading your whole project to java 8. I know they are not ideal but are viable alternatives.

pc-dhutton commented 4 years ago

@lawrence-leung-mox same I agree. I'll leave the ticket open and maybe Salesforce Marketing Cloud will do something about it. Leaning towards a separate microservice that runs Java 8 while the rest of the stack runs Java 11

waldou commented 3 years ago

Works on Java 11 using this dependencies:

implementation 'com.github.salesforce-marketingcloud:fuelsdk:1.5.0'
implementation 'jakarta.xml.ws:jakarta.xml.ws-api:2.3.3'
implementation 'com.sun.xml.messaging.saaj:saaj-impl:1.5.1'
pgiedrojc commented 3 years ago

For me it worked on Java 11 with those dependencies. Funny part that if you put higher versions it simply won't work

javax.xml.bind jaxb-api 2.3.0 com.sun.xml.bind jaxb-core 2.3.0 com.sun.xml.bind jaxb-impl 2.3.0 com.sun.xml.messaging.saaj saaj-impl 1.5.0 javax.xml.ws jaxws-api 2.2.6
    <dependency>
        <groupId>com.github.salesforce-marketingcloud</groupId>
        <artifactId>fuelsdk</artifactId>
        <version>1.5.0</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-osgi</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Hope it helps

pc-dhutton commented 3 years ago

Ok sweet! Thank you for the update. I'll try that within the next few days and report back

red-avtovo commented 3 years ago

@pc-dhutton you can take a look on my PR. It successfully runs on Java 11 now

red-avtovo commented 3 years ago

Hey everyone! Since #125 is merged this ticket is finally resolved. Thx to some external force which help us to move things forward. Congrats everyone for being able to finally use the library on Java 11 The new version 1.5.1 was also published 🎉

pc-dhutton commented 3 years ago

Confirmed that @red-avtovo fix has worked in 1.5.1! Thank you very much sir. Also, I found that our monolithic app was using older versions of saaj and the required SOAP dependencies for Fuel to work. These older dependencies created conflicts with Fuel which made it incompatible with the mono. So I separated Fuel 1.5.1 out into its own spring boot microservice running java 11 and it works perfectly now.