Commits

Ruwan Linton committed daec74d

Fixing the issue with resource loading within jar files of dua archives

Comments (0)

Files changed (2)

modules/core/src/main/java/org/adroitlogic/ultraesb/core/compile/HotSwapClassLoader.java

                 // we are interested only on class files
                 if (entry.getName().endsWith(".class")) {
                     availableDefinitions.put(entry.getName(), jar.toURI());
+                } else if (!entry.getName().endsWith("/")) {
+                    String resourceURI = "jar:file://" + jar.getAbsolutePath() + "!/" + entry.getName();
+                    try {
+                        availableResourceDefinitions.put(entry.getName(), new URI(resourceURI));
+                    } catch (URISyntaxException e) {
+                        logger.debug("Error converting the jar entry {} into a URI", resourceURI, e);
+                    }
                 }
             }
             jarFile.close();

modules/core/src/main/java/org/adroitlogic/ultraesb/core/deployment/DeploymentUnitBuilder.java

                                                    ClassLoader classLoader) {
 
         DeploymentUnit.DU_CLASS_LOADER.set(classLoader);
+        final ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
 
         GenericApplicationContext ctx = null;
         try {
+            Thread.currentThread().setContextClassLoader(classLoader);
             ctx  = new GenericApplicationContext(config.getRootContext());
+            ctx.setClassLoader(classLoader);
             XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
             xmlReader.loadBeanDefinitions(new FileSystemResource(duFile));
-            ctx.setClassLoader(classLoader);
             ctx.refresh();
             ctx.setDisplayName(duFile.getAbsolutePath());
 
         } catch (Exception e) {
             handleException("Error building deployment unit : " + duId, ctx, e);
         } finally {
+            Thread.currentThread().setContextClassLoader(currentClassLoader);
             DeploymentUnit.DU_CLASS_LOADER.remove();
         }