Juan Hernandez has uploaded a new change for review.

Change subject: restapi: Use context classloader from YAML
......................................................................

restapi: Use context classloader from YAML

The YAML library that we use to build load the RSDL metadata assumes
that it can load classes using from its own class loader, and this is
incorrect, specially now the the library is loaded from a JBoss module.
The correct way to load classes is to use the context class loader, so
it will work regardless of where in the application the classes are
located.

Backported from master commit 2fd239a065877c20ea580926e28d6603f6fe1d75.

Change-Id: I78cd79e81bfb44a9c7d0d034d734eb307cde5b3a
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/rsdl/RsdlBuilder.java
M backend/manager/modules/restapi/webapp/pom.xml
A backend/manager/modules/restapi/webapp/src/main/resources/META-INF/MANIFEST.MF
3 files changed, 13 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/79/12779/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/rsdl/RsdlBuilder.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/rsdl/RsdlBuilder.java
index 7e21de4..2917f47 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/rsdl/RsdlBuilder.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/rsdl/RsdlBuilder.java
@@ -59,6 +59,8 @@
 import org.ovirt.engine.core.utils.log.Log;
 import org.ovirt.engine.core.utils.log.LogFactory;
 import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor;
 
 public class RsdlBuilder {
 
@@ -95,7 +97,8 @@
         try {
              InputStream stream = FileUtils.get(RESOURCES_PACKAGE, 
PARAMS_METADATA);
              if (stream != null) {
-                 Object result = new Yaml().load(stream);
+                 Constructor constructor = new 
CustomClassLoaderConstructor(Thread.currentThread().getContextClassLoader());
+                 Object result = new Yaml(constructor).load(stream);
                  for (Action action : ((MetaData)result).getActions()) {
                      parametersMetaData.put(action.getName(), action);
                  }
diff --git a/backend/manager/modules/restapi/webapp/pom.xml 
b/backend/manager/modules/restapi/webapp/pom.xml
index 49835cf..daa2504 100644
--- a/backend/manager/modules/restapi/webapp/pom.xml
+++ b/backend/manager/modules/restapi/webapp/pom.xml
@@ -34,6 +34,13 @@
         <artifactId>maven-war-plugin</artifactId>
         <configuration>
 
+          <!-- Add a the manifest that contains the required
+               dependencies for JBoss modules: -->
+          <archive>
+            <addMavenDescriptor>false</addMavenDescriptor>
+            
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
+          </archive>
+
           <!-- Don't include any of the external dependencies, as they are
                already included as references in the manifest (note that the
                web.xml file is included regardless of this configuration): -->
diff --git 
a/backend/manager/modules/restapi/webapp/src/main/resources/META-INF/MANIFEST.MF
 
b/backend/manager/modules/restapi/webapp/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..24d1ddb
--- /dev/null
+++ 
b/backend/manager/modules/restapi/webapp/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+Dependencies: org.yaml.snakeyaml


--
To view, visit http://gerrit.ovirt.org/12779
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I78cd79e81bfb44a9c7d0d034d734eb307cde5b3a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to