-
1. Re: oh the newbie, mbean connection
bigbinc Nov 24, 2003 4:33 PM (in response to bigbinc)this is part of my build.xml
And this code gives me a nullpointexception, I am using mbeandata from the htmladaptor
org.jboss.jmx.adaptor.model.MBeanData
MBeanData _data = (MBeanData)
Server.getMBeanData("jboss:service=JNDIView"); -
2. Re: oh the newbie, mbean connection
bigbinc Nov 24, 2003 7:12 PM (in response to bigbinc)SUPER newbie here, ok you have to run the code within the context of the application server as opposed to as standalone app.
I will read next time, I swear it.
Here is working code.
package org.retro.gis;
import java.net.*;
import java.util.*;
import javax.management.*;
import javax.management.MBeanServer;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.PrintWriter;
import java.io.IOException;
public class ListServer extends HttpServlet {
public void init() throws ServletException
{
} // end of the function
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException
{
response.setContentType("text/plain");
// get a handle
PrintWriter out = response.getWriter();
out.println("");
out.println("");
out.println("Hello");
goBean(out);
out.println("");
out.println("");
} // end of the function
private void goBean(PrintWriter _out) {
String _domain = "jboss";
MBeanServer server = null;
try {
server =
(MBeanServer)MBeanServerFactory.findMBeanServer( null ).get( 0 );
if (server == null)
_out.println("Error, null");
else
_out.println("not null");
String _s = server.getDefaultDomain();
_out.println("X: " + _s);
ObjectName name = new ObjectName("jboss:service=JNDIView");
MBeanInfo info = server.getMBeanInfo(name);
_out.println("Class: " + info.getClassName());
} catch(Exception e) {
//e.printStackTrace();
_out.println("ERROR:" + e.getMessage());
} // end of the try - catch
} // end of the function
} // end of the class