Solved

Getting a java.lang.NullPointerException at SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)

Posted on 2004-08-26
4
1,711 Views
Last Modified: 2012-06-22
Hello

Could any one tell me the occasion in which the following Axis exception might be thrown:
 
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.lang.NullPointerException
 faultActor:
 faultNode:
 faultDetail:
 {http://xml.apache.org/axis/}stackTrace: AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.lang.NullPointerException
 faultActor:
 faultNode:
 faultDetail:

java.lang.NullPointerException
 at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
 at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
 at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)
 at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1528)
 at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
 at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
 at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
 at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
 at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
 at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
 at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
 at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
 at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
 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:2583)
 at org.apache.axis.client.Call.invoke(Call.java:2553)
 at org.apache.axis.client.Call.invoke(Call.java:2248)
 at org.apache.axis.client.Call.invoke(Call.java:2171)
 at org.apache.axis.client.Call.invoke(Call.java:1691)
 at com.tss.testadmin.service.logon.generated.LogonSoapBindingStub.authenticate(LogonSoapBindingStub.java:190)
 at com.tss.testadmin.swingclient.LogonForm.authenticate(LogonForm.java:29)
 at com.tss.testadmin.swingclient.LogonForm.main(LogonForm.java:48)

The web service I am implementing is not my first one.  However, it is the first I have implemented with my own exceptions.  The fact that my interface implements my own typed exceptions may have nothing to do with this issue.  But, currently, it's the only thing I can think of that may be causing the problem (I'm at my wits end).

-------- All of my typed exceptions are of the same form --------

package com.tss.testadmin.service;
import com.tss.testadmin.util.BaseException;

public class ServiceException extends BaseException {

  public ServiceException(String message) {
    super(message);
  }

  public ServiceException(String message, Integer errorId) {
    super(message, errorId);
  }
}


------- The web service inteface I am implementing is the following --------

package com.tss.testadmin.service.logon;

import com.tss.testadmin.dataAccess.valueObjects.PersonVO;
import com.tss.testadmin.service.ServiceException;

public interface Logon {
  public PersonVO authenticate(String userId, String password) throws InvalidUserIdException,
                                                                      InvalidPasswordException,
                                                                      ServiceException;
}
 
-------- My client code looks like the following --------
 
public class LogonForm {
  public static final String WEB_SERVICE_LOCATION = "http://localhost:8080/axis/services/";
 
  private Object getService(String name) throws Exception {
    final String endpoint = WEB_SERVICE_LOCATION + name;
    final URL serviceURL = new java.net.URL(endpoint);
    final LogonWebService service = new LogonWebServiceLocator();
    return service.getLogon(serviceURL);
  }
 
  public PersonVO authenticate(String userid,String password) {
    try {
      // Get web service port at http://localhost:8080/axis/services/Logon
      final Logon port = (Logon) getService("Logon");
      PersonVO vo = port.authenticate(userid,password);
      System.err.println("***** " + vo.getFirstName() + " " + vo.getLastName() + " " + vo.getPersonTypeId());
      return vo;
    } catch (ServiceException e) {
      e.printStackTrace();
    } catch (InvalidUserIdException e) {
      e.printStackTrace();
    } catch (InvalidPasswordException e) {
      e.printStackTrace();
    } catch (RemoteException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;
  }
 
  public static void main(String[] args) {
    LogonForm logonForm = new LogonForm();
    logonForm.authenticate("user1","password1");
  }
}
 
------- It calls a simple web service that does the following: --------
 
package com.tss.testadmin.service.logon.generated;
 
import com.tss.testadmin.service.ServiceException;
import com.tss.testadmin.service.ServiceFactory;
import com.tss.testadmin.service.logon.InvalidPasswordException;
import com.tss.testadmin.service.logon.InvalidUserIdException;
import com.tss.testadmin.service.logon.Logon;
 
public class LogonSoapBindingImpl implements com.tss.testadmin.service.logon.generated.Logon {
 
  public com.tss.testadmin.dataAccess.valueObjects.generated.PersonVO convertToGenerated(com.tss.testadmin.dataAccess.valueObjects.PersonVO vo) {
    com.tss.testadmin.dataAccess.valueObjects.generated.PersonVO gen = new com.tss.testadmin.dataAccess.valueObjects.generated.PersonVO();
 
    gen.setCampusId(vo.getCampusId());
    gen.setDateOfBirth(vo.getDateOfBirth());
    gen.setFirstName(vo.getFirstName());
    gen.setLastName(vo.getLastName());
    gen.setMiddleInitial(vo.getMiddleInitial());
    gen.setPersonId(vo.getPersonId());
    gen.setPersonTypeId(vo.getPersonTypeId());
    gen.setProtectedId(vo.getProtectedId());
    gen.setPublicId(vo.getPublicId());
    gen.setRoleTypeId(vo.getRoleTypeId());
    gen.setSsn(vo.getSsn());
    gen.setUserId(vo.getUserId());
 
    return gen;
  }
 
  public com.tss.testadmin.dataAccess.valueObjects.generated.PersonVO authenticate(java.lang.String in0, java.lang.String in1)
        throws java.rmi.RemoteException,
        com.tss.testadmin.service.logon.generated.InvalidPasswordException,
        com.tss.testadmin.service.generated.ServiceException,
        com.tss.testadmin.service.logon.generated.InvalidUserIdException {
    try {
      System.err.println("***** I AM HERE *****");
      final Logon logon = (Logon) ServiceFactory.getInstance().getService(ServiceFactory.LOGON_SERVICE);
      return convertToGenerated(logon.authenticate(in0, in1));
    } catch (InvalidUserIdException e) {
      throw new com.tss.testadmin.service.logon.generated.InvalidUserIdException();
    } catch (InvalidPasswordException e) {
      throw new com.tss.testadmin.service.logon.generated.InvalidPasswordException();
    } catch (ServiceException e) {
      throw new com.tss.testadmin.service.generated.ServiceException();
    }
  }
}

Thanks in advance for any help in solving this issue.

Hycel
0
Comment
Question by:HycelTaylor
  • 3
4 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 500 total points
ID: 11911005
Which line is the one that throws the npe? Can you make sure that you are *not* passing a null reference?
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 500 total points
ID: 11911012
>  final Logon logon = (Logon) ServiceFactory.getInstance().getService(ServiceFactory.LOGON_SERVICE);

Is the above the line that throws the npe?
0
 

Author Comment

by:HycelTaylor
ID: 11911822
gironis,

You are correct! To test your assumption, I commented out the original block of code in the method authenticate(), and added the following line of code:

 return convertToGenerated(new com.tss.testadmin.dataAccess.valueObjects.PersonVO());

The client printed the following:

  ***** null null null

This means that the web service is working and I was looking at the wrong issue.  I didn't see it as the issue because, in my intelliJ debugger, I never saw my debug output of the first line of code in method authenticate():

   System.err.println("***** I AM HERE *****");

Thus, I assumed I never made to the authenticate() method.  I now realize that the debug statement is showing up in my Tomcat console.

Thanks for pointing me in the correct direction.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11911982
Thank you for accepting, glad I was of help :)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question