0

I am using following code for getting values of http port for JBoss 6.1 EAP. This code worked perfectly fine in JBoss 7.1 AS.

Following is the code:

MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName socketBindingMBean = new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
Integer port = (Integer) mBeanServer.getAttribute(socketBindingMBean, "boundPort"));

This code works fine if I deploy the WAR after the server has started, but it fails to work during start up. Is there a change in which JBoss loads its modules? How can I get this information at startup?

1 Answers1

1

this is normal while the sockets and ports is not initialized yet and it will after the server is run successfuly then you could read it , i would suggest to use configuration file of JBoss and keep one prt fixed always for your aplication then you will know it always ...

  • Thanks for your reply. My requirement is to fill up these details at startup. At first, we did the same, but we want to eliminate this file altogether. Is there any way to delay the deployment until server initializes these values? – Aditya Neurgaonkar Dec 09 '16 at 05:53
  • This is a valid question. There is no need to down vote it. – Aditya Neurgaonkar Dec 09 '16 at 07:37
  • Similar Question has been asked [link]http://stackoverflow.com/questions/24741004/how-to-get-bound-server-address-and-port-programmatically-in-java-ee – Aditya Neurgaonkar Dec 09 '16 at 07:38