4

We have exported as Runnable JAR (Extract required libriries into generated JAR option) our proyect (which has dependecies the fuelsdk and axis).

So, there are some classes which read properties from resource path.

Example:

ETConfiguration

file = "/fuelsdk.properties";
InputStream is = getClass().getResourceAsStream(file);
if (is == null) {
       throw new ETSdkException("error opening " + file);
}

PartnerAPI

public class PartnerAPI extends Service {

    public final static URL WSDL_LOCATION;

    public final static QName SERVICE = new QName("http://exacttarget.com/wsdl/partnerAPI", "PartnerAPI");
    public final static QName Soap = new QName("http://exacttarget.com/wsdl/partnerAPI", "Soap");
    static {
        URL url = PartnerAPI.class.getClassLoader().getResource("/etframework.wsdl");
        if (url == null) {
            url = PartnerAPI.class.getClassLoader().getResource("etframework.wsdl");
        }
        if (url == null) {
            java.util.logging.Logger.getLogger(PartnerAPI.class.getName())
                .log(java.util.logging.Level.INFO, 
                     "Can not initialize the default wsdl from {0}", "classpath:/etframework.wsdl");
        }       
        WSDL_LOCATION = url;   
    }
...
}

We have found how to override Classloader for ETConfiguration by adding these sentenses:

ClassLoader classLoader = ETConfiguration.class.getClassLoader();
Class aClass = classLoader.loadClass("com.foo.bar");

but, this solution is not working for PartnerAPI.

What can we do?

UPDATED

This issue is solved by creating src/main/resources folder and inserting all property files. ClassLoader is not necessary any more.

But now, we are getting soap service error (probably Fuel SDK bug) when calling

ETClient client = new ETClient();

Here is the error code:

2014-06-23T16:17:55.509+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: GET https://www.exacttargetapis.com/platform/v1/endpoints/soap 
2014-06-23T16:17:55.740+0200 main com.exacttarget.fuelsdk.ETClient DEBUG: requesting new access token... 
2014-06-23T16:17:55.761+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: POST https://auth.exacttargetapis.com/v1/requestToken 
2014-06-23T16:17:55.762+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: Content-Type: application/json 
2014-06-23T16:17:55.770+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: { 
2014-06-23T16:17:55.770+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "clientId": "XXX", 
2014-06-23T16:17:55.771+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "clientSecret": "YYY", 
2014-06-23T16:17:55.771+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "accessType": "offline" 
2014-06-23T16:17:55.771+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: } 
2014-06-23T16:17:59.214+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: 200 OK 
2014-06-23T16:17:59.218+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: { 
2014-06-23T16:17:59.218+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "accessToken": "ZZZ", 
2014-06-23T16:17:59.219+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "expiresIn": 3554, 
2014-06-23T16:17:59.219+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "refreshToken": "ZZZZ" 
2014-06-23T16:17:59.220+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: } 
2014-06-23T16:17:59.221+0200 main com.exacttarget.fuelsdk.ETClient DEBUG: received token: 
2014-06-23T16:17:59.225+0200 main com.exacttarget.fuelsdk.ETClient DEBUG:   accessToken: ZZZ
2014-06-23T16:17:59.225+0200 main com.exacttarget.fuelsdk.ETClient DEBUG:   expiresIn: 3554 
2014-06-23T16:17:59.226+0200 main com.exacttarget.fuelsdk.ETClient DEBUG:   refreshToken: ZZZZ
2014-06-23T16:17:59.234+0200 main com.exacttarget.fuelsdk.ETClient DEBUG: new access token expires at Mon Jun 23 17:17:13 CEST 2014 
2014-06-23T16:17:59.234+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: Accept: application/json 
2014-06-23T16:18:00.150+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: 200 OK 
2014-06-23T16:18:00.152+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: { 
2014-06-23T16:18:00.152+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "type": "soap", 
2014-06-23T16:18:00.153+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "url": "https://webservice.s4.exacttarget.com/Service.asmx" 
2014-06-23T16:18:00.153+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: } 
2014-06-23T16:18:00.154+0200 main com.exacttarget.fuelsdk.ETClient DEBUG: SOAP endpoint: https://webservice.s4.exacttarget.com/Service.asmx 
23-jun-2014 16:18:04 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http://exacttarget.com/wsdl/partnerAPI}PartnerAPI from WSDL: file:/C:/workspace/prueba/bin/etframework.wsdl
Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:334)
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:319)
    at javax.xml.ws.Service.getPort(Service.java:92)
    at com.exacttarget.fuelsdk.internal.PartnerAPI.getSoap(PartnerAPI.java:60)
    at com.exacttarget.fuelsdk.ETSoapConnection.<init>(ETSoapConnection.java:74)
    at com.exacttarget.fuelsdk.ETClient.<init>(ETClient.java:134)
    at com.exacttarget.fuelsdk.ETClient.<init>(ETClient.java:69)
    at Probando.main(Probando.java:33)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
    at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:97)
    at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:156)
    at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:156)
    at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:465)
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:332)
    ... 7 more
