TOMEE-1645 TOMEE-1646 use common.loader for tomee.sh and dont swallow exception for Cipher command
Conflicts: container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java tomee/apache-tomee/src/main/resources/tomee.sh Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/2879bb00 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/2879bb00 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/2879bb00 Branch: refs/heads/tomee-1.7.x Commit: 2879bb00e0bc67fccf0b4c198a9b6e8ac49a20b9 Parents: 4b3a427 Author: Romain Manni-Bucau <rmann...@gmail.com> Authored: Sat Oct 24 21:07:14 2015 +0200 Committer: Jean-Louis Monteiro <jlmonte...@tomitribe.com> Committed: Sun Apr 10 19:54:13 2016 -0700 ---------------------------------------------------------------------- .../java/org/apache/openejb/cli/Bootstrap.java | 49 ++++++++++++++++++-- .../java/org/apache/openejb/config/Cipher.java | 6 +-- tomee/apache-tomee/src/main/resources/tomee.sh | 31 ++++++------- 3 files changed, 62 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/2879bb00/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 e1ca146..4330f90 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,12 +17,15 @@ package org.apache.openejb.cli; +import org.apache.openejb.loader.IO; import org.apache.openejb.loader.SystemClassPath; +import org.apache.openejb.util.PropertyPlaceHolderHelper; import org.apache.openejb.util.URLs; import java.io.File; import java.net.URI; import java.net.URL; +import java.util.StringTokenizer; /** * @version $Rev$ $Date$ @@ -82,11 +85,51 @@ public class Bootstrap { } private static void setupClasspath() { + final String base = System.getProperty(OPENEJB_BASE_PROPERTY_NAME, ""); + final String home = System.getProperty("catalina.home", System.getProperty(OPENEJB_HOME_PROPERTY_NAME, base)); try { - final File lib = new File(System.getProperty(OPENEJB_HOME_PROPERTY_NAME) + File.separator + "lib"); + final File lib = new File(home + File.separator + "lib"); final SystemClassPath systemCP = new SystemClassPath(); - systemCP.addJarsToPath(lib); - systemCP.addJarToPath(lib.toURI().toURL()); // add dir too like Tomcat/TomEE + File config = new File(base, "conf/catalina.properties"); + if (!config.isFile()) { + config = new File(home, "conf/catalina.properties"); + } + if (config.isFile()) { // like org.apache.catalina.startup.Bootstrap.createClassLoader() + String val = IO.readProperties(config).getProperty("common.loader", lib.getAbsolutePath()); + val = PropertyPlaceHolderHelper.simpleValue(val.replace("${catalina.", "${openejb.")); // base/home + + final StringTokenizer tokenizer = new StringTokenizer(val, ","); + while (tokenizer.hasMoreElements()) { + String repository = tokenizer.nextToken().trim(); + if (repository.isEmpty()) { + continue; + } + + if (repository.startsWith("\"") && repository.endsWith("\"")) { + repository = repository.substring(1, repository.length() - 1); + } + + if (repository.endsWith("*.jar")) { + final File dir = new File(repository.substring(0, repository.length() - "*.jar".length())); + if (dir.isDirectory()) { + systemCP.addJarsToPath(dir); + } + } else if (repository.endsWith(".jar")) { + final File file = new File(repository); + if (file.isFile()) { + systemCP.addJarToPath(file.toURI().toURL()); + } + } else { + final File dir = new File(repository); + if (dir.isDirectory()) { + systemCP.addJarToPath(dir.toURI().toURL()); + } + } + } + } else { + systemCP.addJarsToPath(lib); + systemCP.addJarToPath(lib.toURI().toURL()); + } } catch (final Exception e) { System.err.println("Error setting up the classpath: " + e.getClass() + ": " + e.getMessage()); e.printStackTrace(); http://git-wip-us.apache.org/repos/asf/tomee/blob/2879bb00/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java b/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java index ae88030..41d4d18 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/Cipher.java @@ -26,6 +26,7 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; import org.apache.openejb.cipher.PasswordCipher; +import org.apache.openejb.cipher.PasswordCipherException; import org.apache.openejb.cipher.PasswordCipherFactory; import org.apache.openejb.cli.SystemExitException; import org.apache.openejb.util.Join; @@ -41,7 +42,7 @@ import java.util.Map; */ public class Cipher { - private static Messages messages = new Messages(Cipher.class); + private static final Messages messages = new Messages(Cipher.class); public static void main(final String[] args) throws SystemExitException { @@ -93,14 +94,13 @@ public class Cipher { System.out.println(new String(cipher.encrypt(plainPassword))); } - } catch (final RuntimeException e) { + } catch (final PasswordCipherException e) { System.out.println("Could not load password cipher implementation class. Check your classpath."); availableCiphers(); throw new SystemExitException(-1); } - } private static void availableCiphers() { http://git-wip-us.apache.org/repos/asf/tomee/blob/2879bb00/tomee/apache-tomee/src/main/resources/tomee.sh ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/resources/tomee.sh b/tomee/apache-tomee/src/main/resources/tomee.sh index 3ea5279..2acc688 100644 --- a/tomee/apache-tomee/src/main/resources/tomee.sh +++ b/tomee/apache-tomee/src/main/resources/tomee.sh @@ -15,8 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -version="${version.openejb}" -port=8080 +version="${tomee.version}" DEBUG= #DEBUG="-Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005" @@ -32,19 +31,11 @@ esac if $cygwin; then [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$JRE_HOME" ] && JRE_HOME=`cygpath --unix "$JRE_HOME"` - [ -n "$TOMEE_HOME" ] && TOMEE_HOME=`cygpath --unix "$TOMEE_HOME"` - [ -n "$CATALINA_BASE" ] && CATALINA_BASE=`cygpath --unix "$CATALINA_BASE"` - [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"` + [ -n "$TOMEE_BASE" ] && TOMEE_BASE=`cygpath --unix "$TOMEE_BASE"` fi if $cygwin; then JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"` - JRE_HOME=`cygpath --absolute --windows "$JRE_HOME"` - TOMEE_HOME=`cygpath --absolute --windows "$TOMEE_HOME"` - CATALINA_BASE=`cygpath --absolute --windows "$CATALINA_BASE"` - CATALINA_TMPDIR=`cygpath --absolute --windows "$CATALINA_TMPDIR"` - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"` + TOMEE_BASE=`cygpath --absolute --windows "$TOMEE_BASE"` fi PRG="$0" @@ -58,9 +49,10 @@ while [ -h "$PRG" ]; do fi done PRGDIR=`dirname "$PRG"` -[ -z "$TOMEE_HOME" ] && TOMEE_HOME=`cd "$PRGDIR/.." >/dev/null; pwd` +[ -z "$TOMEE_BASE" ] && TOMEE_BASE=`cd "$PRGDIR/.." >/dev/null; pwd` -. "$TOMEE_HOME"/bin/setclasspath.sh +. "$TOMEE_BASE"/bin/setclasspath.sh +[[ -f "$TOMEE_BASE"/bin/setenv.sh ]] && . "$TOMEE_BASE"/bin/setenv.sh if [ -z $JAVA_HOME ]; then JAVA="java" @@ -68,8 +60,8 @@ else JAVA=$JAVA_HOME"/bin/java" fi -CP="$TOMEE_HOME/lib" -for i in $TOMEE_HOME/lib/*.jar; do +CP="$TOMEE_BASE/lib" +for i in $TOMEE_BASE/lib/*.jar; do CP="$CP:$i" done @@ -77,10 +69,13 @@ done if [ "$1" = "deploy" ] || [ "$1" = "undeploy" ]; then if [ $# -eq 2 ]; then echo "${1}ing $2" - $JAVA $DEBUG -Dopenejb.base="$TOMEE_HOME" -cp "\"$CP\"" org.apache.openejb.cli.Bootstrap $1 -s http://localhost:$port/tomee/ejb $2 + $JAVA $DEBUG -Dopenejb.base="$TOMEE_BASE" -cp "\"$CP\"" org.apache.openejb.cli.Bootstrap $1 -s auto $2 else echo "Usage: <tomee.sh> $1 <path>" fi +elif [ "$1" = "start" ] || [ "$1" = "stop" ]; then + echo "To start or stop TomEE please use catalina.sh/startup.sh/shutdown.sh instead of tomee.sh" else - $JAVA $DEBUG -Dopenejb.base="$TOMEE_HOME" -cp "\"$CP\"" org.apache.openejb.cli.Bootstrap $* + $JAVA $DEBUG -Dopenejb.base="$TOMEE_BASE" -cp "\"$CP\"" org.apache.openejb.cli.Bootstrap $* fi +