David Blevins wrote:

On May 22, 2008, at 4:00 AM, Rick McGuire wrote:

I'm thinking perhaps the problem might be you're getting a ClassCastException on the throwable line itself. The line

  cause = new EJBException(re.getMessage(), (Exception) detail);

will cause a ClassCastException because detail is an instance of AbstractMethodError, which is not a subclass of Exception.

Yea, that's it. I came to that conclusion as well at the end of my last email and was sort of kicking myself for missing it.

Unfortunately, you can't just remove the (Exception) cast, because that's the type specified on the constructor. It looks like the initClause() form is the only way to get what you want out of this.


I'd love to know the rationale behind not allowing it to accept throwable in the constructor. Seems like awfully arbitrary restriction.
I was wondering the same thing, so I took at look at the spec code. There's a getCausedByException() method defined on that class that checks to see if the init cause is an instance of Exception and returns null if not. That's the only clue I could find for why it might be that way. It seems silly to me.


-David




Reply via email to