Skip to Content
avatar image
Former Member

Null Pointer Exception

Hi Experts,

I have to display a smart form from R/3 to portal. I have developed a web dynpro java application to do that where a RFC adaptive model is calling the bapi that will display the smart form. The problem I am facing is that when I am deploying the application it is showing java.lang.NullPointerException error. Please guide me.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    May 26, 2014 at 10:52 AM

    Hi all,

    thanks for your response.

    here in the application on web dynpro java, i need to display a smart form from R/3 as there login id as the input parameter in the RFC FM. below is my code:

    public void wdDoInit()

    {

    //@@begin wdDoInit()

    Zfm_Empform_Portal_Input input = new Zfm_Empform_Portal_Input();

    Zfm_Empform_Portal_Input inputuser = new Zfm_Empform_Portal_Input();

    wdContext.nodeZfm_Empform_Portal_Input().bind(inputuser);

    wdContext.currentContextElement().setPdf_data(convertXStringToURL(wdContext.currentOutputElement().getBin_File()));

    //@@end

    }

    public java.lang.String convertXStringToURL( byte[] doc_content )

    {

    //@@begin convertXStringToURL()

    String url = "";

    WDWebResourceType webResType = WDWebResourceType.PDF;

    IWDWebResource webResource = WDWebResource.getWebResource(doc_content, webResType);

    try {

    url = webResource.getURL();

    } catch (WDURLException e) {

    e.printStackTrace();

    }

    return url;

    //@@end

    }

    please help me to resolve this issue.

    Add comment
    10|10000 characters needed characters exceeded

    • h shilpi,

      nice to see the pics with all details,

      i would like to suggest a better programming style , like to use try catch block.

      try

      {

      // All your execution code

      }catch(Exception e)

      {

      }

      in the catch block i would suggest you to use this..

      //-------------------------------------------------------------------------

      StringWriter StrWriter = new StringWriter();

      Mylog.Myloc.errorT(StrWriter.toString());

      PrintWriter PntWWriter = new PrintWriter(StrWriter);

      StrWriter.getBuffer().setLength(0);

      exception.printStackTrace(PntWWriter);

      Mylog.Myloc.errorT(wdComponentAPI.getApplication().getName()+StrWriter.toString());

      //--------------------------------------------------------------------------------

      and at end of component controller or view controller put this code

      //@beging others

      public static class Mylog

      {

      private static final Location Myloc = Location.getLocation("com.yourorg.MyLogController");

      }

      //@end others

      This will actually clearly speicify the actual cause of the error and will be logged at nwa .

      in default trace.

      i.e log in as administrator to your ep server in the url

      http://host:port/nwa

      then go to monitoring->logs and traces-> select default trace --> here you will the find the errors that you get when you run your applications .

      in the logs it will give details explaination why such error is coming .

      now comign to your problem , in the above code you can see at line 123 you are getting data from node outputelement , i guess the cardinality of this is 0..n , and no element of that is available so you are getting null pointer exception.

      it should be 1..1

      Regards

      Govardan Raj S

  • May 20, 2014 at 09:32 AM

    debug first

    detail error

    Add comment
    10|10000 characters needed characters exceeded

  • May 21, 2014 at 05:05 AM

    Hi shilpi,

    Can you please provide further details , like when you are deploying you are getting the null pointer error or at run time when you are using the application.

    can you please post the error details completely

    Regards

    Govardan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 23, 2014 at 06:55 AM

    check the nwa, it will give your more detail about the error.

    Add comment
    10|10000 characters needed characters exceeded