tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1178381 - /openejb/trunk/openejb/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/TomcatHelper.java
Date Mon, 03 Oct 2011 12:14:43 GMT
Author: rmannibucau
Date: Mon Oct  3 12:14:42 2011
New Revision: 1178381

URL: http://svn.apache.org/viewvc?rev=1178381&view=rev
Log:
avoiding a classnotfoundexception when running tomee in normal mode (the error comes from
embedded mode)

Modified:
    openejb/trunk/openejb/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/TomcatHelper.java

Modified: openejb/trunk/openejb/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/TomcatHelper.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/TomcatHelper.java?rev=1178381&r1=1178380&r2=1178381&view=diff
==============================================================================
--- openejb/trunk/openejb/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/TomcatHelper.java
(original)
+++ openejb/trunk/openejb/assembly/openejb-tomcat/openejb-tomcat-loader/src/main/java/org/apache/openejb/tomcat/loader/TomcatHelper.java
Mon Oct  3 12:14:42 2011
@@ -19,6 +19,7 @@ package org.apache.openejb.tomcat.loader
 
 import java.io.File;
 import java.lang.management.ManagementFactory;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.security.Principal;
 
@@ -46,8 +47,18 @@ public class TomcatHelper {
 	public static StandardServer getServer() {
 		StandardServer server = null;
 
-        server = SystemInstance.get().getComponent(StandardServer.class);
-        if (server != null) return server;
+        Class<?> systemInstanceClass = null;
+        try {
+            // server = SystemInstance.get().getComponent(StandardServer.class)
+            systemInstanceClass = Thread.currentThread().getContextClassLoader().loadClass("org.apache.openejb.loader.SystemInstance");
+            Object instance = systemInstanceClass.getDeclaredMethod("get").invoke(null);
+            server = (StandardServer) systemInstanceClass.getDeclaredMethod("getComponent",
Class.class).invoke(instance, StandardServer.class);
+        } catch (Exception classNotFoundException) {
+            // ignored
+        }
+        if (server != null) {
+            return server;
+        }
 
         // first try to use Tomcat's ServerFactory class to give us a reference to the server
 		
@@ -56,8 +67,8 @@ public class TomcatHelper {
 			Method getServerMethod = tomcatServerFactory.getMethod("getServer");
 			server = (StandardServer) getServerMethod.invoke(null);
 		} catch (Exception e) {
+            // ignored
 		}
-		
 		if (server != null) {
 			return server;
 		}
@@ -67,10 +78,11 @@ public class TomcatHelper {
 			MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
 			server = (StandardServer) mbeanServer.getAttribute(new ObjectName("Catalina:type=Server"),
"managedResource");
 		} catch (Exception e) {
+            // ignored
 		}
 
 		// if this still fails, that's too bad.
-		
+
 		return server;
 	}
 	



Mime
View raw message