Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 22470 invoked from network); 23 Jan 2007 06:23:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Jan 2007 06:23:22 -0000 Received: (qmail 47464 invoked by uid 500); 23 Jan 2007 06:23:27 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 47355 invoked by uid 500); 23 Jan 2007 06:23:27 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 47344 invoked by uid 500); 23 Jan 2007 06:23:27 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 47341 invoked by uid 99); 23 Jan 2007 06:23:27 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Jan 2007 22:23:27 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Jan 2007 22:23:20 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 9FCD61A981A; Mon, 22 Jan 2007 22:22:13 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: axis2-cvs@ws.apache.org From: nthaker@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070123062213.9FCD61A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 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