How to get IP-address and port in JBoss AS 7.1 programmatically.

This can be achieved using the MBeanServerConnection API and the correct node and attribute names within the JBoss configuration:

// get an javax.management.MBeanServerConnection object
MBeanServerConnection mbServerConn = ManagementFactory.getPlatformMBeanServer();
// drill down to the 'http' node in the standard-socket-binding-group
ObjectName nameSocket = new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
// use the getAttribute()-method of the MBeanServerConnection object
String serverBase = "http://" + mbServerConn.getAttribute(nameSocket, "bound-address") + ":" + mbServerConn.getAttribute(nameSocket, "port")+ "/";

How to find out about the nodes and attribute names? The easiest way to achieve this, is to use the JBoss command line interface jboss-cli.sh. After you connected to the JBoss instance in question, use the ls command to find out about the nodes. You can use tab for autocompletion. Once you have found a leave, use the parameter -l for listing the attribute names:


ls socket-binding-group=standard-sockets
ls socket-binding-group=standard-sockets/socket-binding=http
ls - socket-binding-group=standard-sockets/socket-binding=http

The last command results in

ATTRIBUTE VALUE TYPE
bound true BOOLEAN
bound-address XX.YY.ZZ.WW STRING
bound-port 8080 INT
client-mappings undefined LIST
fixed-port false BOOLEAN
interface undefined STRING
multicast-address undefined STRING
multicast-port undefined INT
name http STRING
port 8080 INT

Snow Leopard: MyEclipse, Subeclipse and Java 6

Having moved from Mac OS X 10.5 (Leopard) to Mac OS X 10.6 (Snow Leopard), the Subversion integration into MyEclipse IDE 7.5 using Subeclipse did not work any more. More precisely, when opening the repository item in the SVN Repositories view, I got the dialog

Screen shot1

and an error message in the console saying

Screen shot 2

After trying to remove and reinstall the Subeclipse plugin without any improvement, I found a solution solving my problem after installing and using the JDK Version 1.5. For a detailed description look here: Snow Leopard and MyEclipse Fix Resolution and here http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard.

After installing the JDK 1.5, just move the J2SE 5.0 32-bit in front of the Java SE 6 32-bit within the Java Preferences utility. The 64-bit JDKs are not taken into account (yet) and can be left even on top of the 32-bit JDKs.

If you use the encryption API of Java, make sure you download and install the Unlimited Strength Jurisdiction Policy Files in the appropriate directory:

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0-leopard/Home/lib/security

Otherwise you might get errors like

java.security.InvalidKeyException: Illegal key size or default parameters

Good luck.

Optional ant tasks in separate build.xml file invoked with Maven AntRun plugin

In a legacy development project, ant build.xml files are used for compilation and packaging. To integrate new features more easily, I decided to use Maven and the AntRun plugin. The original targets can simply be invoked as it is explained in the examples.

However, if you want to use taks not included in the default jar, e.g. the optional ant tasks, you have to correctly add the dependencies to the AntRun plugin. Unfortunately, I moved the dependencies to the global section of my pom.xml. This mistake took me a quite some time to fix, as I simply oversaw it. 🙁

Just make sure, it looks like this:

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <dependencies>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-nodeps</artifactId>
      <version>1.7.0</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
    ...
    </execution>
  </executions>
</plugin>