Fixed a ClassCastException in some codepaths of BasicResourceFactory construction. Thanks to petrjanata on SourceForge for reporting and tracking down the issue.