0

Im having a problem on how can i get the string of array it gives me this error:

Request processing failed; nested exception is java.lang.NullPointerException

Error Detail:

java.lang.NullPointerException
com.max.common.CampaignSyncEntity.getSyncAdKeywords(CampaignSyncEntity.java:249)
com.max.adwords.testsync.AWSyncTest.runSyncTest(AWSyncTest.java:21)
com.max.web.controller.CampaignSync.uploadMultipleFileHandler(CampaignSync.java:25)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

It seems that when getting an Null array of string this error occur.

This is the code on getting the null array:

public class AWSyncTest {
static CampaignSyncEntity syncEntity = new CampaignSyncEntity();
public void runSyncTest() {

    System.out.println("CAMPAIGN NAME: "+syncEntity.getSyncCampaignName());
    System.out.println("CAMPAIGN ID: "+syncEntity.getSyncCampaignId());
    System.out.println("AD GROUP NAME: "+syncEntity.getSyncAdGroupName());
    System.out.println("AD GROUP ID: "+syncEntity.getSyncAdGroupId());
    System.out.println("AD STATUS: "+syncEntity.getSyncAdStatus());
    System.out.println("TEXT AD TYPE: "+syncEntity.getSyncTextAdType());
    System.out.println("TEXT HEADLINE: "+syncEntity.getSyncTextHeadline());
    System.out.println("TEXT DESCRIPTION 1: "+syncEntity.getSyncTextDesc1());
    System.out.println("TEXT DESCRIPTION 2: "+syncEntity.getSyncTextDesc2());
    System.out.println("TEXT DISPLAY URL: "+syncEntity.getSyncTextDisplayURL());
    System.out.println("TEXT FINAL URL: "+syncEntity.getSyncTextFinalURL());
    System.out.println("KEYWORDS: "+Arrays.toString(syncEntity.getSyncAdKeywords()));
    System.out.println("NEGATIVE KEYWORD: "+syncEntity.getSyncAdNegativeKeywords());
    System.out.println("MATCH TYPE: "+syncEntity.getSyncAdMatchType());
    System.out.println("AD CRITERIA TYPE: "+syncEntity.getSyncAdCriteriaType());
    System.out.println("LOCATION: "+syncEntity.getSyncLocation());
    System.out.println("LOCATION ID: "+syncEntity.getSyncLocationId());

}

}

Hope you guys can help me about my problem, thanks in advance

John Geliberte
  • 1,015
  • 1
  • 11
  • 19

2 Answers2

0

can you please check this line...

System.out.println("KEYWORDS: "+Arrays.toString(syncEntity.getSyncAdKeywords()));

I mean what is returned by syncEntity.getSyncAdKeywords().

If its returning null problem is lying there..

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
Mr. Noddy
  • 1,530
  • 2
  • 16
  • 45
0

The error means that your code is trying to do something with a member/variable that hasn't been initialized - it's null. As you can see in the backtrace, the error occurs in CampaignSyncEntity.java:249.

When you jump to the line, most probably you will see some kind of action on a member/variable (i.e. something trying to access a member of the unitialized object) and when you go to CampaignSyncEntity() constructor's definition (which you used in the example code), the member that eventually is used in CampaignSyncEntity.java:249 won't have anything assigned as well as in the place where the member is declared. If there is a variable used in CampaignSyncEntity.java:249, you should check where it is declared and what happens with it during the program flow. Probably it is returned by some function which can alse return a Null and that is in this case.


In such situations it is really helpful to use Java Debugger. Most IDEs have built-in debug GUI which makes it nice and smooth to use. Here's an example for Eclipse: http://www.vogella.com/tutorials/EclipseDebugging/article.html . Especially look at Watchpoint feature - it allows you to track a field access/modification.

psliwa
  • 1,094
  • 5
  • 9