This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes Getting reference to JBoss MBean Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Getting reference to JBoss MBean Server" Watch "Getting reference to JBoss MBean Server" New topic
Author

Getting reference to JBoss MBean Server

Ragavendran Baskaran
Greenhorn

Joined: Dec 12, 2011
Posts: 15
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

Joined: Dec 12, 2011
Posts: 15
Also tried this option, but not able to get reference to the mbean server.


Output:
servers.size() = 0

Ragavendran Baskaran
Greenhorn

Joined: Dec 12, 2011
Posts: 15
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting reference to JBoss MBean Server