Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting reference to JBoss MBean Server

 
Ragavendran Baskaran
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to get reference to Jboss MBean server using the code snippet below. I'm invoking this in a JSP file which is present in a WAR file and deployed in default profile of Jboss.

If i try with the below,
.....
MBeanServer server = MBeanServerLocator.locateJBoss();
.....

I'm getting this error.

[java] java.lang.IllegalStateException: No 'jboss' MBeanServer found!
[java] at org.jboss.mx.util.MBeanServerLocator.locateJBoss(MBeanServerLocator.java:110)
[java] at org.apache.jsp.demo_jsp._jspService(demo_jsp.java:67)
[java] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[java] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
[java] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
[java] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)

If i use the below:
...
MBeanServer server = MBeanServerLocator.locate();
...

then getting this error.

[java] java.util.NoSuchElementException
[java] at java.util.AbstractList$Itr.next(AbstractList.java:350)
[java] at org.jboss.mx.util.MBeanServerLocator.locate(MBeanServerLocator.java:67)
[java] at org.jboss.mx.util.MBeanServerLocator.locate(MBeanServerLocator.java:80)
[java] at org.apache.jsp.demo1_jsp._jspService(demo1_jsp.java:67)
[java] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[java] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)


Can you please explain the reason for this error or what is the correct way to obtain reference of Jboss mbean server in application code running on the same VM.
 
Ragavendran Baskaran
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also tried this option, but not able to get reference to the mbean server.


Output:
servers.size() = 0

 
Ragavendran Baskaran
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dropped the below JSP file in to jmx-console.war of jboss



I'm able to see the below output:

Locate method : org.jboss.mx.server.MBeanServerImpl@121dcac[ defaultDomain='jboss' ]
Locate Jboss method : org.jboss.mx.server.MBeanServerImpl@121dcac[ defaultDomain='jboss' ]
findMBeanServer method : [org.jboss.mx.server.MBeanServerImpl@121dcac[ defaultDomain='jboss' ], org.jboss.mx.server.MBeanServerImpl@dc5c8b[ defaultDomain='null' ]]

However if i drop the same JSP in to my application WAR and access it. I'm getting this exception as stated in my above posts.

I'm running out of clues. Any help will be highly appreciated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic