ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject ambari git commit: AMBARI-11468 - Views : ClassLoader conflict with com.sun.jersey classes (tbeerbower)
Date Thu, 28 May 2015 13:44:49 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 8775fe29c -> 087d9003e


AMBARI-11468 - Views : ClassLoader conflict with com.sun.jersey classes (tbeerbower)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/087d9003
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/087d9003
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/087d9003

Branch: refs/heads/trunk
Commit: 087d9003ecf6af33890e4f48743d7237a30d6438
Parents: 8775fe2
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Thu May 28 09:44:23 2015 -0400
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Thu May 28 09:44:37 2015 -0400

----------------------------------------------------------------------
 ambari-project/pom.xml                          | 18 ++++++++--------
 .../ambari/server/view/ViewClassLoader.java     |  8 ++++++-
 .../ambari/server/view/ViewClassLoaderTest.java | 22 +++++++++++++++-----
 3 files changed, 33 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/087d9003/ambari-project/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-project/pom.xml b/ambari-project/pom.xml
index b1db47b..528dbf4 100644
--- a/ambari-project/pom.xml
+++ b/ambari-project/pom.xml
@@ -301,12 +301,12 @@
       <dependency>
         <groupId>com.sun.jersey</groupId>
         <artifactId>jersey-core</artifactId>
-        <version>1.11</version>
+        <version>1.18</version>
       </dependency>
       <dependency>
         <groupId>com.sun.jersey</groupId>
         <artifactId>jersey-grizzly</artifactId>
-        <version>1.11</version>
+        <version>1.18</version>
       </dependency>
       <dependency>
         <groupId>org.codehaus.jackson</groupId>
@@ -341,17 +341,17 @@
       <dependency>
         <groupId>com.sun.jersey</groupId>
         <artifactId>jersey-bundle</artifactId>
-        <version>1.11</version>
+        <version>1.18</version>
       </dependency>
       <dependency>
         <groupId>com.sun.jersey</groupId>
         <artifactId>jersey-json</artifactId>
-        <version>1.11</version>
+        <version>1.18</version>
       </dependency>
       <dependency>
         <groupId>com.sun.jersey</groupId>
         <artifactId>jersey-server</artifactId>
-        <version>1.11</version>
+        <version>1.18</version>
       </dependency>
       <dependency>
         <groupId>com.sun.jersey</groupId>
@@ -361,23 +361,23 @@
       <dependency>
         <groupId>com.sun.jersey.contribs</groupId>
         <artifactId>jersey-multipart</artifactId>
-        <version>1.11</version>
+        <version>1.18</version>
       </dependency>
       <dependency>
         <groupId>com.sun.jersey.jersey-test-framework</groupId>
         <artifactId>jersey-test-framework-core</artifactId>
-        <version>1.11</version>
+        <version>1.18</version>
         <scope>test</scope>
       </dependency>
       <dependency>
         <groupId>com.sun.jersey.jersey-test-framework</groupId>
         <artifactId>jersey-test-framework-grizzly2</artifactId>
-        <version>1.11</version>
+        <version>1.18</version>
       </dependency>
       <dependency>
         <groupId>com.sun.jersey.contribs</groupId>
         <artifactId>jersey-guice</artifactId>
-        <version>1.11</version>
+        <version>1.18</version>
       </dependency>
       <dependency>
         <groupId>log4j</groupId>

