deploy mbean in weblogic 8.1?
how to deploy mbean in weblogic ?
what are the changes need to make in config.xml .
How to access mbean from client side.
thanks in advance.
Sachin >>
how to deploy mbean in weblogic ?
what are the changes need to make in config.xml .
How to access mbean from client side.
thanks in advance.
Sachin >>
Hey Sachin,
I take it you want to deploy an MBean of your own making? In that case it is quite easy:
1) Put your MBeans into the same jar/war/ear file as another of your J2EE components.
2) Write a weblogic specific startup class/application listener that creates your MBean instances and registers them in the weblogic MBean server - don't create your own MBean server. You get a reference to the weblogic MBean server via JNDI. See below.
You can now access your custom MBeans via the MBeanServer interface after you get a reference to the weblogic MBean server from JNDI. See below.
How to get a reference to the weblogic MBean server:
Hastable t = new Hashtable();
t.put(Context.PROVIDER_URL, "t3://localhost:7001"); /or whereever your server that runs the MBean server can be contacted.
t.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
//might be necessary depending on the settings in your weblogic server:
t.put(Context.SECURITY_PRINCIPAL, "weblogic");//or whatever user you have
t.put(Context.SECURITY_CREDENTIALS, "weblogic"); //or whatever password that user has
Context ctx = new InitialContext(t);
MBeanHome home = (MBeanHome) ctx.lookup("<some mbean server jndi location>")
MBeanServer server = home.getMBeanServer();
ctx.close();
Where <some mbean server jndi location>
is depending on if you deploy your MBeans on the admin server or not:
Admin server MBean server: "weblogic.management.adminhome"
Managed Server MBean server: "weblogic.management.home.localhome"
From this point, just use the MBeanServer interface as if it was local. It makes and RMI call to the server whenever you invoke a method on it.
Getting a reference to the weblogic MBean server from a client or from the server is the same. There is no difference.
Hope this helps,
Eske
Hi esort,
I created jar having MBean but i didnt find location where to put jar.
As this is not j2ee application.
in second step . When i write a Class registering MBean it gives error
[java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException:
weblogic.rmi.extensions.RemoteRuntimeException: Unexpected Exception
- with nested exception:
[java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: com.management.Example:
This error could indicate that a component was deployed on a cluster member
but not other members of that cluster.
Make sure that any component deployed on a server that is part of a cluster
is also deployed on all other members of that cluster] .
In weblogic 8, your class needs to implement the weblogic.common.T3StartupDef interface. Then you jar this class (and all associated files), and put it in the class path in your server start up script. In the weblogic admin console, you need to specify the startup class, and target it to server or cluster, or individual servers. Then when you start the server, it will call this class's startup method.
http://edocs.bea.com/wls/docs81/javadocs/weblogic/common/T3StartupDef.html
- Alper
When you write "this is not a J2EE application" do you mean that it does not contain EJBs? Is it a web application, then? Deployed in a .war file?
You can create a jar file with your MBeans and then create a dummy EJB that does nothing, which will go into the same jar file. The dummy EJB will allow you to deploy the MBeans.
To deploy anything on weblogic it must be a J2EE resource (being either a: jar, war, ear or rar file). According to the J2EE spec (I think) jar files can only be deployed on their own if they contain EJBs.
I suggest you create a .ear file and put your .war and .jars in there. Create a META-INF dir in the root of the ear file and place an application.xml and weblogic-application.xml file in there.
Inside the jar file with the MBEans, create a startup class that extends this:
http://edocs.bea.com/wls/docs81/javadocs/weblogic/application/ApplicationLifecycleListener.html
Then in weblogic-application.xml enter a <listener>..</listener> (see here: http://e-docs.bea.com/wls/docs81/programming/app_xml.html#1025948) that tells weblogic where your startup class is.
Regards,
Eske