Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-26
4
Medium Priority
?
1,954 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 2000 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

916 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