From 191724a9eb132d232f8ab081658aa40ea1eb2778 Mon Sep 17 00:00:00 2001 Subject: [PATCH] OWB-1309 fix missing NoSuchMethodException --- pom.xml | 2 +- .../web/tomcat7/TomcatInstanceManager.java | 53 ++++++++++++++----- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index ba45ccc..316f27e 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,7 @@ 1.0 1.1 6.0.35 - 7.0.54 + 7.0.99 3.1.4 1.2.9 2.2.3 diff --git a/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java b/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java index eb127e6..d271d4e 100644 --- a/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java +++ b/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java @@ -27,6 +27,7 @@ import javax.naming.NamingException; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.InstanceManager; +import org.apache.webbeans.util.ExceptionUtil; public class TomcatInstanceManager implements InstanceManager { @@ -70,24 +71,40 @@ public class TomcatInstanceManager implements InstanceManager public Object newInstance(Class aClass) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException { // Creates a defaut instance - Object object = this.processor.newInstance(aClass); + try + { + Object object = this.processor.newInstance(aClass); - // Inject dependencies - inject(object); + // Inject dependencies + inject(object); - return object; + return object; + } + catch (Exception e) + { + // sadly this is required as the Tomcat InstanceManager introduced an additional Exception in their signature :( + throw ExceptionUtil.throwAsRuntimeException(e); + } } @Override public Object newInstance(String str) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException { - // Creates a defaut instance - Object object = this.processor.newInstance(str); + try + { + // Creates a defaut instance + Object object = this.processor.newInstance(str); - // Inject dependencies - inject(object); + // Inject dependencies + inject(object); - return object; + return object; + } + catch (Exception e) + { + // sadly this is required as the Tomcat InstanceManager introduced an additional Exception in their signature :( + throw ExceptionUtil.throwAsRuntimeException(e); + } } @Override @@ -100,13 +117,21 @@ public class TomcatInstanceManager implements InstanceManager @Override public Object newInstance(String str, ClassLoader cl) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException { - // Creates a defaut instance - Object object = this.processor.newInstance(str, cl); + try + { + // Creates a defaut instance + Object object = this.processor.newInstance(str, cl); - // Inject dependencies - inject(object); + // Inject dependencies + inject(object); - return object; + return object; + } + catch (Exception e) + { + // sadly this is required as the Tomcat InstanceManager introduced an additional Exception in their signature :( + throw ExceptionUtil.throwAsRuntimeException(e); + } } private void inject(Object object) -- 2.23.0