aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java39
1 files changed, 35 insertions, 4 deletions
diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java
index 9ad803049..cf774fe0d 100644
--- a/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java
+++ b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java
@@ -26,10 +26,14 @@ import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.classworlds.ClassWorld;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
+import java.lang.reflect.Method;
import java.net.URL;
+import java.net.URLClassLoader;
import java.util.List;
import java.util.Map;
@@ -44,6 +48,8 @@ import java.util.Map;
public class PlexusSisuBridge
{
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
private boolean containerAutoWiring = false;
private String containerClassPathScanning = PlexusConstants.SCANNING_OFF;
@@ -70,14 +76,19 @@ public class PlexusSisuBridge
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- ClassRealm classRealm = new ClassRealm( classWorld, "maven", tccl )
+ ClassRealm classRealm = new ClassRealm( classWorld, "maven", tccl );
+
+ // olamy hackhish but plexus-sisu need a URLClassLoader with URL filled
+
+ if ( tccl instanceof URLClassLoader )
{
- public URL[] getURLs()
+ URL[] urls = ( (URLClassLoader) tccl ).getURLs();
+ for ( URL url : urls )
{
- return super.getURLs();
+ classRealm.addURL( url );
}
+ }
- };
conf.setRealm( classRealm );
conf.setClassWorld( classWorld );
@@ -92,6 +103,26 @@ public class PlexusSisuBridge
}
}
+
+ private URL[] getClassLoaderURLs( ClassLoader classLoader )
+ {
+ try
+ {
+ // can be WebappClassLoader when using tomcat maven plugin
+ //java.net.URL[] getURLs
+ Method method = classLoader.getClass().getMethod( "getURLs", new Class[]{ } );
+ if ( method != null )
+ {
+ return (URL[]) method.invoke( classLoader, null );
+ }
+ }
+ catch ( Exception e )
+ {
+ log.info( "ignore issue trying to find url[] from classloader {}", e.getMessage() );
+ }
+ return new URL[]{ };
+ }
+
public <T> T lookup( Class<T> clazz )
throws PlexusSisuBridgeException
{