Dear users,
I recently encountered a bug in the Main/RecentChanges page.
For some reason, we kept getting an error:
Error number 4001 in 4: Error while parsing velocity page
Main.RecentChanges
Wrapped Exception: Failed to evaluate content with id Recent Changes
com.xpn.xwiki.XWikiException: Error number 4001 in 4: Error while parsing velocity page
Main.RecentChanges
Wrapped Exception: Failed to evaluate content with id Recent Changes
at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:114)
at com.xpn.xwiki.render.XWikiVelocityRenderer.render(XWikiVelocityRenderer.java:85)
.............
Caused by: java.lang.ClassCastException: java.util.Date
at java.sql.Timestamp.compareTo(Timestamp.java:474)
.............
It was unclear when it occured, because this has worked before.
After some googling, I found this:
http://twit88.com/blog/2007/12/08/javasqltimestamp-compareto-bug-in-jdk-15/
So I started fiddling around a bit.
The classes compared in the following line in the source seem both to be of the java util
Date class.
For some reason the comparison fails, just like in the article.
The difference with the article is that a subclass is compared to a superclass, while in
this case the comparison seems the same.
I do not know enough about XWiki internals to find out what goes wrong.
So could be a JDK 1.5 bug, could be a XWiki bug.
We are running XWiki 1.9.3.22597 on Oracle AS with JDK 1.5.
The workaround that for the moment does the trick is to switch the compared values.
So:
change this:
#if($lastCommentDate.compareTo($rcDt.toDate()) > -1 &&
$lastCommentDate.compareTo($rcDt.toDate()) <= 1)
with this:
#if($rcDt.toDate().compareTo($lastCommentDate) < -1 &&
$rcDt.toDate().compareTo($lastCommentDate) >= 1)
I am interested to know if more users encountered this.
Besides that I would like to know if this should be reported in Jira and how?
Hope this helps someone.
I am not sure if this is a structural solution, I would love to hear that from a
developer.
--
Met vriendelijke groet / Kind regards,
Vincent Gerris (SL 2.34)
De Haagse Hogeschool
Dienst ICT
V.J.Gerris(a)hhs.nl
Tel: 070 445 7468