http://git-wip-us.apache.org/repos/asf/ambari/blob/087d9003/ambari-server/src/main/java/org/apache/ambari/server/view/ViewClassLoader.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewClassLoader.java
b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewClassLoader.java
index f339b9a..c90bcaa 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewClassLoader.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewClassLoader.java
@@ -71,10 +71,16 @@ public class ViewClassLoader extends WebAppClassLoader {
 
     WebAppContext webAppContext = new WebAppContext();
 
+    // add ambari classes as system classes
+    webAppContext.addSystemClass("org.apache.ambari.server.");
+    webAppContext.addSystemClass("org.apache.ambari.view.");
+
     // add com.google.inject as system classes to allow for injection in view components
using the google annotation
     webAppContext.addSystemClass("com.google.inject.");
-    // add org.slf4j as system classes to avoid linkage errors
+
+    // add as system classes to avoid conflicts and linkage errors
     webAppContext.addSystemClass("org.slf4j.");
+    webAppContext.addSystemClass("com.sun.jersey.");
 
     // set the class loader settings from the configuration
     if (viewConfig != null) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/087d9003/ambari-server/src/test/java/org/apache/ambari/server/view/ViewClassLoaderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewClassLoaderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewClassLoaderTest.java
index ed701fd..f831989 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewClassLoaderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewClassLoaderTest.java
@@ -74,9 +74,12 @@ public class ViewClassLoaderTest {
     expect(parentClassLoader.getPackage("org.apache.ambari.server.view")).andReturn(null).anyTimes();
     expect(parentClassLoader.loadClass("java.lang.Object")).andReturn(parentClass).anyTimes();
     expect(parentClassLoader.loadClass("ParentClass")).andReturn(parentClass).once();
+    expect(parentClassLoader.loadClass("org.apache.ambari.server.controller.spi.ResourceProvider")).andReturn(parentClass).once();
+    expect(parentClassLoader.loadClass("org.apache.ambari.view.ViewContext")).andReturn(parentClass).once();
     expect(parentClassLoader.loadClass("javax.xml.parsers.SAXParserFactory")).andReturn(parentClass).once();
     expect(parentClassLoader.loadClass("com.google.inject.AbstractModule")).andReturn(parentClass).once();
     expect(parentClassLoader.loadClass("org.slf4j.LoggerFactory")).andReturn(parentClass).once();
+    expect(parentClassLoader.loadClass("com.sun.jersey.api.ConflictException")).andReturn(parentClass).once();
 
     replay(parentClassLoader, viewConfig);
 
@@ -87,33 +90,42 @@ public class ViewClassLoaderTest {
 
     ViewClassLoader classLoader = new ViewClassLoader(viewConfig, parentClassLoader, urls);
 
-    Class clazz = classLoader.loadClass("org.apache.ambari.server.view.ViewClassLoaderTest");
+    // should be loaded by parent loader
+    Class clazz = classLoader.loadClass("ParentClass");
 
     Assert.assertNotNull(clazz);
+    Assert.assertSame(parentClass, clazz);
 
-    clazz = classLoader.loadClass("ParentClass");
+    clazz = classLoader.loadClass("org.apache.ambari.server.controller.spi.ResourceProvider");
+
+    Assert.assertNotNull(clazz);
+    Assert.assertSame(parentClass, clazz);
+
+    clazz = classLoader.loadClass("org.apache.ambari.view.ViewContext");
 
     Assert.assertNotNull(clazz);
     Assert.assertSame(parentClass, clazz);
 
-    // should be loaded by parent loader
     clazz = classLoader.loadClass("javax.xml.parsers.SAXParserFactory");
 
     Assert.assertNotNull(clazz);
     Assert.assertSame(parentClass, clazz);
 
-    // should be loaded by parent loader
     clazz = classLoader.loadClass("com.google.inject.AbstractModule");
 
     Assert.assertNotNull(clazz);
     Assert.assertSame(parentClass, clazz);
 
-    // should be loaded by parent loader
     clazz = classLoader.loadClass("org.slf4j.LoggerFactory");
 
     Assert.assertNotNull(clazz);
     Assert.assertSame(parentClass, clazz);
 
+    clazz = classLoader.loadClass("com.sun.jersey.api.ConflictException");
+
+    Assert.assertNotNull(clazz);
+    Assert.assertSame(parentClass, clazz);
+
     verify(parentClassLoader, viewConfig);
   }
 


Mime
View raw message