This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes BEA/Weblogic and the fly likes JMX registration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "JMX registration" Watch "JMX registration" New topic

JMX registration

florian adler

Joined: Sep 07, 2005
Posts: 1

I have created a MBean that is shipped with my servlet. The MBean is registered (here User) in the init method of the servlet.
I the problem is that I need to hardcode the registration parameters:

public void init() throws ServletException {
try {
MBeanHome home = null;
RemoteMBeanServer rmbs = null;

//domain variables
String url = "t3://localhost:7001";
String serverName = "Server1";
String username = "weblogic";
String password = "weblogic";

//Using MBeanHome to get MBeanServer.
try {
Environment env = new Environment();
Context myCtx = env.getInitialContext();
MBeanHome mbeanHome = (MBeanHome) myCtx.lookup(
MBeanServer server = mbeanHome.getMBeanServer();
ObjectName objName = new ObjectName(mbeanHome.getDomainName() +
User user = new User();
if (!server.isRegistered(objName)) {
server.registerMBean(user, objName);
} catch (Exception e) {
System.out.println("Caught exception: " + e);

I find this registration a bit annoying and a bit heavy since the registration parameters are shipped within the servlet (whether hardcoded or configured).

I would rather like that the MBean register on the WLS the servlet is deployed whatever the WLS.

Can someone help me with this issue?

It is sorta covered in the JavaRanch Style Guide.
subject: JMX registration
It's not a secret anymore!