use of fish.payara.micro.BootstrapException in project Payara by payara.
the class PayaraMicroImpl method createLauncher.
private void createLauncher() throws BootstrapException {
try {
if (rootDir == null) {
LOGGER.severe("--rootdir is required for creating a launcher");
System.exit(-1);
}
unPackRuntime();
addLibraries();
LauncherCreator creator = new LauncherCreator(rootDir, ((URLClassLoader) getClass().getClassLoader()));
creator.buildLauncher();
} catch (RuntimeException | URISyntaxException | IOException e) {
throw new BootstrapException("Unable to create launcher", e);
}
}
use of fish.payara.micro.BootstrapException in project Payara by payara.
the class PayaraMicroImpl method bootStrap.
/**
* Boots the Payara Micro Server. All parameters are checked at this point
*
* @return An instance of PayaraMicroRuntime that can be used to access the
* running server
* @throws BootstrapException
*/
@Override
public PayaraMicroRuntime bootStrap() throws BootstrapException {
// First check whether we are already running
if (isRunning()) {
throw new IllegalStateException("Payara Micro is already running, calling bootstrap now is meaningless");
}
long start = System.currentTimeMillis();
// Build the runtime directory
try {
unPackRuntime();
} catch (IOException | URISyntaxException ex) {
throw new BootstrapException("Problem unpacking the Runtime", ex);
}
final String loggingProperty = System.getProperty("java.util.logging.config.file");
resetLogging(loggingProperty);
// If it's been enabled, watch the log file for changes
if (enableDynamicLogging) {
PayaraFileWatcher.watch(new File(loggingProperty).toPath(), () -> {
LOGGER.info("Logging file modified, resetting logging");
resetLogging(loggingProperty);
});
}
// Check a supported JDK version is being used
if (!JDK.isRunningLTSJDK()) {
LOGGER.warning("You are running the product on an unsupported JDK version and might see unexpected results or exceptions.");
}
runtimeDir.processDirectoryInformation();
// build the runtime
BootstrapProperties bprops = new BootstrapProperties();
bprops.setInstallRoot(runtimeDir.getDirectory().getAbsolutePath());
bprops.setProperty(Constants.PLATFORM_PROPERTY_KEY, Constants.Platform.PayaraMicro.toString());
GlassFishRuntime gfruntime;
try {
gfruntime = GlassFishRuntime.bootstrap(bprops, Thread.currentThread().getContextClassLoader());
GlassFishProperties gfproperties = new GlassFishProperties();
gfproperties.setProperty("-type", "MICRO");
gfproperties.setInstanceRoot(runtimeDir.getDirectory().getAbsolutePath());
gfproperties.setConfigFileReadOnly(false);
gfproperties.setConfigFileURI(runtimeDir.getDomainXML().toURI().toString());
try {
configureCommandFiles();
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, "Unable to load command file", ex);
}
gf = gfruntime.newGlassFish(gfproperties);
configurePorts();
configureThreads();
configureAccessLogging();
configureHazelcast();
configurePhoneHome();
configureNotificationService();
configureHealthCheck();
configureRequestTracingService();
configureSecrets();
// Add additional libraries
addLibraries();
// boot the server
preBootCommands.executeCommands(gf.getCommandRunner());
callHandler(preBootHandler);
gf.start();
// Execute post boot commands
postBootCommands.executeCommands(gf.getCommandRunner());
callHandler(postBootHandler);
this.runtime = new PayaraMicroRuntimeImpl(gf, gfruntime);
// deploy all applications and then initialize them
deployAll();
// These steps are separated in case any steps need to be done in between
gf.getCommandRunner().run("initialize-all-applications");
postDeployCommands.executeCommands(gf.getCommandRunner());
long end = System.currentTimeMillis();
dumpFinalStatus(end - start);
return runtime;
} catch (Exception ex) {
try {
if (gf != null) {
gf.dispose();
}
} catch (GlassFishException ex1) {
LOGGER.log(Level.SEVERE, null, ex1);
}
throw new BootstrapException(ex.getMessage(), ex);
}
}
Aggregations