You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2008/07/16 21:56:26 UTC

svn commit: r677400 - /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java

Author: scheu
Date: Wed Jul 16 12:56:26 2008
New Revision: 677400

URL: http://svn.apache.org/viewvc?rev=677400&view=rev
Log:
Quick Fix.  If the findBestSet method fails with the intial "primary classes" then fallback to a brute force method of adding one class at a time.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java?rev=677400&r1=677399&r2=677400&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java Wed Jul 16 12:56:26 2008
@@ -77,13 +77,17 @@
         try {
             if (log.isDebugEnabled()) {
                 if (classArray == null || classArray.length == 0) {
-                    log.debug("JAXBContext is constructed with 0 input classes.");
+                    log.debug("Try to construct JAXBContext with 0 input classes.");
                 } else {
-                    log.debug("JAXBContext is constructed with " + classArray.length +
+                    log.debug("Try to construct JAXBContext with " + classArray.length +
                             " input classes.");
                 }
             }
             jaxbContext = _newInstance(classArray, cl, properties);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Successfully constructed JAXBContext " + jaxbContext);
+            }
         } catch (Throwable t) {
             // Try finding the best set of classes
             ArrayList<Class> original = new ArrayList<Class>();
@@ -184,6 +188,11 @@
                                    ClassLoader cl,
                                    List<Class> best, 
                                    Map<String, ?> properties) {
+        
+        if (log.isDebugEnabled()) {
+            log.debug("Could not construct JAXBContext with the initial list.");
+            log.debug("Now trying to construct JAXBContext with only the valid classes in the list");
+        }
         JAXBContext jc = null;
         Class[] clsArray = new Class[0];
             
@@ -200,7 +209,15 @@
             try {
                 jc = _newInstance(best.toArray(clsArray), cl, properties);
             } catch (Throwable t) {
-                return null;
+                if (log.isDebugEnabled()) {
+                    log.debug("The JAXBContext creation failed with the primary list");
+                    log.debug("Will try a more brute force algorithm");
+                    log.debug("  The reason is " + t);
+                }
+                // Add all of the primary classes to the secondary list so 
+                // that we can walk them one by one.
+                secondary.addAll(primary);
+                best.clear(); // Clear out the best list
             }
         }