Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Hauge2013-05-31 17:33:40 -0400
committerNeil Hauge2013-05-31 17:33:40 -0400
commit87f1ce663b4c9c3966f559d315b7c7c307195530 (patch)
tree7f5575414f6776f6d247cd1020e38e4609e17b81
parentc2d52733c07931591ca870a76b4fa14983c40a01 (diff)
downloadwebtools.dali-87f1ce663b4c9c3966f559d315b7c7c307195530.tar.gz
webtools.dali-87f1ce663b4c9c3966f559d315b7c7c307195530.tar.xz
webtools.dali-87f1ce663b4c9c3966f559d315b7c7c307195530.zip
394616 - Fix classloader issue caused by m2e bug by setting TCCL
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.gen/src/org/eclipse/jpt/jpa/gen/internal/PackageGenerator.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.gen/src/org/eclipse/jpt/jpa/gen/internal/PackageGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.gen/src/org/eclipse/jpt/jpa/gen/internal/PackageGenerator.java
index 629e411bfd..77295bdabd 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.gen/src/org/eclipse/jpt/jpa/gen/internal/PackageGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.gen/src/org/eclipse/jpt/jpa/gen/internal/PackageGenerator.java
@@ -287,7 +287,15 @@ public class PackageGenerator {
vep.setProperty("file.resource.loader.path", templateDirPath); //$NON-NLS-1$
vep.setProperty( JdkLogChute.RUNTIME_LOG_JDK_LOGGER, LOGGER_NAME );
VelocityEngine ve = new VelocityEngine();
- ve.init(vep);
+ //Massage TCCL to deal with bug in m2e - see 396554
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(ve.getClass().getClassLoader());
+ try {
+ ve.init(vep);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+
sm.worked(2);
generateJavaFile(table, javaFile, ve, "main.java.vm", true/*isDomainClass*/, sm.newChild(6)); //$NON-NLS-1$
@@ -417,7 +425,14 @@ public class PackageGenerator {
vep.setProperty("file.resource.loader.path", templateDirPath); //$NON-NLS-1$
vep.setProperty( JdkLogChute.RUNTIME_LOG_JDK_LOGGER, LOGGER_NAME );
VelocityEngine ve = new VelocityEngine();
- ve.init(vep);
+ //Massage TCCL to deal with bug in m2e - 396554
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(ve.getClass().getClassLoader());
+ try {
+ ve.init(vep);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
StringBuilder xmlFileContents = new StringBuilder();
xmlFileContents.append(generateXmlHeaderFooter(ve, "header.vm")); //$NON-NLS-1$

Back to the top