You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2018/04/18 07:39:24 UTC

[cxf-xjc-utils] branch master updated: [CXFXJC-25]cxf-xjc-plugin can't load xjc plugin extensions which is already on the classpath with jax-xjc 2.3.0

This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf-xjc-utils.git


The following commit(s) were added to refs/heads/master by this push:
     new 345186f  [CXFXJC-25]cxf-xjc-plugin can't load xjc plugin extensions which is already on the classpath with jax-xjc 2.3.0
345186f is described below

commit 345186ff320d5adae7ac0dfacdc423e39e93a798
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Wed Apr 18 15:39:14 2018 +0800

    [CXFXJC-25]cxf-xjc-plugin can't load xjc plugin extensions which is already on the classpath with jax-xjc 2.3.0
---
 .../java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java     | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java
index 7ca2f2f..3df23e0 100644
--- a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java
+++ b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/XSDToJavaRunner.java
@@ -157,6 +157,7 @@ public class XSDToJavaRunner {
                 catResolver.getCatalog().parseCatalog(catalogFile.getPath());
             }
         };
+
         for (URL url : urls) {
             opt.classpaths.add(url);
         }
@@ -164,7 +165,15 @@ public class XSDToJavaRunner {
             opt.target = SpecVersion.V2_1;
         }
         opt.setSchemaLanguage(Language.XMLSCHEMA);
-        opt.parseArguments(args);
+        // set up the context class loader so that the user-specified plugin
+        // on classpath can be loaded from there with jaxb-xjc 2.3.0
+        ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(opt.getUserClassLoader(origLoader));
+            opt.parseArguments(args);
+        } finally {
+            Thread.currentThread().setContextClassLoader(origLoader);
+        }
         Model model = loadModel(opt); 
         if (model == null) {
             listener.message(xsdFile, "Failed to create model");

-- 
To stop receiving notification emails like this one, please contact
ffang@apache.org.