axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntha...@apache.org
Subject svn commit: r498931 - in /webservices/axis2/trunk/java/modules: jaxws/src/org/apache/axis2/jaxws/message/databinding/ jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/ jaxws/src/org/apache/axis2/jaxws/server/ metadata/src/org/apache/axis2/jaxw...
Date Tue, 23 Jan 2007 06:22:13 GMT
Author: nthaker
Date: Mon Jan 22 22:22:12 2007
New Revision: 498931

URL: http://svn.apache.org/viewvc?view=rev&rev=498931
Log:
AXIS2-2015
Catching Throable where ever we use Class.forName in jaxws.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/ClassFinderImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderUtils.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java?view=diff&rev=498931&r1=498930&r2=498931
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
Mon Jan 22 22:22:12 2007
@@ -81,7 +81,12 @@
 	 */
 	public static JAXBContext getJAXBContext(Set<String> contextPackages) throws JAXBException
{
 		// JAXBContexts for the same class can be reused and are supposed to be thread-safe
-        
+        if(log.isDebugEnabled()){
+        	log.debug("Following packages are in this batch of getJAXBContext() :");
+        	for(String pkg:contextPackages){
+        		log.debug(pkg);
+        	}
+        }
 	    // The JAXBContexts are keyed by ClassLoader and the set of Strings
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         
@@ -125,7 +130,12 @@
     private static JAXBContext createJAXBContext(Set<String> contextPackages, ClassLoader
cl) throws JAXBException {
 
        JAXBContext context = null;
-       
+       if(log.isDebugEnabled()){
+       	log.debug("Following packages are in this batch of getJAXBContext() :");
+       	for(String pkg:contextPackages){
+       		log.debug(pkg);
+       	}
+       }
         // The contextPackages is a set of package names that are constructed using PackageSetBuilder.
         // PackageSetBuilder gets the packages names from the following sources.
         //   a) It walks the various annotations on the WebService collecting package names.
@@ -368,14 +378,20 @@
 	private static boolean checkPackage(String p, ClassLoader cl) {
 	    
 	    // Each package must have an ObjectFactory
-	    
+		if(log.isDebugEnabled()){
+        	log.debug("checking package :" + p);
+        	
+        }
 	    try {
 	        Class cls = Class.forName(p + ".ObjectFactory",false, cl);
 	        if (cls != null) {
 	            return true;
 	        }
-	    } catch (Exception e) {
-	        // Exception is thrown if class does not exist.  
+	        //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that
+	        //does not extend Exception. So we will absorb any Throwable exception here.
+	    } catch (Throwable e) {
+	        // Exception is thrown if class does not exist.
+	    	e.printStackTrace();
 	    }
 	    
         try {
@@ -383,8 +399,11 @@
             if (cls != null) {
                 return true;
             }
-        } catch (Exception e) {
-            // Exception is thrown if class does not exist.  
+            //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that
+	        //does not extend Exception. So we will absorb any Throwable exception here.
+        } catch (Throwable e) {
+            // Exception is thrown if class does not exist.
+        	e.printStackTrace();
         }
 
 	    return false;
@@ -451,8 +470,7 @@
         } catch (ClassNotFoundException e) {
         	 if(log.isDebugEnabled()){
                  log.debug("getClassesFromDirectory failed to get Classes");
-        	 }
-        	 e.printStackTrace();            
+        	 }          
         }
         try {
            //If Calsses not found in directory then look for jar that has these classes
@@ -465,7 +483,6 @@
         	 if(log.isDebugEnabled()){
                  log.debug("getClassesFromJarFile failed to get Classes");
         	 }
-        	 e.printStackTrace();
         }
         
         return classes;
@@ -535,7 +552,9 @@
                                 
                                 //Class aClazz = Class.forName(loadableName, false, Thread.currentThread().getContextClassLoader());
                             }
