Discussions

EJB programming & troubleshooting: NullPointerException

  1. NullPointerException (4 messages)

    when i call a remote method on ejb, it throws a NullPointerException. i am passing a VO as an argument. code: In Action somewhere in my Action code... ArrayList al = (ArrayList) EJBRemote.xyz(VO); In Remote Interface public collection EJBRemote.xyz(VO) throws RemoteException; In Session Bean public collection EJBRemote.xyz(VO){ Dao.getXYZ(VO); } Error code : java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.ServerException: RuntimeException; nested exception is: java.lang.NullPointerException I have checked the code in DAO, there is no way it is going to throw NullPointerException. what could be the reason for NullPointerException?

    Threaded Messages (4)

  2. Re: NullPointerException[ Go to top ]

    May be the variable "Dao" is null. Is it a global variable ? and the bean is stateless ? then there is a possibility that "Dao" will be null.
  3. reply[ Go to top ]

    is a NullPointerException is thrown when an SQLException is thrown which is not handled by the calling ejb?
  4. more precise question[ Go to top ]

    is a nullpointerexception thrown by an ejb when an SQLException is thrown by the DAO, which is not handled by that ejb.
  5. Re: more precise question[ Go to top ]

    did you try to log.debug the dao i.e. public collection EJBRemote.xyz(VO){ log.debug("the dao object" + Dao); //the dao object must not be null, if possible also log/sys.out.print the VO object Dao.getXYZ(VO); } if both the objects are NOT null, then probably, there is some null pointer inside the getXYZ, try to check which objects could possibly be null. And SQLException will not get converted and display as NullPointerException, although subsequent to a SQLException or any other unhandled exception, a NullPointer could occur.