• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JMX registration

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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();
env.setProviderUrl(url);
env.setSecurityPrincipal(username);
env.setSecurityCredentials(password);
Context myCtx = env.getInitialContext();
MBeanHome mbeanHome = (MBeanHome) myCtx.lookup(
"weblogic.management.home.localhome");
MBeanServer server = mbeanHome.getMBeanServer();
ObjectName objName = new ObjectName(mbeanHome.getDomainName() +
":Name=MyHello,Type=HelloServlet");
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?

Florian.
 
reply
    Bookmark Topic Watch Topic
  • New Topic