Don't create the special factory for abstract classes.  Also, log that it's 
doing that as the user could avoid it via a default constructor.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/103c145d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/103c145d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/103c145d

Branch: refs/heads/3.0.x-fixes
Commit: 103c145d248c1eddcd57a0f3e3459ae3c743f72f
Parents: f49b6ef
Author: Daniel Kulp <[email protected]>
Authored: Tue Jun 2 15:33:26 2015 -0400
Committer: Daniel Kulp <[email protected]>
Committed: Tue Jun 2 16:55:08 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxb/JAXBContextInitializer.java    | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/103c145d/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
----------------------------------------------------------------------
diff --git 
a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
 
b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
index 27f7a74..afde3f4 100644
--- 
a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
+++ 
b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
@@ -34,6 +34,7 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.logging.Logger;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAttribute;
@@ -48,6 +49,7 @@ import javax.xml.namespace.QName;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.jaxb.JAXBUtils;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.ASMHelper;
 import org.apache.cxf.common.util.ASMHelper.ClassWriter;
 import org.apache.cxf.common.util.ASMHelper.MethodVisitor;
@@ -65,7 +67,7 @@ import org.apache.cxf.service.model.UnwrappedOperationInfo;
  * Walks the service model and sets up the classes for the context.
  */
 class JAXBContextInitializer extends ServiceModelVisitor {
-
+    private static final Logger LOG = 
LogUtils.getL7dLogger(JAXBContextInitializer.class);
     private Set<Class<?>> classes;
     private Collection<Object> typeReferences;
     private Set<Class<?>> globalAdapters = new HashSet<Class<?>>();
@@ -304,7 +306,10 @@ class JAXBContextInitializer extends ServiceModelVisitor {
             return;
         } else {
             Class<?> cls = JAXBUtils.getValidClass(claz);
-            if (cls == null && 
ReflectionUtil.getDeclaredConstructors(claz).length > 0) {
+            if (cls == null 
+                && ReflectionUtil.getDeclaredConstructors(claz).length > 0 
+                && !Modifier.isAbstract(claz.getModifiers())) {
+                LOG.info("Class " + claz.getName() + " does not have a default 
constructor which JAXB requires.");
                 //there is no init(), but other constructors
                 Object factory = createFactory(claz, 
ReflectionUtil.getDeclaredConstructors(claz)[0]);
                 unmarshallerProperties.put("com.sun.xml.bind.ObjectFactory", 
factory);

Reply via email to