Why and when to perform this task
Because of a change in the Java APIs for XML based Remote Procedure Call (JAX-RPC) specification, EJB applications that could be wrappered in WebSphere Application Server version 5.1 cannot be wrappered in version 6 unless you modify the code to the exception handling of the base EJB application.a service specific exception declared in a remote method signature must be a checked exception. It must extend java.lang.Exception either directly or indirectly but it must not be a RuntimeException.
So it is no longer possible to directly use java.lang.Exception or java.lang.Throwable types. You must modify your applications using service specific exceptions to comply with the specification.
Steps for this task
new UserException class: package irwwbase; /** * Insert the type's description here. * Creation date: (9/25/00 2:25:18 PM) * @author: Administrator */ public class UserException extends java.lang.Exception { private java.lang.String _infostring = null; private java.lang.String ex; /** * UserException constructor comment. */ public UserException() { super(); } /** * UserException constructor comment. */ public UserException (String infostring) { _infostring = infostring; } // ctor /** * Insert the method's description here. * Creation date: (11/29/2001 9:25:50 AM) * @param msg java.lang.String * @param ex java.lang.Exception */ public UserException(String msg,String t) { super(msg); this.setEx(t); } /** * @return */ public java.lang.String get_infostring() { return _infostring; } /** * @return */ public java.lang.String getEx() { return ex; } /** * @param string */ public void set_infostring(java.lang.String string) { _infostring = string; } /** * @param Exception */ public void setEx(java.lang.String exception) { ex = exception; } public void printStackTrace(java.io.PrintWriter s) { System.out.println("the exception is :"+ex); } }
new EJB exception handling: try { if (isDistributed()) itemCMPEntity = itemCMPEntityHome.findByPrimaryKey(ckey); else itemCMPEntityLocal = itemCMPEntityLocalHome.findByPrimaryKey(ckey); } catch (Exception ex) { System.out.println("%%%%% ERROR: getItemInstance - CMPjdbc " + _className); ex.printStackTrace(); throw new UserException("error on itemCMPEntityHome.findByPrimaryKey(ckey)",ex.getMessage()); }