I'm not sure how good this solution is. It avoids the ClassNotFoundException when debugging but it remains to be seen how well it works when the report is used from within the application at runtime.
public static List<Protocol> getProtocols(String path) throws Exception
{
List<Protocol> result = new ArrayList<Protocol>();
File file = new File(path);
if (file.exists())
{
String xml = FileUtils.read(file);
try
{
Trace.out("P1");
Protocol pp = new Protocol();
Trace.out("Class: %s", pp.getClass().getName());
Trace.out("ClassLoader: %s", pp.getClass().getClassLoader());
// FORCE THREAD CLASSLOADER
Thread.currentThread().setContextClassLoader(
pp.getClass().getClassLoader());
XMLSerializer xs = new XMLSerializer();
Protocol p = xs.deserialize(xml, Protocol.class);
result.add(p);
}
catch (Exception e)
{
}
}
return result;
}