NullPointerException When trying to get CrmBasedUserList Id in Adwords java client version v201708

116 views
Skip to first unread message

hari krishna

unread,
Sep 18, 2017, 3:34:38 PM9/18/17
to AdWords API Forum
Hi , 

We are getting NullPointerException When trying to get CrmBasedUserList Id in Adwords java client version v201708. This is happening once in 15 requests. This issue is happening randomly. Can you please help us getting this issue solved. 

Below is the exception stack trace. 

java.lang.NullPointerException

       at java.io.StringReader.<init>(StringReader.java:50)

       at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:688)

       at org.apache.axis.SOAPPart.getEnvelope(SOAPPart.java:1003)

       at org.apache.axis.Message.getSOAPHeader(Message.java:559)

       at com.google.api.ads.common.lib.soap.ResponseInfoXPathSet.parseMessage(ResponseInfoXPathSet.java:83)

       at com.google.api.ads.common.lib.soap.axis.AxisHandler.invokeSoapCall(AxisHandler.java:249)

       at com.google.api.ads.common.lib.soap.SoapServiceClient.callSoapClient(SoapServiceClient.java:63)

       at com.google.api.ads.common.lib.soap.SoapServiceClient.invoke(SoapServiceClient.java:93)

       at com.sun.proxy.$Proxy17.mutate(Unknown Source)

       at com.aaa.adwords.services.AdwordsDataServicesImpl.uploadEmailsClientId(AdwordsDataServicesImpl.java:116)

       at com.aaa.adwords.services.AdwordsDataServicesImpl.uploadEmailsToGoogle(AdwordsDataServicesImpl.java:373)

       at com.aaa.adwords.Application.main(Application.java:71)


Below is the code we are using. 


    AdwordsUserListServiceInterface userListService =

        adWordsServices.get(session, AdwordsUserListServiceInterface.class);

 

    // Create a user list.

    CrmBasedUserList userList = new CrmBasedUserList();

    userList.setName("Customer relationship management list #" + System.currentTimeMillis());

    userList.setDescription("A list of customers that originated from email addresses");

 

    // See limit here: https://support.google.com/adwords/answer/6276125#requirements.

    userList.setMembershipLifeSpan(30L);

 

    // Create operation.

    UserListOperation operation = new UserListOperation();

    operation.setOperand(userList);

    operation.setOperator(Operator.ADD);

 

    // Add user list.

// Add user list.

                           UserListReturnValue result = null;

                           try {

                                  result = userListService.mutate(new UserListOperation[] { operation });

 

                           } catch (ApiException e) {

                                  result = handleUserListServiceApiError(userListService, operation, e, result);

 

                           } catch (Exception e) {

                                  LOGGER.error("Exception in getting userListId", e);

                           }

    // Display user list.

    UserList userListAdded = result.getValue(0);

    System.out.printf(

        "User list with name '%s' and ID %d was added.%n",

        userListAdded.getName(), userListAdded.getId());

 

    // Get user list ID.

    Long userListId = userListAdded.getId();


Thanks!

Hari.


Peter Oliquino

unread,
Sep 18, 2017, 11:44:42 PM9/18/17
to AdWords API Forum
Hi Hari,

Could you send to me privately via the Reply privately to author option, your clientCustomerID and the generated SOAP request and response when the error was encountered?

Best regards,
Peter
AdWords API Team

hari krishna

unread,
Sep 20, 2017, 12:05:42 AM9/20/17
to AdWords API Forum
Hi Peter, 

I sent you private message.

Thanks!
Hari. 

Josh Radcliff (AdWords API Team)

unread,
Sep 20, 2017, 8:23:51 AM9/20/17
to AdWords API Forum
Hi Hari,

Could you check out the Java library's page on thread safety and confirm that you are following the guidelines outlined there? When I've seen issues like this in the past, it's been due to objects that are not thread-safe being shared among multiple threads.

Thanks,
Josh, AdWords API Team

hari krishna

unread,
Sep 20, 2017, 9:03:42 AM9/20/17
to AdWords API Forum
Hi Josh, 

We are creating standalone application using java. It will run as backgourd process and upload emails to CM.We are not using any multi-threading in this. 

I will give SOAP request and response to you for better debugging from your end. 

One thing we are doing is we are looping through the chunks of emails (Each chunk with 100000  emails ) and uploading. 

I will check once again from my end too as per the documentation you have given in Java library's page on thread safety. and update. 

Thanks!
Hari. 

hari krishna

unread,
Sep 27, 2017, 3:05:43 AM9/27/17
to AdWords API Forum
Hi Josh, 

Please find soap and java error logs for the one of the failure. 


Please help us in resolving this kind of issues. 

Thanks!
Hari. 
soap_log.txt

Josh Radcliff (AdWords API Team)

unread,
Sep 27, 2017, 2:17:00 PM9/27/17
to AdWords API Forum
Hi Hari,

I noticed that the underlying error here is:

1495223 [main] ERROR org.apache.axis.SOAPPart  - Exception:
java.lang.IllegalArgumentException: The char '0x0' after 'return code:  401
<HEAD><TITLE>Authorization Required</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black"><H1>Authorization Required</H1><HR>
<FONT FACE="Helvetica,Arial"><B>
Description: Authorization is required for access to this proxy</B></FONT>
<HR>
<!-- default "Authorization Required" response (401) -->
</BODY>

That error suggests that:

a. You are going through a proxy that requires authorization.
b. When authorization fails, your proxy server is returning the null byte (0x0) in the response. As a result, when the client library tries to parse the response, it fails.

Do you know why authorization is failing intermittently, or do you have a system admin who can help debug that issue?

Thanks,
Josh, AdWords API Team

Reply all
Reply to author
Forward
0 new messages