diff --git a/src/main/java/org/openhab/automation/jrule/internal/handler/JRuleHandler.java b/src/main/java/org/openhab/automation/jrule/internal/handler/JRuleHandler.java index c2fe7c30..7eff5e07 100644 --- a/src/main/java/org/openhab/automation/jrule/internal/handler/JRuleHandler.java +++ b/src/main/java/org/openhab/automation/jrule/internal/handler/JRuleHandler.java @@ -508,19 +508,21 @@ public Class loadClass(String name) throws ClassNotFoundException { try { for (URL url : getURLs()) { if (url.getProtocol().equals("file")) { - FileInputStream is = new FileInputStream( - url.getFile() + "/" + name.replaceAll("\\.", "/") + JRuleConstants.CLASS_FILE_TYPE); - if (is != null) { - byte[] buf = is.readAllBytes(); - is.close(); - return defineClass(name, is.readAllBytes(), 0, buf.length); + File classFile = new File(url.getPath(), + name.replaceAll("\\.", "/") + JRuleConstants.CLASS_FILE_TYPE); + if (classFile.exists()) { + FileInputStream is = new FileInputStream(classFile); + if (is != null) { + byte[] buf = is.readAllBytes(); + is.close(); + return defineClass(name, buf, 0, buf.length); + } } } } return super.loadClass(name); - } catch (IOException e) { - JRuleLog.warn(logger, LOG_NAME_HANDLER, e.getMessage()); + JRuleLog.warn(logger, LOG_NAME_HANDLER, "Trouble loading class {}: {}", name, e.toString()); return super.loadClass(name); } }