Hi,
I'm using Tomcat 5.5 on Java 5. I'm trying to dynamically create a new
DataSource resource and add it to the JNDI component environment within a
webapp. To do so, I'm doing the same thing the admin app does: I get
Tomcat's MBeanServer, create the ObjectName for the NamingResource mbean
for my webapp's context, and invoke the "addResource" operation on the
NamingResource through the MBeanServer. This does not work. When I try
to subsequently retrieve the DataSource from JNDI, I get a
NameNotFoundException.
I think I know what the problem is, and it looks like either a bug or an
unimplemented feature. After the "invoke" method is called, Tomcat calls
the NamingResources.addResource(ContextResource) method on the appropriate
NamingResources instance. This method appears to do exactly what it
should. The last line of the method calls
support.firePropertyChange("resource", null, resource)
The problem here is that nobody's listening. I think an instance of
NamingContextListener should be listening for this event. Let's look at
that class.
In NamingContextListener.lifecycleEvent(LifecycleEvent), the instance's
container field is set from the LifecycleEvent. Later in that method, for
the case Lifecycle.START_EVENT, if the container is an instance of the
Server type, we see the line
namingResources.addPropertyChangeListener(this)
However, if the container is an instance of the Context type, there is no
such method call on namingResources. This seems to be the reason for the
failure of the mbean "addResource" invocation.
Given the fact that this feature (dynamic DataSource adds) is provided by
the admin app, I'm assuming it's supposed to work. Can anyone on the
Tomcat developers' team chime in?
Cheers,
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org