Caused by: org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/wsdl/soap/ registered.
    at org.apache.cxf.bus.managers.BindingFactoryManagerImpl.getBindingFactory(BindingFactoryManagerImpl.java:123)
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:116)
    at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
    ... 11 more

Normally, it should print this message:

2014-06-23T16:31:45.157+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: GET https://www.exacttargetapis.com/platform/v1/endpoints/soap 
2014-06-23T16:31:45.413+0200 main com.exacttarget.fuelsdk.ETClient DEBUG: requesting new access token... 
2014-06-23T16:31:45.442+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: POST https://auth.exacttargetapis.com/v1/requestToken 
2014-06-23T16:31:45.443+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: Content-Type: application/json 
2014-06-23T16:31:45.449+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: { 
2014-06-23T16:31:45.450+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "clientId": "XXX", 
2014-06-23T16:31:45.451+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "clientSecret": "YYY", 
2014-06-23T16:31:45.451+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "accessType": "offline" 
2014-06-23T16:31:45.452+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: } 
2014-06-23T16:31:48.972+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: 200 OK 
2014-06-23T16:31:48.977+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: { 
2014-06-23T16:31:48.977+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "accessToken": "ZZZ", 
2014-06-23T16:31:48.978+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "expiresIn": 3600, 
2014-06-23T16:31:48.978+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "refreshToken": "ZZZZ" 
2014-06-23T16:31:48.979+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: } 
2014-06-23T16:31:48.980+0200 main com.exacttarget.fuelsdk.ETClient DEBUG: received token: 
2014-06-23T16:31:49.013+0200 main com.exacttarget.fuelsdk.ETClient DEBUG:   accessToken: ZZZ
2014-06-23T16:31:49.013+0200 main com.exacttarget.fuelsdk.ETClient DEBUG:   expiresIn: 3600 
2014-06-23T16:31:49.013+0200 main com.exacttarget.fuelsdk.ETClient DEBUG:   refreshToken: ZZZZ
2014-06-23T16:31:49.019+0200 main com.exacttarget.fuelsdk.ETClient DEBUG: new access token expires at Mon Jun 23 17:31:49 CEST 2014 
2014-06-23T16:31:49.019+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: Accept: application/json 
2014-06-23T16:31:49.990+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: 200 OK 
2014-06-23T16:31:49.992+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: { 
2014-06-23T16:31:49.992+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "type": "soap", 
2014-06-23T16:31:49.992+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG:   "url": "https://webservice.s4.exacttarget.com/Service.asmx" 
2014-06-23T16:31:49.993+0200 main com.exacttarget.fuelsdk.ETRestConnection DEBUG: } 
2014-06-23T16:31:49.994+0200 main com.exacttarget.fuelsdk.ETClient DEBUG: SOAP endpoint: https://webservice.s4.exacttarget.com/Service.asmx 
23-jun-2014 16:31:56 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http://exacttarget.com/wsdl/partnerAPI}PartnerAPI from WSDL: file:/C:/workspace/fuelsdk/target/classes/etframework.wsdl
2014-06-23T16:32:00.785+0200 main com.exacttarget.fuelsdk.ETSoapConnection DEBUG: updated SOAP header with new access token ZZZ

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.