4 Replies Latest reply on Feb 22, 2008 12:31 PM by jaikiran

    System.getProperty(

    gordonh

      I am an experience object-oriented programmer, but havent done alot with JBoss. I am working on a Java app hosting in JBoss right now that I am having an issue getting certain environment variables. Consider this line of code:

      System.getProperty("jboss.server.home.dir")

      Should this not produce the home directory of JBoss "out-of-the-box", or do I need to perform some sort of manual initialization for this setting (ie - look into a file, pull a manually set config value for the dir, then set the property)?

      Right now, the code above produces NULL invariably - and I have tried everything to resolve the issue. My first experience with JBoss hasnt been a good one - LOL. Hopefully it will get better.

      Thanks in advance for your help!

        • 1. Re: System.getProperty(
          jaikiran

           


          System.getProperty("jboss.server.home.dir")

          Should this not produce the home directory of JBoss "out-of-the-box", or do I need to perform some sort of manual initialization for this setting (ie - look into a file, pull a manually set config value for the dir, then set the property)?


          It should work out-of-box.

          Where are you calling this method? Is it a jsp/servlet or some class running on the server? Or is it some standalone client (in which case, this wont be available)?

          And which version of JBoss and Java are you using?



          • 2. Re: System.getProperty(
            jaikiran

            Also, when you start JBoss, what does the initial few lines in the logs show. On my local setup, i see this:

            ===============================================================================
            
             JBoss Bootstrap Environment
            
             JBOSS_HOME: D:\jboss-4.0.5.GA\bin\\..
            
             JAVA: c:\jdk1.5.0_07\bin\java
            
             JAVA_OPTS: -Dprogram.name=run.bat -server -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000
            
             CLASSPATH: c:\jdk1.5.0_07\lib\tools.jar;D:\jboss-4.0.5.GA\bin\\run.jar
            
            ===============================================================================
            
            11:30:47,426 INFO [Server] Starting JBoss (MX MicroKernel)...
            11:30:47,426 INFO [Server] Release ID: JBoss [Zion] 4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)
            11:30:47,426 INFO [Server] Home Dir: D:\jboss-4.0.5.GA
            11:30:47,426 INFO [Server] Home URL: file:/D:/jboss-4.0.5.GA/
            11:30:47,426 INFO [Server] Patch URL: null
            11:30:47,426 INFO [Server] Server Name: default
            11:30:47,426 INFO [Server] Server Home Dir: D:\jboss-4.0.5.GA\server\default
             11:30:47,426 INFO [Server] Server Home URL: file:/D:/jboss-4.0.5.GA/server/default/
            11:30:47,426 INFO [Server] Server Log Dir: D:\jboss-4.0.5.GA\server\default\log
            11:30:47,426 INFO [Server] Server Temp Dir: D:\jboss-4.0.5.GA\server\default\tmp
            11:30:47,426 INFO [Server] Root Deployment Filename: jboss-service.xml
            11:30:48,145 INFO [ServerInfo] Java version: 1.5.0_07,Sun Microsystems Inc.
            11:30:48,145 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_07-b03,Sun Microsystems Inc.
            11:30:48,145 INFO [ServerInfo] OS-System: Windows 2003 5.2,x86
            11:30:49,239 INFO [Server] Core system initialized


            • 3. Re: System.getProperty(
              gordonh

              The application is a Java WebStart application. Here is what is displayed when I start JBoss (includes version info).

              ===============================================================================

              JBoss Bootstrap Environment

              JBOSS_HOME: C:\JAVA\jboss-4.0.5.GA\bin\\..

              JAVA: C:\Program Files\Java\jdk1.5.0_14\\bin\java

              JAVA_OPTS: -Dprogram.name=run.bat -server -Xms128m -Xmx512m -Dsun.rmi.dgc.cli
              ent.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000

              CLASSPATH: C:\Program Files\Java\jdk1.5.0_14\\lib\tools.jar;C:\JAVA\jboss-4.0.
              5.GA\bin\\run.jar

              ===============================================================================

              11:41:33,484 INFO [Server] Starting JBoss (MX MicroKernel)...
              11:41:33,500 INFO [Server] Release ID: JBoss [Zion] 4.0.5.GA (build: CVSTag=Bra
              nch_4_0 date=200610162339)
              11:41:33,500 INFO [Server] Home Dir: C:\JAVA\jboss-4.0.5.GA
              11:41:33,500 INFO [Server] Home URL: file:/C:/JAVA/jboss-4.0.5.GA/
              11:41:33,500 INFO [Server] Patch URL: null
              11:41:33,500 INFO [Server] Server Name: default
              11:41:33,500 INFO [Server] Server Home Dir: C:\JAVA\jboss-4.0.5.GA\server\defau
              lt
              11:41:33,500 INFO [Server] Server Home URL: file:/C:/JAVA/jboss-4.0.5.GA/server
              /default/
              11:41:33,500 INFO [Server] Server Log Dir: C:\JAVA\jboss-4.0.5.GA\server\defaul
              t\log
              11:41:33,500 INFO [Server] Server Temp Dir: C:\JAVA\jboss-4.0.5.GA\server\defau
              lt\tmp
              11:41:33,500 INFO [Server] Root Deployment Filename: jboss-service.xml
              11:41:35,015 INFO [ServerInfo] Java version: 1.5.0_14,Sun Microsystems Inc.
              11:41:35,015 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_14-b03
              ,Sun Microsystems Inc.
              11:41:35,015 INFO [ServerInfo] OS-System: Windows XP 5.1,x86
              11:41:38,500 INFO [Server] Core system initialized
              11:41:52,093 INFO [WebService] Using RMI server codebase: http://protools1:8083
              /
              11:41:52,187 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resour
              ce:log4j.xml

              • 4. Re: System.getProperty(
                jaikiran

                 

                The application is a Java WebStart application.


                The Java Webstart application runs in its own JVM and hence wont have the system properties available on the server. The application server runs in its own JVM and if you use the System.getProperty from the code which runs on the server JVM then you will get the desired output (as you can see from the logs which you posted):

                11:41:33,500 INFO [Server] Server Home Dir: C:\JAVA\jboss-4.0.5.GA\server\default