Solved

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

Posted on 2004-08-26
4
1,672 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
Comment Utility
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
Comment Utility
>  final Logon logon = (Logon) ServiceFactory.getInstance().getService(ServiceFactory.LOGON_SERVICE);

Is the above the line that throws the npe?
0
 

Author Comment

by:HycelTaylor
Comment Utility
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
Comment Utility
Thank you for accepting, glad I was of help :)
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Java and GPO 11 45
Java - Why doesn't this JFrame work 3 13
maven project error 5 16
github account with ecipse 1 14
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now