Hello,

I need to dynamically create a datasource within
Tomcat (5.5 or 6.0) using the JMX service of the
server.

Firstly I activate the service using the following
parameters:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.ssl=false

At this time, I can access the server with a JMX
client like MC4J. I can see all the configured web
applications and all their associated resources
included datasources. I have the following structure:
Domain Catalina:
- host=localhost
  - path=/MyWebApp
    - class=javax.sql.DataSource
      - name="jdbc/ds1"

I want to register a similar datasource using JMX. I
try to use the following code:

MBeanServer server =
    ManagementFactory.getPlatformMBeanServer();

try {
    BaseModelMBean mbean = new BaseModelMBean();
        
    AttributeList attributes = new AttributeList();
    attributes.add(new Attribute("maxIdle", 30));
    [...]
    attributes.add(new Attribute("modelerType",
      "org.apache.tomcat.dbcp.dbcp.BasicDataSource"));
    [...]

    mbean.setAttributes(attributes);

    String mbeanName =
"Catalina:type=DataSource,name=\"jdbc/ds2\",class=javax.sql.DataSource,path=/MyWebApp,host=localhost";

    ObjectInstance mbeanObjectName = 
          server.registerMBean(mbean,
                new ObjectName(mbeanName));

The entry is added in the jmx tree but there no
property. I don't know if it's correct to use the
BaseModelMBean to do that...

Is it the correct way to configure a datasource using
JMX? Is there another better solution to do that?

Thanks for your answers!
Thierry

Take a look at my blog:
http://jroller.com/page/Templth/
(old: http://templth.blogspot.com/)


      
_____________________________________________________________________________ 
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to