NamingException extends NestedRuntimeException { public Object getResolvedObj() { if (getCause() instanceof javax.naming.NamingException) { return ((javax.naming.NamingException) getCause()).getResolvedObj(); } return null; } NamingException(String msg);  NamingException(String msg, Throwable cause);  NamingException(Throwable cause); Throwable getCause(); String getExplanation(); Name getRemainingName(); Name getResolvedName(); Object getResolvedObj();  }
@Test public void testNamingExceptionWithNonSerializableResolvedObj() throws Exception { javax.naming.NameAlreadyBoundException wrappedException = new javax.naming.NameAlreadyBoundException( "some error"); wrappedException.setResolvedObj(new InitialDirContext()); NamingException exception = new NameAlreadyBoundException( wrappedException); writeToStream(exception); NamingException deSerializedException = readFromStream(); assertNotNull( "Original exception resolvedObj after serialization should not be null", exception.getResolvedObj()); assertNull("De-serialized exception resolvedObj should be null", deSerializedException.getResolvedObj()); }