1 Reply Latest reply on Jul 10, 2007 12:41 AM by canterburry

    bootstrapping jboss from command line

    canterburry

      Hi,

      I am having some sort of classpath issue and I have been banging my head against it for a while now...some help would be very much appreciated...

      I am able to bootstrap the server in Eclipse (from junit) and from an ant task (java task which also uses the very same Server class to bootstrap).

      However, when I try to do the same from command prompt it blows up.

      I have created a very simple wrapper class around the bootstrapper:

      public class Server {

      private static Server instance;

      public static void main(String[] args) throws Exception {

      if(instance == null){
      instance = new Server();
      }

      if(args[0].equalsIgnoreCase("start")){
      System.out.println("Starting server...");

      if(instance != null && args.length > 1){
      instance.startServer(args[1]);
      }else{
      instance.startServer();
      }
      System.out.println("Server started.");
      }

      if(args[0].equalsIgnoreCase("stop")){
      System.out.println("Starting server...");
      if(instance != null)
      instance.shutdownServer();

      instance = null;
      System.out.println("Server stopped.");
      }

      if(args[0].equalsIgnoreCase("restart")){
      instance.shutdownServer();
      instance.startServer();
      }
      }

      public Server(){

      }

      public void startServer() throws Exception {
      Bootstrap.getInstance().bootstrap();
      }

      public void startServer(String path) throws Exception {
      System.out.println(System.getProperty("java.class.path"));
      Bootstrap.getInstance().bootstrap(path);
      }

      public void shutdownServer(){
      Bootstrap.getInstance().shutdown();
      }

      public void restartServer() throws Exception {
      Bootstrap.getInstance().shutdown();
      Bootstrap.getInstance().bootstrap();
      }

      }

      Now...I am trying to bootstrap things from the command prompt:

      @echo off
      SET JAVA_HOME=%JAVA_HOME%
      SET DIR=C:/DEV/server
      SET CP=.;lib/jboss-embedded-tomcat-bootstrap.jar;lib/server-mm.jar;lib/jboss-embedded-all.jar;lib/hibernate-all.jar;lib/thirdparty-all.jar;./bootstrap/

      if "%1" == "" (
      echo startup takes parameters: start, stop or restart.
      ) else (
      REM echo %CP%
      "%JAVA_HOME%/bin/java" -cp "%CP%" -jar "lib/server-mm.jar" %1

      )

      the server-mm.jar is an archive which contains my Server class with it's main method. Whenever I execute this script I get the following error:


      C:\DEV\server>startup start
      Starting server...
      log4j:WARN No appenders could be found for logger (org.jboss.kernel.KernelFactory).
      log4j:WARN Please initialize the log4j system properly.
      Exception in thread "main" org.jboss.deployers.spi.DeploymentException: Unable to find bootstrap file: conf/bootstrap-be
      ans.xml in classpath
      at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:200)
      at org.jboss.embedded.Bootstrap.bootstrap(Bootstrap.java:214)
      at forisent.brms.ejb.server.Server.startServer(Server.java:52)
      at forisent.brms.ejb.server.Server.main(Server.java:27)


      I have tried every possible classpath combo I can think of... am I completely missing something?

        • 1. Re: bootstrapping jboss from command line
          canterburry

          OK, solved this problem.

          Turns out this was a classic case of not reading the manual. Reading the Java manual a bit closer reveals that using the -jar option causes all CLASSPATH entries to be ignored and the passed jar file becomes the ONLY classpath entry passed to the JVM. So, using the classic com.package.MainClass method worked.


          @echo off
          SET JAVA_HOME=%JAVA_HOME%
          SET DIR=C:/DEV/server
          SET BOOTSTRAP_DIR=../bootstrap
          SET DEPLOY_DIR=%BOOTSTRAP_DIR%/deploy
          SET CP=.;lib/server-mm.jar;lib/jboss-embedded-tomcat-bootstrap.jar;lib/jboss-embedded-all.jar
          SET CP=%CP%;lib/hibernate-all.jar;lib/thirdparty-all.jar;%BOOTSTRAP_DIR%

          if "%1" == "" (
          echo startup takes parameters: start, stop or restart.
          ) else (
          REM echo %CP%
          "%JAVA_HOME%/bin/java" -cp %CP% com.package.Main %1
          )