function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

java.lang.NullPointerException during login (remoteexception)

I use the Eclipse deveopment environment and was testing a small java app to update a field in the Account object.  In the Eclipse enviornment the login is successful and the update to the Account object works.

I tried to run the app from a dos window using 'java' and I receive the message:

; nested exception is:

I checked my classpath and the paths looked ok.  I went back and tried the quickstart.class and it is now happening to quickstart as well.  The exception that is being processed is the RemoteException.

The login code is the code from the quickstart sample.  The login code is below.

  private void doLogin() {
  if (userName.length() == 0 || pwd.length() == 0)
  else {
   try {
    binding = (SoapBindingStub) new SforceServiceLocator()
   } catch (ServiceException ex1) {
   try {
    lr = binding.login(userName, pwd);
   } catch (UnexpectedErrorFault ex2) {
    System.out.println(ex2.getExceptionMessage() + "\nUnexpected\n");
   } catch (LoginFault ex2) {
    System.out.println(ex2.getExceptionMessage() + "\nloginfault\n");
   } catch (RemoteException ex2) {
    System.out.println(ex2.getMessage() + "\nremote\n");
   System.out.println("Login was successfull.");
   System.out.print("The returned session id is: ");
   System.out.print("Your logged in user id is: ");
   System.out.println(lr.getUserId() + " \n\n");

   //on a successful login, you should always set up your session id
   //and the url for subsequent calls

   //reset the url endpoint property, this will cause subsequent calls
   //to made to the serverURL from the login result

   //create a session head object
   _SessionHeader sh = new _SessionHeader();
   //set the sessionId property on the header object using
   //the value from the login result
   //add the header to the binding stub
                       String sforceURI = new SforceServiceLocator().getServiceName().getNamespaceURI();
   binding.setHeader(sforceURI, "SessionHeader", sh);

I thought maybe recompiling in the DOS window would work so I used 'javac' to recompile and still received the error.

What I don't understand is why the app runs correctly through the Eclipse environment but not in the DOS windows.

Any ideas?




The error is occuring while I execute it from my workstation.  I decided to try and run it from my Windows 2003 Server.

I copied over the necessary files and set the classpath and my app completes the login routine successfully.


Probably a classpath related issue. What's the message string for the exception ?
Hey ...

Try printing out the Exection. In the Try catch block .. Instead of the message. Try Exception.printStackTrace();

Sometimes, the problem could be with Axis and Java compatability : If you are using Java 1.5 try Axis- RC1 .. This is something you can figure it out once you know where exactly the error is.



You're right.  I checked the java -version on my server and it was 1.4.2 and the version was recently auto updated on my workstation and when I checked it, the version was 1.5.

I removed version 1.5 and now the login works correctly.





I would suggest you to update your axis and try to get it to work for Java 1.5 rather than using old Java Version. Eventually , you will have to update .. why not do it now ...

Jus a Suggestion..


Chitra, Thanks for your suggestion !

Today, I faced the following error when loggin-to SF:

; nested exception is:

and going by your post, I used Exception.printStackTrace(); to get more details.

it was indeed the upgradation of java version to 1.5 which caused incompatibility with existing Axis ver 1.1

I installed the latest version 1.2.1 of Axis and its now working.