We have writen a MBEAN such as posted in the JBoss3.x docu: A Standard MBean
Example page 118. (see code below)
This worked wounderfull in JBoss3.2.3.
After adapting the jboss-service.xml I was able to deploy it in JBoss4.0.0.
Using the jmx-Console I am able to view all the properties stored in the MBean.
But when I try to connect to the MBean using JDNI
| Context ctx = new InitialContext();
| serverSettings =
(ServerSettings)ctx.lookup("java:/MARSServerSettings");
|
from my application (inside Jboss) I am able to invoke the bean and its
methods, but the returned properties are null.
Has anyone an idea whats the problem ?
It seems to me that the MBean is not a singleton anymore!
Cheers Michael
| public interface ServerSettingsMBean extends java.io.Serializable {
| public static final int STOPPED = 0;
| public static final int STARTED = 1;
|
| public void setProperty(String key, String value);
| public void removeProperty(String key);
| public String getProperty(String key);
| public String listProperties();
| public String[] getKeys();
| public void setJNDIName(String jndiName);
| public String getJNDIName();
| public String getStatusString();
| public int getStatus();
| public void start();
| public void stop();
| }
|
| public class ServerSettings implements ServerSettingsMBean {
| private static final String TABLENAME = "MARSSERVERPROPERTIES";
|
| private String JNDIName_ = "not set";
| private int status_ = STOPPED;
| private java.util.Hashtable properties_ = new java.util.Hashtable();
| private transient Connection con_ = null;
|
|
|
| public void setProperty(String key, String value) {
| setPropertyDB(key.trim(),value.trim());
| properties_.put(key.trim(), value.trim());
| }
|
| public String getProperty(String key) {
| System.out.println("ServerSettings-getProperty "+key);
| String retValue = (String)properties_.get(key.trim());
| System.out.println("ServerSettings-getProperty returns "+retValue);
| return retValue;
| }
| .......
| }
|
|
|
| <server>
| <mbean code="at.tugraz.genome.marsservice.ServerSettings"
| name="at.tugraz.genome.marsservice:service=ServerSettings">
| <attribute name="JNDIName">java:/MARSServerSettings</attribute>
|
<depends>jboss.jca:service=DataSourceBinding,name=jdbc/DefaultDS</depends>
|
<!--depends>jboss.jca:service=XATxCM,name=jdbc/DefaultDS</depends>
|
<depends>jboss.jca:service=ManagedConnectionFactory,name=jdbc/DefaultDS</depends>
|
<depends>jboss.jca:service=ManagedConnectionPool,name=jdbc/DefaultDS</depends-->
| </mbean>
| </server>
|
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3857051#3857051
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3857051
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user