'Fuel SDK ETClient causing Exception in thread "main" java.lang.NullPointerException
I know this is caused by a null value, however I'm fairly new to java and not sure why it's null. Have I not instantiated ETClient correctly? Or overlooked something else? I'm using the Salesforce Marketingcloud Java SDK in a class like so:
package exacttarget.api;
import com.exacttarget.fuelsdk.*;
public class MyClass {
public static void main(String[] args) {
try {
// specifiy client ID and secret
ETConfiguration configuration = new ETConfiguration();
configuration.set("clientId", "abc123");
configuration.set("clientSecret", "xyz");
// instantiate ETClient object
ETClient client = new ETClient(configuration);
ETFilter myFilter = new ETFilter();
ETResponse response = client.retrieve(ETSubscriber.class, myFilter);
System.out.println(response);
}
catch (ETSdkException e) {
e.printStackTrace();
}
}
}
It compiles (using Gradle), however when I run the jar I get the following error:
log4j:WARN No appenders could be found for logger (com.exacttarget.fuelsdk.ETClient).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.NullPointerException
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(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.<init>(ServiceImpl.java:129)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
at javax.xml.ws.Service.<init>(Service.java:77)
at com.exacttarget.fuelsdk.internal.PartnerAPI.<init>(PartnerAPI.java:49)
at com.exacttarget.fuelsdk.ETSoapConnection.<init>(ETSoapConnection.java:88)
at com.exacttarget.fuelsdk.ETSoapConnection.<init>(ETSoapConnection.java:178)
at com.exacttarget.fuelsdk.ETClient.<init>(ETClient.java:158)
at exacttarget.api.MyClass.main(MyClass.java:15)
Thanks in advance for any help or suggestions.
Solution 1:[1]
gralde: com.github.salesforce-marketingcloud:fuelsdk:1.6.0
ETResponse<ETDataExtensionRow> dataRows = null;
ETConfiguration configuration = new ETConfiguration();
configuration.set("authEndpoint","XXX");
configuration.set("clientId","ABC");
configuration.set("clientSecret","Xyz");
configuration.set("useOAuth2Authentication","true");
configuration.set("soapEndpoint","Soapendpoint");
configuration.set("endpoint","Endpoint");
ETClient client=new ETClient(configuration);
ETSoapConnection soapConnection=new ETSoapConnection(client,"soapEndPoint");
ETFilter etf=new ETFilter();
ETExpression expression=new ETExpression();
expression.setProperty("name");
expression.setOperator("=");
expression.setValue(DataExtensionName);
etf.setExpression(expression);
ETResponse<ETDataExtension> response=client.retrieve(ETDataExtension.class,etf);
dataRows=response.getObject().select();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | techDoubts23 |