]> source.dussan.org Git - gitblit.git/commitdiff
Fix class loading failure when there are no STARTED plugins
authorJames Moger <james.moger@gitblit.com>
Wed, 7 May 2014 19:37:03 +0000 (15:37 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 7 May 2014 19:37:03 +0000 (15:37 -0400)
src/main/java/com/gitblit/wicket/GitBlitWebApp.java
src/main/java/com/gitblit/wicket/PluginClassResolver.java

index d3aa62fdd6de9c0eb3b3568df66380feb3335bbc..7291d03956cc57bcb7ad73c3bdb5f842835d238e 100644 (file)
@@ -25,6 +25,7 @@ import org.apache.wicket.Application;
 import org.apache.wicket.Request;
 import org.apache.wicket.Response;
 import org.apache.wicket.Session;
+import org.apache.wicket.application.IClassResolver;
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.protocol.http.WebApplication;
 
@@ -226,7 +227,8 @@ public class GitBlitWebApp extends WebApplication implements GitblitWicketApp {
                }
 
                 // customize the Wicket class resolver to load from plugins
-        PluginClassResolver classResolver = new PluginClassResolver(pluginManager);
+               IClassResolver coreResolver = getApplicationSettings().getClassResolver();
+        PluginClassResolver classResolver = new PluginClassResolver(coreResolver, pluginManager);
         getApplicationSettings().setClassResolver(classResolver);
 
                getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
index ba53b04bf28369cf41314ee5ac63997f32f4abc7..476f9611817d09f4b1691ca15fea30796bd6e588 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.Set;
 import java.util.TreeSet;
 
-import org.apache.wicket.Application;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.application.IClassResolver;
 import org.slf4j.Logger;
@@ -40,9 +39,11 @@ import com.gitblit.manager.IPluginManager;
 public class PluginClassResolver implements IClassResolver {
        private static final Logger logger = LoggerFactory.getLogger(PluginClassResolver.class);
 
+       private final IClassResolver coreResolver;
        private final IPluginManager pluginManager;
 
-       public PluginClassResolver(IPluginManager pluginManager) {
+       public PluginClassResolver(IClassResolver coreResolver, IPluginManager pluginManager) {
+               this.coreResolver = coreResolver;
                this.pluginManager = pluginManager;
        }
 
@@ -65,7 +66,7 @@ public class PluginClassResolver implements IClassResolver {
                        }
                }
 
-               throw new ClassNotFoundException(className);
+               return coreResolver.resolveClass(className);
        }
 
        @Override
@@ -85,6 +86,11 @@ public class PluginClassResolver implements IClassResolver {
                        }
                }
 
+               Iterator<URL> it = coreResolver.getResources(name);
+               while (it.hasNext()) {
+                       URL url = it.next();
+                       urls.add(url);
+               }
                return urls.iterator();
        }
 
@@ -94,14 +100,6 @@ public class PluginClassResolver implements IClassResolver {
                        // Try the classloader for the wicket jar/bundle
                        Enumeration<URL> resources = plugin.getPluginClassLoader().getResources(name);
                        loadResources(resources, loadedFiles);
-
-                       // Try the classloader for the user's application jar/bundle
-                       resources = Application.get().getClass().getClassLoader().getResources(name);
-                       loadResources(resources, loadedFiles);
-
-                       // Try the context class loader
-                       resources = Thread.currentThread().getContextClassLoader().getResources(name);
-                       loadResources(resources, loadedFiles);
                } catch (IOException e) {
                        throw new WicketRuntimeException(e);
                }