Null Pointer exception

Discussion in 'Java' started by nobody, May 13, 2005.

  1. nobody

    nobody Guest

    Hi, when I run the following code I get
    "Exceptionjava.lang.NullPointe­rException"


    Any idea what I did wrong?
    Also, I'm using WSDL file to access the web service, not external
    library. I'm using Eclipse environment to develop web service client.
    <code>


    public static void main(String[] args) {
    System.out.println( "hello" );


    GoogleSearchService service = new GoogleSearchServiceLocator();


    try
    {
    GoogleSearchPort google = service.getGoogleSearchPort();


    String key = "my key....";
    String search = "Exchange rate";


    GoogleSearchResult result = new GoogleSearchResult();
    result =
    google.doGoogleSearch(key,sear­ch,
    0, 10, true, "countryEN", false, "lang_en", "UTF-8",
    "UTF-8");


    System.out.println("Did you mean: " + result);
    }
    catch ( Exception e )
    {
    System.out.println("Exception" + e );
    }
    }


    </code>
     
    nobody, May 13, 2005
    #1
    1. Advertising

  2. nobody wrote:

    > Hi, when I run the following code I get
    > "Exceptionjava.lang.NullPointe­rException"
    >
    >
    > Any idea what I did wrong?


    Absolutely. You attempted to dereference a null reference.

    The line numbers in the stack trace will identify the exact source file
    and line on which the dereference attempt occurred (if the class
    contains debug info). My first guess, however, would be that
    service.getGoogleSearchPort() is returning null.

    > Also, I'm using WSDL file to access the web service, not external
    > library. I'm using Eclipse environment to develop web service client.
    > <code>
    >
    >
    > public static void main(String[] args) {
    > System.out.println( "hello" );
    >
    >
    > GoogleSearchService service = new GoogleSearchServiceLocator();
    >
    >
    > try
    > {
    > GoogleSearchPort google = service.getGoogleSearchPort();
    >
    >
    > String key = "my key....";
    > String search = "Exchange rate";
    >
    >
    > GoogleSearchResult result = new GoogleSearchResult();
    > result =
    > google.doGoogleSearch(key,sear­ch,
    > 0, 10, true, "countryEN", false, "lang_en", "UTF-8",
    > "UTF-8");
    >
    >
    > System.out.println("Did you mean: " + result);
    > }
    > catch ( Exception e )
    > {
    > System.out.println("Exception" + e );
    > }
    > }
    >
    >
    > </code>


    --
    John Bollinger
     
    John C. Bollinger, May 13, 2005
    #2
    1. Advertising

  3. nobody

    nobody Guest

    But for me, getGoogleSearchPort doesn't take a parameter... and I'm
    getting the following error

    It occurs at GoogleSearchResult result = new GoogleSearchResult();
    result =
    google.doGoogleSearch(key,"Tim Kuo",
    0, 10, true, "countryEN", false, "lang_en", "UTF-8",
    "UTF-8");


    and I have no clue why it happens. Seems like there is nothing wrong
    with my code...

    AxisFault
    faultCode:
    {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.lang.NullPointerException
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:
    java.lang.NullPointerException
    at java.util.Hashtable.put(Unknown Source)
    at
    com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setProperty(Unknown
    Source)
    at
    org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:246)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2545)
    at org.apache.axis.client.Call.invoke(Call.java:2515)
    at org.apache.axis.client.Call.invoke(Call.java:2210)
    at org.apache.axis.client.Call.invoke(Call.java:2133)
    at org.apache.axis.client.Call.invoke(Call.java:1656)
    at
    GoogleSearch.GoogleSearchBindingStub.doGoogleSearch(GoogleSearchBindingStub.java:251)
    at GoogleSearch.goog_client.main(goog_client.java:33)


    java.lang.NullPointerException
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
    at org.apache.axis.client.Call.invoke(Call.java:2213)
    at org.apache.axis.client.Call.invoke(Call.java:2133)
    at org.apache.axis.client.Call.invoke(Call.java:1656)
    at
    GoogleSearch.GoogleSearchBindingStub.doGoogleSearch(GoogleSearchBindingStub.java:251)
    at GoogleSearch.goog_client.main(goog_client.java:33)
    Caused by: java.lang.NullPointerException
    at java.util.Hashtable.put(Unknown Source)
    at
    com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setProperty(Unknown
    Source)
    at
    org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:246)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2545)
    at org.apache.axis.client.Call.invoke(Call.java:2515)
    at org.apache.axis.client.Call.invoke(Call.java:2210)
    ... 4 more
     
    nobody, May 16, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    26,907
    Mike Schilling
    Mar 29, 2006
  2. Ken
    Replies:
    69
    Views:
    12,584
    Michael D. Borghardt
    Jul 31, 2004
  3. Ken
    Replies:
    5
    Views:
    2,553
    Victor Bazarov
    Jul 24, 2004
  4. aneuryzma
    Replies:
    3
    Views:
    742
    Jim Langston
    Jun 16, 2008
  5. Christopher
    Replies:
    4
    Views:
    454
    Ruben Safir
    Jul 9, 2011
Loading...

Share This Page