This post originated from an RSS feed registered with Java Buzz
by Simon Brown.
Original Post: Introspector problems
Feed Title: Simon Brown's weblog
Feed URL: http://www.simongbrown.com/blog/feed.xml?flavor=rss20&category=java
Feed Description: My thoughts on Java, software development and technology.
I tried to upgrade my blog at the weekend to the latest version of Pebble and it failed miserably. I've been developing the recent changes against Resin and although my site is running on Tomcat, I didn't see there being any problems. Unfortunately, on requesting pages containing blog entries, I got the following error.
java.lang.StringIndexOutOfBoundsException: String index out of range: -3
at java.lang.String.substring(String.java:1444)
at java.beans.Introspector.getTargetEventInfo(Introspector.java:885)
at java.beans.Introspector.getBeanInfo(Introspector.java:372)
at java.beans.Introspector.getBeanInfo(Introspector.java:145)
The full stack trace contained references to the JSTL <c:out> tag. Initially I thought that this was causing the problem because the exception was being thrown when trying to evaluate a JSTL expression. After compiling my own version of Apache's JSTL implementation I was able to see that this wasn't the case. Strangely, a call to Introspector.getBeanInfo(Class c) was causing the problem, which is interesting because the target class of the expression hasn't changed. A quick Google later and I found a forum post for a similar problem, although it magically went away after changing some code.
After creating a test case, I set out to apply the new changes to the previous version of the codebase, hoping that I'd find the point at which it would break. Thankfully it didn't take too long, but I still don't really understand why this happened. In the new codebase, one of the existing superclasses now implements the java.beans.PropertyChangeListener interface and, for some reason, this unrelated change caused the exception. Moving the listener implementation into an inner class did the trick. As I said, I don't know why this happened, but I imagine that this worked on Resin because it ships with a different JSTL implementation. Anybody else experienced this?