-                        } catch (Exception e) {
+                	        //Catch Throwable as ClassLoader can throw an NoClassDefFoundError
that
+                	        //does not extend Exception
+                        } catch (Throwable e) {
                             if (log.isDebugEnabled()) {
                                 log.debug("Tried to load class " + className + " while constructing
a JAXBContext.  This class will be skipped.  Processing Continues." );
                                 log.debug("  The reason that class could not be loaded:"
+ e.toString());
@@ -580,7 +599,9 @@
                 // Load and add the class
                 Class cls = Class.forName(ClassUtils.getLoadableClassName(className), false,
cl);
                 list.add(cls);
-            } catch (Exception e) {
+    	        //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that
+    	        //does not extend Exception
+            } catch (Throwable e) {
                 if (log.isDebugEnabled()) {
                     log.debug("Tried to load class " + className + " while constructing a
JAXBContext.  This class will be skipped.  Processing Continues." );
                     log.debug("  The reason that class could not be loaded:" + e.toString());

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/ClassFinderImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/ClassFinderImpl.java?view=diff&rev=498931&r1=498930&r2=498931
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/ClassFinderImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/ClassFinderImpl.java
Mon Jan 22 22:22:12 2007
@@ -80,7 +80,10 @@
 		        	                             classes.add(clazz);
 		        	                             
 		        	                         }
-		        	                       }catch (Exception e) {
+		        	             	        //catch Throwable as ClassLoader can throw an NoClassDefFoundError
that
+		        	             	        //does not extend Exception, so lets catch everything that
extends Throwable
+		        	                        //rather than just Exception.
+		        	                       }catch (Throwable e) {
 		        	                         if (log.isDebugEnabled()) {
 		        	                             log.debug("Tried to load class " + clazzName + "
while constructing a JAXBContext.  This class will be skipped.  Processing Continues." );
 		        	                             log.debug("  The reason that class could not be loaded:"
+ e.toString());

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java?view=diff&rev=498931&r1=498930&r2=498931
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
Mon Jan 22 22:22:12 2007
@@ -109,7 +109,10 @@
 		    //TODO: What should be done if the supplied ClassLoader is null?
             Class _class = Class.forName(className, true, cl);
             return _class;
-		} catch(ClassNotFoundException cnf ){
+	        //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that
+	        //does not extend Exception, so lets catch everything that extends Throwable
+            //rather than just Exception.
+		} catch(Throwable cnf ){
 			throw ExceptionFactory.makeWebServiceException(Messages.getMessage(
                     "EndpointControllerErr4", className));
 		}

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderUtils.java?view=diff&rev=498931&r1=498930&r2=498931
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderUtils.java
Mon Jan 22 22:22:12 2007
@@ -310,8 +310,11 @@
             // Use the specified classloader to load the class.
             try {
                 returnClass = Class.forName(classToLoad, false, classLoader);
-            } 
-            catch (ClassNotFoundException ex) {
+            }
+	        //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that
+	        //does not extend Exception, so lets catch everything that extends Throwable
+            //rather than just Exception.
+            catch (Throwable ex) {
                 throw ExceptionFactory.makeWebServiceException("DescriptionBuilderUtils:
Class not found for parameter: " +classToLoad);
             }
         } 
@@ -320,7 +323,9 @@
             try {
                 returnClass = Class.forName(classToLoad);
             } 
-            catch (ClassNotFoundException ex) {
+	        //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that
+	        //does not extend Exception
+            catch (Throwable ex) {
                 throw ExceptionFactory.makeWebServiceException("DescriptionBuilderUtils:
Class not found for parameter: " +classToLoad);
             }
         }

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?view=diff&rev=498931&r1=498930&r2=498931
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
Mon Jan 22 22:22:12 2007
@@ -470,7 +470,10 @@
     				try {
     					// TODO: Using Class.forName() is probably not the best long-term way to get the
SEI class from the annotation
     					seiClass = Class.forName(seiClassName, false, Thread.currentThread().getContextClassLoader());
-    				} catch (ClassNotFoundException e) {
+    			        //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that
+    			        //does not extend Exception, so lets catch everything that extends Throwable
+                        //rather than just Exception.
+    				} catch (Throwable e) {
     					// TODO: Throwing wrong exception
     					e.printStackTrace();
     					throw new UnsupportedOperationException("Can't create SEI class: " + e);

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java?view=diff&rev=498931&r1=498930&r2=498931
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java
Mon Jan 22 22:22:12 2007
@@ -368,8 +368,10 @@
             // TODO J2W AccessController Needed
             // Don't make this public, its a security exposure
             return Class.forName(className, true, Thread.currentThread().getContextClassLoader());
-            
-        } catch (ClassNotFoundException e) {
+	        //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that
+	        //does not extend Exception, so lets catch everything that extends Throwable
+            //rather than just Exception.
+        } catch (Throwable e) {
             // TODO Should the exception be swallowed ?
             if (log.isDebugEnabled()) {
                 log.debug("PackageSetBuilder cannot load the following class:" + className);



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message