8 Replies Latest reply on May 19, 2006 3:47 AM by mschwarz

    Retrieve "binding address" within the application

    mschwarz

      Sorry to post this again - my subject went to hell....

      **************************************************************

      Hi folks,

      can anyone tell me, if there is a way to retrieve the jboss binding address as set in my run script ?
      I need this value in my application to generate an url.

      thanks a lot
      Marion

        • 1. Re: Retrieve
          mschwarz

          Ok, so JBoss displays all the system properties during startup.
          But how do I get those properties in Java ?

          • 2. Re: Retrieve
            starksm64

            System.getProperty("jboss.bind.address")

            • 3. Re: Retrieve
              mschwarz

              NULL ?

              • 4. Re: Retrieve
                mschwarz

                Sorry Scott,
                I know it seems like I am dumb, but I really tried a couple of things before I posted this topic.

                If there is a simple way to retrieve this information, please tell me so.

                • 5. Re: Retrieve
                  starksm64

                  If its null then the no bind address has been spcified via the -b option (or --host long option) has not been specified.

                  • 6. Re: Retrieve
                    mschwarz

                    In the "Full System Properties Dump" which is displayed in a logfile after startup, jboss claims the bind address to be "localhost", which is what I expect.
                    Still, in my Java application all I get is NULL.
                    Could it be that the jboss properties are hidden from the JVM ?

                    • 7. Re: Retrieve
                      peterj

                      Marion, where are you running the Java code that attempts to get the jboss.bind.address system property? Is it running within, say, a web application deployed to JBoss? Or is it running as a client Java app?

                      Just for grins, here is a JSP that I use to display the system properties. Packaged in a war file and accessed via the browser, it lists all system properties in alpha order. According to it, the jboss.bind.address is "0.0.0.0" if not specified on the command line. While this makes sense from a server socket perspective, it probably doesn't help you with generating URLs.

                      <%@ page language="java" %>
                      <?xml version="1.0" encoding="UTF-8"?>
                      <!DOCTYPE html
                       PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
                      <head>
                      <title>System Properties</title>
                      <style>
                      body
                       { font-family: Comic Sans MS, sans-serif
                       ; font-size: 11pt
                       ; background-color: #EFDBCD
                       }
                      h1
                       { font-family: Arial Rounded MT Bold, sans-serif
                       ; font-size: 18pt
                       ; color: #8A6C49
                       ; text-align: center
                       }
                      th
                       { font-family: Arial Rounded MT Bold, sans-serif
                       ; font-size: 14pt
                       ; color: white
                       ; background-color: #8A6C49
                       }
                      </style>
                      </head>
                      <%!
                       /*
                       * The path separator character, typically a colon or semi-colon.
                       */
                       private String sep;
                      
                       /*
                       * Places each item in a colon (or semi-colon) separated list on its
                       * own line. This makes the output for things such as the classpath
                       * more legible.
                       */
                       private String replaceAll(String str) {
                       StringBuffer buf = new StringBuffer();
                      
                       int loc = str.indexOf(sep);
                       while (loc > 0) {
                       buf.append(str.substring(0, loc+1));
                       buf.append("<br/>");
                       str = str.substring(loc + 1);
                       loc = str.indexOf(sep);
                       }
                       buf.append(str);
                       return buf.toString();
                       }
                      %>
                      <body>
                      <h1>System Properties</h1>
                      <table border='1' cellpadding='2'>
                       <tr>
                       <th>Property</th>
                       <th>Value</th>
                       </tr>
                      <%
                       java.util.TreeMap prop = new java.util.TreeMap(System.getProperties());
                       sep = (String)prop.get("path.separator");
                       for (java.util.Iterator iter = prop.keySet().iterator() ; iter.hasNext() ;) {
                       String p = (String)iter.next();
                       String v = (String)prop.get(p);
                      %>
                       <tr>
                       <td>
                       <%= p %>
                       </td>
                       <td>
                       <%= replaceAll(v) %>
                       </td>
                       </tr>
                      <%
                       }
                      %>
                      </table>
                      </body>
                      </html>


                      • 8. Re: Retrieve
                        mschwarz

                        Hi Peter,
                        this is good to know, even if it propably wont help me. As you guessed, I am trying to get the properties inside a client application and not via jsp techniques.

                        thanx anyway