You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/12/06 20:53:52 UTC
[1/9] tomee git commit: TOMEE-2253 - tomee.sh -version not working
properly with Java 11
Repository: tomee
Updated Branches:
refs/heads/tomee-7.0.x 35f131e12 -> 8f8394f4e
TOMEE-2253 - tomee.sh -version not working properly with Java 11
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/e5ad4b2d
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e5ad4b2d
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e5ad4b2d
Branch: refs/heads/tomee-7.0.x
Commit: e5ad4b2d769aafc93f8817b23ddc55dea9327b1b
Parents: 35f131e
Author: Daniel Cunha (soro) <da...@apache.org>
Authored: Tue Oct 23 17:29:37 2018 -0300
Committer: Daniel Cunha (soro) <da...@apache.org>
Committed: Tue Dec 4 14:06:18 2018 -0300
----------------------------------------------------------------------
.../java/org/apache/openejb/cli/Bootstrap.java | 44 +--
.../openejb/loader/BasicURLClassPath.java | 4 +-
tomee/apache-tomee/pom.xml | 12 +
.../src/test/java/org/apache/tomee/Test.java | 24 ++
.../java/org/apache/tomee/TestCommand1.java | 25 ++
.../java/org/apache/tomee/TestCommand2.java | 26 ++
.../test/java/org/apache/tomee/TomEECliIT.java | 272 +++++++++++++++++++
7 files changed, 385 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5ad4b2d/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
index 98f8741..0b9f26c 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
@@ -17,7 +17,7 @@
package org.apache.openejb.cli;
-import org.apache.openejb.loader.ClassPath;
+import org.apache.openejb.loader.BasicURLClassPath;
import org.apache.openejb.loader.IO;
import org.apache.openejb.loader.SystemClassPath;
import org.apache.openejb.util.JavaSecurityManagers;
@@ -28,8 +28,11 @@ import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URL;
+import java.net.URLClassLoader;
import java.util.StringTokenizer;
+import static org.apache.openejb.loader.JarLocation.jarLocation;
+
/**
* @version $Rev$ $Date$
*/
@@ -87,13 +90,14 @@ public class Bootstrap {
JavaSecurityManagers.setSystemProperty(prop, val);
}
- private static ClassLoader setupClasspath() {
+ private static URLClassLoader setupClasspath() {
final String base = JavaSecurityManagers.getSystemProperty(OPENEJB_BASE_PROPERTY_NAME, "");
final String home = JavaSecurityManagers.getSystemProperty("catalina.home", JavaSecurityManagers.getSystemProperty(OPENEJB_HOME_PROPERTY_NAME, base));
try {
final File lib = new File(home + File.separator + "lib");
- final ClassPath systemCP = new SystemClassPath();
- systemCP.getClassLoader();
+ final BasicURLClassPath.CustomizableURLClassLoader dynamicURLClassLoader =
+ new BasicURLClassPath.CustomizableURLClassLoader(ClassLoader.getSystemClassLoader());
+
File config = new File(base, "conf/catalina.properties");
if (!config.isFile()) {
config = new File(home, "conf/catalina.properties");
@@ -116,25 +120,25 @@ public class Bootstrap {
if (repository.endsWith("*.jar")) {
final File dir = new File(repository.substring(0, repository.length() - "*.jar".length()));
if (dir.isDirectory()) {
- systemCP.addJarsToPath(dir);
+ dynamicURLClassLoader.add(dir.toURI().toURL());
}
} else if (repository.endsWith(".jar")) {
final File file = new File(repository);
if (file.isFile()) {
- systemCP.addJarToPath(file.toURI().toURL());
+ dynamicURLClassLoader.add(file.toURI().toURL());
}
} else {
final File dir = new File(repository);
if (dir.isDirectory()) {
- systemCP.addJarToPath(dir.toURI().toURL());
+ dynamicURLClassLoader.add(dir.toURI().toURL());
}
}
}
} else {
- systemCP.addJarsToPath(lib);
- systemCP.addJarToPath(lib.toURI().toURL());
+ dynamicURLClassLoader.add(lib.toURI().toURL());
}
- return systemCP.getClassLoader();
+
+ return dynamicURLClassLoader;
} catch (final Exception e) {
System.err.println("Error setting up the classpath: " + e.getClass() + ": " + e.getMessage());
e.printStackTrace();
@@ -146,17 +150,18 @@ public class Bootstrap {
* Read commands from BASE_PATH (using XBean's ResourceFinder) and execute the one specified on the command line
*/
public static void main(final String[] args) throws Exception {
- setupHome(args);
- final ClassLoader loader = setupClasspath();
- if (loader != null) {
- Thread.currentThread().setContextClassLoader(loader);
- if (loader != ClassLoader.getSystemClassLoader()) {
- System.setProperty("openejb.classloader.first.disallow-system-loading", "true");
+ try (final URLClassLoader loader = setupClasspath()) {
+ setupHome(args);
+
+ if (loader != null) {
+ Thread.currentThread().setContextClassLoader(loader);
+ if (loader != ClassLoader.getSystemClassLoader()) {
+ System.setProperty("openejb.classloader.first.disallow-system-loading", "true");
+ }
}
- }
- final Class<?> clazz = (loader == null ? Bootstrap.class.getClassLoader() : loader).loadClass(OPENEJB_CLI_MAIN_CLASS_NAME);
- try {
+ final Class<?> clazz = (loader == null ? Bootstrap.class.getClassLoader() : loader).loadClass(OPENEJB_CLI_MAIN_CLASS_NAME);
+
final Object main = clazz.getConstructor().newInstance();
main.getClass().getMethod("main", String[].class).invoke(main, new Object[]{args});
} catch (final InvocationTargetException e) {
@@ -173,5 +178,4 @@ public class Bootstrap {
throw new IllegalStateException(cause);
}
}
-
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5ad4b2d/container/openejb-loader/src/main/java/org/apache/openejb/loader/BasicURLClassPath.java
----------------------------------------------------------------------
diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/BasicURLClassPath.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/BasicURLClassPath.java
index d459664..e8acf96 100644
--- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/BasicURLClassPath.java
+++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/BasicURLClassPath.java
@@ -142,12 +142,12 @@ public abstract class BasicURLClassPath implements ClassPath {
return ucpField;
}
- protected static class CustomizableURLClassLoader extends URLClassLoader {
+ public static class CustomizableURLClassLoader extends URLClassLoader {
static {
ClassLoader.registerAsParallelCapable();
}
- protected CustomizableURLClassLoader(final ClassLoader parent) {
+ public CustomizableURLClassLoader(final ClassLoader parent) {
super(new URL[0], parent);
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5ad4b2d/tomee/apache-tomee/pom.xml
----------------------------------------------------------------------
diff --git a/tomee/apache-tomee/pom.xml b/tomee/apache-tomee/pom.xml
index 45919d9..da7de9e 100644
--- a/tomee/apache-tomee/pom.xml
+++ b/tomee/apache-tomee/pom.xml
@@ -49,6 +49,18 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-api</artifactId>
+ <version>1.2.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.shrinkwrap</groupId>
+ <artifactId>shrinkwrap-impl-base</artifactId>
+ <version>1.2.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5ad4b2d/tomee/apache-tomee/src/test/java/org/apache/tomee/Test.java
----------------------------------------------------------------------
diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/Test.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/Test.java
new file mode 100644
index 0000000..c788582
--- /dev/null
+++ b/tomee/apache-tomee/src/test/java/org/apache/tomee/Test.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomee;
+
+public class Test {
+
+ public static void main(String[] args) {
+ System.out.println("TESTING CLASSLOADER!!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5ad4b2d/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand1.java
----------------------------------------------------------------------
diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand1.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand1.java
new file mode 100644
index 0000000..1fe2af7
--- /dev/null
+++ b/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand1.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomee;
+
+public class TestCommand1 {
+
+ public static void main(String[] args) {
+ final Test test = new Test();
+ test.main(args);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5ad4b2d/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand2.java
----------------------------------------------------------------------
diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand2.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand2.java
new file mode 100644
index 0000000..b66bedd
--- /dev/null
+++ b/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand2.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomee;
+
+import org.apache.openejb.cli.Bootstrap;
+
+public class TestCommand2 {
+
+ public static void main(String[] args) throws Exception {
+ new Bootstrap().main(new String[]{"classloadertest"});
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/e5ad4b2d/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
----------------------------------------------------------------------
diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
new file mode 100644
index 0000000..92fe6f4
--- /dev/null
+++ b/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
@@ -0,0 +1,272 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomee;
+
+import org.apache.openejb.loader.IO;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.nio.file.Files;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class TomEECliIT {
+
+ @Test
+ public void testTomEECliWithJar() throws IOException, InterruptedException {
+ final File file = Files.createTempDirectory("tomee-test").toFile();
+ final File jar = new File(file.getAbsolutePath() + "/test.jar");
+
+ final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar")
+ .addClasses(org.apache.tomee.Test.class)
+ .add(new StringAsset("main.class = org.apache.tomee.Test\n" +
+ "name = classloadertest\n" +
+ "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest");
+
+ archive.as(ZipExporter.class).exportTo(jar);
+
+ File work = new File("target/webprofile-work-dir/").getAbsoluteFile();
+ if (!work.exists()) {
+ work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile();
+ }
+
+ final File[] files = work.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(final File pathname) {
+ return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-");
+ }
+ });
+
+ final File tomee = (null != files ? files[0] : null);
+ if (tomee == null) {
+ fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources");
+ }
+
+ final ProcessBuilder builder = new ProcessBuilder()
+ .command("java", "-cp", jar.getAbsolutePath() + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "openejb-core-8.0.0-SNAPSHOT.jar" + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "commons-cli-1.2.jar",
+ "org.apache.openejb.cli.Bootstrap", "classloadertest");
+
+ final Process start = builder.start();
+ start.waitFor();
+
+ final String result = IO.slurp(start.getInputStream());
+ assertTrue(result.contains("TESTING CLASSLOADER!!"));
+ }
+
+ @Test
+ public void testTomEECliWithJarDir() throws IOException, InterruptedException {
+ final File file = Files.createTempDirectory("tomee-test").toFile();
+ final File jar = new File(file.getAbsolutePath() + "/test.jar");
+
+ final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar")
+ .addClasses(org.apache.tomee.Test.class)
+ .add(new StringAsset("main.class = org.apache.tomee.Test\n" +
+ "name = classloadertest\n" +
+ "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest");
+
+ archive.as(ZipExporter.class).exportTo(jar);
+
+ File work = new File("target/webprofile-work-dir/").getAbsoluteFile();
+ if (!work.exists()) {
+ work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile();
+ }
+
+ final File[] files = work.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(final File pathname) {
+ return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-");
+ }
+ });
+
+ final File tomee = (null != files ? files[0] : null);
+ if (tomee == null) {
+ fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources");
+ }
+
+ final ProcessBuilder builder = new ProcessBuilder()
+ .command("java", "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "*",
+ "org.apache.openejb.cli.Bootstrap", "classloadertest");
+
+ final Process start = builder.start();
+ start.waitFor();
+
+ final String result = IO.slurp(start.getInputStream());
+ assertTrue(result.contains("TESTING CLASSLOADER!!"));
+ }
+
+ @Test
+ public void testTomEECliWithJarCallingAnotherMain() throws IOException, InterruptedException {
+ final File file = Files.createTempDirectory("tomee-test").toFile();
+ final File jar = new File(file.getAbsolutePath() + "/test.jar");
+ final File jar2 = new File(file.getAbsolutePath() + "/test2.jar");
+
+ final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar")
+ .addClasses(org.apache.tomee.Test.class)
+ .add(new StringAsset("main.class = org.apache.tomee.Test\n" +
+ "name = classloadertest\n" +
+ "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest");
+
+ final JavaArchive archive2 = ShrinkWrap.create(JavaArchive.class, "test2.jar")
+ .addClasses(org.apache.tomee.TestCommand1.class)
+ .add(new StringAsset("main.class = org.apache.tomee.TestCommand1\n" +
+ "name = classloadertest2\n" +
+ "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest2");
+
+ archive.as(ZipExporter.class).exportTo(jar);
+ archive2.as(ZipExporter.class).exportTo(jar2);
+
+ File work = new File("target/webprofile-work-dir/").getAbsoluteFile();
+ if (!work.exists()) {
+ work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile();
+ }
+
+ final File[] files = work.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(final File pathname) {
+ return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-");
+ }
+ });
+
+ final File tomee = (null != files ? files[0] : null);
+ if (tomee == null) {
+ fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources");
+ }
+
+ final ProcessBuilder builder = new ProcessBuilder()
+ .command("java", "-cp", jar.getAbsolutePath() + File.pathSeparator +
+ jar2.getAbsolutePath() + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "openejb-core-8.0.0-SNAPSHOT.jar" + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "commons-cli-1.2.jar",
+ "org.apache.openejb.cli.Bootstrap", "classloadertest2");
+
+ final Process start = builder.start();
+ start.waitFor();
+
+ final String result = IO.slurp(start.getInputStream());
+ assertTrue(result.contains("TESTING CLASSLOADER!!"));
+ }
+
+ @Test
+ public void testTomEECliWithJarDirCallingAnotherMain() throws IOException, InterruptedException {
+ final File file = Files.createTempDirectory("tomee-test").toFile();
+ final File jar = new File(file.getAbsolutePath() + "/test.jar");
+ final File jar2 = new File(file.getAbsolutePath() + "/test2.jar");
+
+ final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar")
+ .addClasses(org.apache.tomee.Test.class)
+ .add(new StringAsset("main.class = org.apache.tomee.Test\n" +
+ "name = classloadertest\n" +
+ "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest");
+
+ final JavaArchive archive2 = ShrinkWrap.create(JavaArchive.class, "test2.jar")
+ .addClasses(org.apache.tomee.TestCommand1.class)
+ .add(new StringAsset("main.class = org.apache.tomee.TestCommand1\n" +
+ "name = classloadertest2\n" +
+ "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest2");
+
+ archive.as(ZipExporter.class).exportTo(jar);
+ archive2.as(ZipExporter.class).exportTo(jar2);
+
+ File work = new File("target/webprofile-work-dir/").getAbsoluteFile();
+ if (!work.exists()) {
+ work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile();
+ }
+
+ final File[] files = work.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(final File pathname) {
+ return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-");
+ }
+ });
+
+ final File tomee = (null != files ? files[0] : null);
+ if (tomee == null) {
+ fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources");
+ }
+
+ final ProcessBuilder builder = new ProcessBuilder()
+ .command("java", "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "*",
+ "org.apache.openejb.cli.Bootstrap", "classloadertest2");
+
+ final Process start = builder.start();
+ start.waitFor();
+
+ final String result = IO.slurp(start.getInputStream());
+ assertTrue(result.contains("TESTING CLASSLOADER!!"));
+ }
+
+ @Test
+ public void testDelegatesToCLIMain() throws IOException, InterruptedException {
+ final File file = Files.createTempDirectory("tomee-test").toFile();
+ final File jar = new File(file.getAbsolutePath() + "/test.jar");
+ final File jar2 = new File(file.getAbsolutePath() + "/test2.jar");
+
+ final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar")
+ .addClasses(org.apache.tomee.Test.class)
+ .add(new StringAsset("main.class = org.apache.tomee.Test\n" +
+ "name = classloadertest\n" +
+ "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest");
+
+ final JavaArchive archive2 = ShrinkWrap.create(JavaArchive.class, "test2.jar")
+ .addClasses(org.apache.tomee.TestCommand2.class)
+ .add(new StringAsset("main.class = org.apache.tomee.TestCommand2\n" +
+ "name = classloadertest2\n" +
+ "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest2");
+
+ archive.as(ZipExporter.class).exportTo(jar);
+ archive2.as(ZipExporter.class).exportTo(jar2);
+
+ File work = new File("target/webprofile-work-dir/").getAbsoluteFile();
+ if (!work.exists()) {
+ work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile();
+ }
+
+ final File[] files = work.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(final File pathname) {
+ return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-");
+ }
+ });
+
+ final File tomee = (null != files ? files[0] : null);
+ if (tomee == null) {
+ fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources");
+ }
+
+ final ProcessBuilder builder = new ProcessBuilder()
+ .command("java", "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "*",
+ "org.apache.openejb.cli.Bootstrap", "classloadertest2");
+
+ final Process start = builder.start();
+ start.waitFor();
+
+ final String result = IO.slurp(start.getInputStream());
+ assertTrue(result.contains("TESTING CLASSLOADER!!"));
+ }
+}
[3/9] tomee git commit: Test classloader change
Posted by jg...@apache.org.
Test classloader change
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/232c2463
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/232c2463
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/232c2463
Branch: refs/heads/tomee-7.0.x
Commit: 232c246338a8b2b49c81e68b0eb822b23a361d03
Parents: 7274095
Author: Daniel Cunha (soro) <da...@apache.org>
Authored: Mon Nov 26 10:07:02 2018 -0300
Committer: Daniel Cunha (soro) <da...@apache.org>
Committed: Tue Dec 4 14:06:50 2018 -0300
----------------------------------------------------------------------
.../src/test/java/org/apache/tomee/TomEECliIT.java | 9 +++++++++
1 file changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/232c2463/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
----------------------------------------------------------------------
diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
index 92fe6f4..f33f53b 100644
--- a/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
+++ b/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
@@ -16,6 +16,7 @@
*/
package org.apache.tomee;
+import org.apache.openejb.cli.Bootstrap;
import org.apache.openejb.loader.IO;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
@@ -28,6 +29,7 @@ import java.io.FileFilter;
import java.io.IOException;
import java.nio.file.Files;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -269,4 +271,11 @@ public class TomEECliIT {
final String result = IO.slurp(start.getInputStream());
assertTrue(result.contains("TESTING CLASSLOADER!!"));
}
+
+ @Test
+ public void testIfClassloaderNotChange() throws Exception {
+ final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+ new Bootstrap().main(new String[]{"cipher"});
+ assertEquals(originalClassLoader, Thread.currentThread().getContextClassLoader());
+ }
}
[8/9] tomee git commit: TOMEE-2322 restore previous classloader at
the end
Posted by jg...@apache.org.
TOMEE-2322 restore previous classloader at the end
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3bffc921
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3bffc921
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3bffc921
Branch: refs/heads/tomee-7.0.x
Commit: 3bffc921284874c13012a62a099feaab4a222a37
Parents: c56e301
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 15:09:10 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:43:48 2018 +0000
----------------------------------------------------------------------
.../src/main/java/org/apache/openejb/cli/Bootstrap.java | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/3bffc921/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
index b5508a3..95e879e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
@@ -175,10 +175,12 @@ public class Bootstrap {
* Read commands from BASE_PATH (using XBean's ResourceFinder) and execute the one specified on the command line
*/
public static void main(final String[] args) throws Exception {
+ ClassLoader cl = null;
setupHome(args);
try (final URLClassLoader loader = setupClasspath()) {
if (loader != null) {
+ cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(loader);
if (loader != ClassLoader.getSystemClassLoader()) {
System.setProperty("openejb.classloader.first.disallow-system-loading", "true");
@@ -200,6 +202,10 @@ public class Bootstrap {
throw Error.class.cast(cause);
}
throw new IllegalStateException(cause);
+ } finally {
+ if (cl != null) {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
}
}
}
[4/9] tomee git commit: No needed classpath override
Posted by jg...@apache.org.
No needed classpath override
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/71702dc6
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/71702dc6
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/71702dc6
Branch: refs/heads/tomee-7.0.x
Commit: 71702dc6bafb715b7a9f8bd8e36f9d33285a4af1
Parents: 232c246
Author: Daniel Cunha (soro) <da...@apache.org>
Authored: Tue Dec 4 07:06:55 2018 -0300
Committer: Daniel Cunha (soro) <da...@apache.org>
Committed: Tue Dec 4 14:06:58 2018 -0300
----------------------------------------------------------------------
.../src/main/java/org/apache/openejb/cli/Bootstrap.java | 7 -------
1 file changed, 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/71702dc6/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
index 0b9f26c..2bb4a01 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
@@ -153,13 +153,6 @@ public class Bootstrap {
try (final URLClassLoader loader = setupClasspath()) {
setupHome(args);
- if (loader != null) {
- Thread.currentThread().setContextClassLoader(loader);
- if (loader != ClassLoader.getSystemClassLoader()) {
- System.setProperty("openejb.classloader.first.disallow-system-loading", "true");
- }
- }
-
final Class<?> clazz = (loader == null ? Bootstrap.class.getClassLoader() : loader).loadClass(OPENEJB_CLI_MAIN_CLASS_NAME);
final Object main = clazz.getConstructor().newInstance();
[7/9] tomee git commit: TOME-2322 removing debug
Posted by jg...@apache.org.
TOME-2322 removing debug
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/c56e3017
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/c56e3017
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/c56e3017
Branch: refs/heads/tomee-7.0.x
Commit: c56e3017771f17465f14c4c486049d9ece885d3d
Parents: c03eebc
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 14:26:31 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:43:41 2018 +0000
----------------------------------------------------------------------
.../openejb/itest/failover/RandomConnectionStrategyTest.java | 2 --
1 file changed, 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/c56e3017/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
----------------------------------------------------------------------
diff --git a/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java b/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
index c347285..401eabc 100644
--- a/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
+++ b/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
@@ -91,8 +91,6 @@ public class RandomConnectionStrategyTest {
root.ignoreOut();
root.setProperty("name", name);
root.setProperty("openejb.extract.configuration", "false");
-// root.setDebug(true);
-// root.setDebugPort(5006);
final StandaloneServer.ServerService multipoint = root.getServerService("multipoint");
multipoint.setBind("localhost");
[9/9] tomee git commit: TOMEE-2322 add missing jar
Posted by jg...@apache.org.
TOMEE-2322 add missing jar
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/8f8394f4
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/8f8394f4
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/8f8394f4
Branch: refs/heads/tomee-7.0.x
Commit: 8f8394f4e9763e21eee312acdfb1a84577c253c3
Parents: 3bffc92
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 15:27:50 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:43:55 2018 +0000
----------------------------------------------------------------------
.../src/test/java/org/apache/tomee/TomEECliIT.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/8f8394f4/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
----------------------------------------------------------------------
diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
index f33f53b..bff58c4 100644
--- a/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
+++ b/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
@@ -68,7 +68,8 @@ public class TomEECliIT {
final ProcessBuilder builder = new ProcessBuilder()
.command("java", "-cp", jar.getAbsolutePath() + File.pathSeparator +
tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "openejb-core-8.0.0-SNAPSHOT.jar" + File.pathSeparator +
- tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "commons-cli-1.2.jar",
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "commons-cli-1.2.jar" + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "commons-lang3-3.8.1.jar",
"org.apache.openejb.cli.Bootstrap", "classloadertest");
final Process start = builder.start();
@@ -162,7 +163,8 @@ public class TomEECliIT {
.command("java", "-cp", jar.getAbsolutePath() + File.pathSeparator +
jar2.getAbsolutePath() + File.pathSeparator +
tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "openejb-core-8.0.0-SNAPSHOT.jar" + File.pathSeparator +
- tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "commons-cli-1.2.jar",
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "commons-cli-1.2.jar" + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "commons-lang3-3.8.1.jar",
"org.apache.openejb.cli.Bootstrap", "classloadertest2");
final Process start = builder.start();
[2/9] tomee git commit: Added test to call cli command from jaxrs
Posted by jg...@apache.org.
Added test to call cli command from jaxrs
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/72740957
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/72740957
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/72740957
Branch: refs/heads/tomee-7.0.x
Commit: 72740957235e31acfdc7672136da83035d23bd05
Parents: e5ad4b2
Author: Daniel Cunha (soro) <da...@apache.org>
Authored: Tue Nov 20 15:56:36 2018 -0300
Committer: Daniel Cunha (soro) <da...@apache.org>
Committed: Tue Dec 4 14:06:41 2018 -0300
----------------------------------------------------------------------
.../server/cxf/rs/TestCLIFromJaxRSTest.java | 70 ++++++++++++++++++++
1 file changed, 70 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/72740957/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/TestCLIFromJaxRSTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/TestCLIFromJaxRSTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/TestCLIFromJaxRSTest.java
new file mode 100644
index 0000000..bd00b23
--- /dev/null
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/TestCLIFromJaxRSTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.server.cxf.rs;
+
+import org.apache.openejb.cli.Bootstrap;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.RandomPort;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.MediaType;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@EnableServices("jaxrs")
+@Classes(innerClassesAsBean = true)
+@RunWith(ApplicationComposer.class)
+public class TestCLIFromJaxRSTest {
+ @RandomPort("http")
+ private URL base;
+
+ @Test
+ public void mapping() {
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(out));
+
+
+ assertEquals(
+ "nice",
+ ClientBuilder.newClient().target(base.toExternalForm()).path("openejb/endpoint").request(MediaType.TEXT_PLAIN)
+ .get(String.class));
+
+ assertEquals("BeAUgMQKg6SzYbDM5vtzsQ==\n", out.toString());
+ }
+
+ @Path("endpoint")
+ public static class ValidateMe {
+ @GET
+ public String get() {
+ try {
+ new Bootstrap().main(new String[]{"cipher", "my-password"});
+ } catch (Exception e) {
+ return "fail";
+ }
+ return "nice";
+ }
+ }
+}
[5/9] tomee git commit: TOMEE-2322 WIP attempting to fix classpath
setup for iTests
Posted by jg...@apache.org.
TOMEE-2322 WIP attempting to fix classpath setup for iTests
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5e86f90d
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5e86f90d
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5e86f90d
Branch: refs/heads/tomee-7.0.x
Commit: 5e86f90dd3df5c2906d49bb2560ad3dc222cb39d
Parents: 71702dc
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 12:40:03 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:43:25 2018 +0000
----------------------------------------------------------------------
.../java/org/apache/openejb/cli/Bootstrap.java | 27 +++++++++++++++++++-
.../failover/RandomConnectionStrategyTest.java | 6 +++--
2 files changed, 30 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/5e86f90d/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
index 2bb4a01..88dacad 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
@@ -25,7 +25,9 @@ import org.apache.openejb.util.PropertyPlaceHolderHelper;
import org.apache.openejb.util.URLs;
import java.io.File;
+import java.io.FilenameFilter;
import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
@@ -120,6 +122,7 @@ public class Bootstrap {
if (repository.endsWith("*.jar")) {
final File dir = new File(repository.substring(0, repository.length() - "*.jar".length()));
if (dir.isDirectory()) {
+ addJarsToPath(dynamicURLClassLoader, dir);
dynamicURLClassLoader.add(dir.toURI().toURL());
}
} else if (repository.endsWith(".jar")) {
@@ -135,6 +138,7 @@ public class Bootstrap {
}
}
} else {
+ addJarsToPath(dynamicURLClassLoader, lib);
dynamicURLClassLoader.add(lib.toURI().toURL());
}
@@ -146,12 +150,33 @@ public class Bootstrap {
return null;
}
+ private static void addJarsToPath(final BasicURLClassPath.CustomizableURLClassLoader classLoader, final File folder) throws MalformedURLException {
+ if (classLoader == null || folder == null) {
+ return;
+ }
+
+ if (! folder.exists()) {
+ return;
+ }
+
+ final File[] jarFiles = folder.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar");
+ }
+ });
+
+ for (final File jarFile : jarFiles) {
+ classLoader.add(jarFile.toURI().toURL());
+ }
+ }
+
/**
* Read commands from BASE_PATH (using XBean's ResourceFinder) and execute the one specified on the command line
*/
public static void main(final String[] args) throws Exception {
+ setupHome(args);
try (final URLClassLoader loader = setupClasspath()) {
- setupHome(args);
final Class<?> clazz = (loader == null ? Bootstrap.class.getClassLoader() : loader).loadClass(OPENEJB_CLI_MAIN_CLASS_NAME);
http://git-wip-us.apache.org/repos/asf/tomee/blob/5e86f90d/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
----------------------------------------------------------------------
diff --git a/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java b/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
index 401eabc..2f82aae 100644
--- a/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
+++ b/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
@@ -88,9 +88,11 @@ public class RandomConnectionStrategyTest {
root = new StandaloneServer(home, home);
root.killOnExit();
root.getJvmOpts().add("-Dopenejb.classloader.forced-load=org.apache.openejb");
- root.ignoreOut();
+// root.ignoreOut();
root.setProperty("name", name);
root.setProperty("openejb.extract.configuration", "false");
+ root.setDebug(true);
+ root.setDebugPort(5006);
final StandaloneServer.ServerService multipoint = root.getServerService("multipoint");
multipoint.setBind("localhost");
@@ -116,7 +118,7 @@ public class RandomConnectionStrategyTest {
final StandaloneServer server = new StandaloneServer(home, home);
server.killOnExit();
- server.ignoreOut();
+// server.ignoreOut();
server.setProperty("name", name);
server.setProperty("openejb.extract.configuration", "false");
server.getJvmOpts().add("-Dopenejb.classloader.forced-load=org.apache.openejb");
[6/9] tomee git commit: TOMEE-2322 Still WIP,
but these failover tests pass now
Posted by jg...@apache.org.
TOMEE-2322 Still WIP, but these failover tests pass now
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/c03eebcc
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/c03eebcc
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/c03eebcc
Branch: refs/heads/tomee-7.0.x
Commit: c03eebcc2a5925e9126872c876532b3761ea6c04
Parents: 5e86f90
Author: Jonathan Gallimore <jg...@tomitribe.com>
Authored: Thu Dec 6 14:23:34 2018 +0000
Committer: Jonathan Gallimore <jg...@tomitribe.com>
Committed: Thu Dec 6 20:43:34 2018 +0000
----------------------------------------------------------------------
.../src/main/java/org/apache/openejb/cli/Bootstrap.java | 8 +++++++-
.../openejb/itest/failover/RandomConnectionStrategyTest.java | 8 ++++----
2 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/c03eebcc/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
index 88dacad..b5508a3 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cli/Bootstrap.java
@@ -178,8 +178,14 @@ public class Bootstrap {
setupHome(args);
try (final URLClassLoader loader = setupClasspath()) {
- final Class<?> clazz = (loader == null ? Bootstrap.class.getClassLoader() : loader).loadClass(OPENEJB_CLI_MAIN_CLASS_NAME);
+ if (loader != null) {
+ Thread.currentThread().setContextClassLoader(loader);
+ if (loader != ClassLoader.getSystemClassLoader()) {
+ System.setProperty("openejb.classloader.first.disallow-system-loading", "true");
+ }
+ }
+ final Class<?> clazz = (loader == null ? Bootstrap.class.getClassLoader() : loader).loadClass(OPENEJB_CLI_MAIN_CLASS_NAME);
final Object main = clazz.getConstructor().newInstance();
main.getClass().getMethod("main", String[].class).invoke(main, new Object[]{args});
} catch (final InvocationTargetException e) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/c03eebcc/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
----------------------------------------------------------------------
diff --git a/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java b/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
index 2f82aae..c347285 100644
--- a/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
+++ b/itests/failover/src/test/java/org/apache/openejb/itest/failover/RandomConnectionStrategyTest.java
@@ -88,11 +88,11 @@ public class RandomConnectionStrategyTest {
root = new StandaloneServer(home, home);
root.killOnExit();
root.getJvmOpts().add("-Dopenejb.classloader.forced-load=org.apache.openejb");
-// root.ignoreOut();
+ root.ignoreOut();
root.setProperty("name", name);
root.setProperty("openejb.extract.configuration", "false");
- root.setDebug(true);
- root.setDebugPort(5006);
+// root.setDebug(true);
+// root.setDebugPort(5006);
final StandaloneServer.ServerService multipoint = root.getServerService("multipoint");
multipoint.setBind("localhost");
@@ -118,7 +118,7 @@ public class RandomConnectionStrategyTest {
final StandaloneServer server = new StandaloneServer(home, home);
server.killOnExit();
-// server.ignoreOut();
+ server.ignoreOut();
server.setProperty("name", name);
server.setProperty("openejb.extract.configuration", "false");
server.getJvmOpts().add("-Dopenejb.classloader.forced-load=org.apache.openejb");