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

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
HycelTaylorAsked:
Who is Participating?
 
girionisCommented:
Which line is the one that throws the npe? Can you make sure that you are *not* passing a null reference?
0
 
girionisCommented:
>  final Logon logon = (Logon) ServiceFactory.getInstance().getService(ServiceFactory.LOGON_SERVICE);

Is the above the line that throws the npe?
0
 
HycelTaylorAuthor Commented:
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
 
girionisCommented:
Thank you for accepting, glad I was of help :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.