diff --git a/server/src/main/java/org/red5/server/Launcher.java b/server/src/main/java/org/red5/server/Launcher.java index 27d27ad5164e611fadd445134c77a9c29259b4f0..2885fe6202b9b2a5d4e8b473252d448133fb886a 100644 --- a/server/src/main/java/org/red5/server/Launcher.java +++ b/server/src/main/java/org/red5/server/Launcher.java @@ -9,6 +9,7 @@ package org.red5.server; import org.red5.logging.Red5LoggerFactory; import org.red5.server.api.Red5; +import org.red5.server.exception.LaunchErrorException; import org.slf4j.Logger; import org.slf4j.bridge.SLF4JBridgeHandler; import org.springframework.context.support.FileSystemXmlApplicationContext; @@ -26,10 +27,10 @@ public class Launcher { /** * Launch Red5 under it's own classloader * - * @throws Exception + * @throws LaunchErrorException * on error */ - public void launch() throws Exception { + public void launch() throws LaunchErrorException { System.out.printf("Root: %s%nDeploy type: %s%n", System.getProperty(l_root), System.getProperty("red5.deployment.type")); // check for the logback disable flag boolean useLogback = Boolean.valueOf(System.getProperty("useLogback", "true")); @@ -52,8 +53,12 @@ public class Launcher { // create red5 app context @SuppressWarnings("resource") FileSystemXmlApplicationContext root = new FileSystemXmlApplicationContext(new String[] { "classpath:/red5.xml" }, false); - // set the current threads classloader as the loader for the factory/appctx - root.setClassLoader(Thread.currentThread().getContextClassLoader()); + try { + // set the current threads classloader as the loader for the factory/appctx + root.setClassLoader(Thread.currentThread().getContextClassLoader()); + } catch (Exception e) { + throw new LaunchErrorException("possible mismatch between the classloader used to launch the application and the one expected by the context ", e); + } root.setId(l_root); root.setBeanName(l_root); // refresh must be called before accessing the bean factory diff --git a/server/src/main/java/org/red5/server/exception/LaunchErrorException.java b/server/src/main/java/org/red5/server/exception/LaunchErrorException.java new file mode 100644 index 0000000000000000000000000000000000000000..f10f140f91d1addd119089aa32142e45118d7730 --- /dev/null +++ b/server/src/main/java/org/red5/server/exception/LaunchErrorException.java @@ -0,0 +1,21 @@ +/* + * RED5 Open Source Media Server - https://github.com/Red5/ Copyright 2006-2023 by respective authors (see below). All rights reserved. Licensed 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.red5.server.exception; +/** +* Couldn't launch the server +* +*/ +public class LaunchErrorException extends Exception{ + + /** + * this is serial Version is required from the owner developer that owns the right to initialize it + */ + // private static final long serialVersionUID = /* TODO */; + public LaunchErrorException(String message, Throwable cause) { + super(message, cause); + } +} \ No newline at end of file