cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joakim Olsson (JIRA)" <j...@apache.org>
Subject [jira] Created: (CXF-3339) ClassLoader issue with cached JAXBContext by packagename
Date Tue, 15 Feb 2011 17:31:57 GMT
ClassLoader issue with cached JAXBContext by packagename
--------------------------------------------------------

                 Key: CXF-3339
                 URL: https://issues.apache.org/jira/browse/CXF-3339
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
            Reporter: Joakim Olsson


When using the same REST-integration from two different WAR's we got a nice "JAXBException
occurred : class packagename.Classname nor any of its super class is known to this context"
from one of the applications.

I tracked this to the AbstractJAXBProvider and the packageContexts being keyed on the string-representation
of the package.

The following naive patch (towards the 2.3.x-fixes branch) solved the problem for us. There
probably is a better solution.

@@ -394,7 +394,13 @@ public abstract class AbstractJAXBProvider extends AbstractConfigurableProvider
             return null;
         }
         synchronized (packageContexts) {
-            String packageName = PackageUtils.getPackageName(type);
+            String classLoaderName;
+            if (type.getClassLoader() != null) {
+                classLoaderName = type.getClassLoader().toString();
+            } else {
+                classLoaderName = "none";
+            }
+            String packageName = classLoaderName + "-" + PackageUtils.getPackageName(type);
             JAXBContext context = packageContexts.get(packageName);
             if (context == null) {
                 try {


-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message