Hi,

Revision
    11468 <http://fisheye.codehaus.org/changelog/mojo/?cs=11468>
Author
    jonnio
Date
    2009-12-07 09:38:27 -0600 (Mon, 07 Dec 2009)


      Log Message

Updated documentation. Fixed bug with jdk 1.6 and claassloading.


     /**
+     * Load tools jar into the selected classloader. We need to do it this way
+     * because the addURL method is protected on the classloader. This is for 
a bug in 1.6
+     * tools.jar implementations
+     *
+     * @param classLoader the classloader to load
+     * @throws Exception
+     */
+    protected void addToolsJar(ClassLoader classLoader) throws Exception {
+        if (this.toolsJar == null ||
+                this.toolsJar.trim().length() == 0) {
+            throw new MojoExecutionException(
+                    "toolsJar is required for this mojo.");
+        }
+        final File f = new File(this.toolsJar);
+        if (!f.exists()) {
+            throw new MojoExecutionException(
+                    "toolsJar was supplied but not found. was java.home 
correct?");
+        }
+        final URL u = f.toURI().toURL();
+        final Class urlClass = URLClassLoader.class;
+        final Method method =
+                urlClass.getDeclaredMethod("addURL", new Class[]{URL.class});
+        method.setAccessible(true);
+        method.invoke(classLoader, new Object[]{u});
+    }
+
--- 
trunk/mojo/weblogic-maven-plugin/src/main/java/org/codehaus/mojo/weblogic/JwscMojo.java
     2009-12-06 21:15:43 UTC (rev 11467)
+++ 
trunk/mojo/weblogic-maven-plugin/src/main/java/org/codehaus/mojo/weblogic/JwscMojo.java
     2009-12-07 15:38:27 UTC (rev 11468)
@@ -154,6 +154,7 @@
                 getLog().debug( iter.next().toString() );
             }
             final JwscTask task = new JwscTask();
+            addToolsJar( ClassLoader.getSystemClassLoader() );

Hacking other people's class loaders like this is bad and will in particular not be supported by Maven 3. See http://jira.codehaus.org/browse/MOJO-1458 for a related bug.


Benjamin

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to