tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <knst.koli...@gmail.com>
Subject Re: MBean InitialContext() Tomcat query- pls help
Date Thu, 22 Dec 2011 10:34:43 GMT
2011/12/20 S B <sblvrg@gmail.com>:
> Hi,
>
> I created and deployed an MBean in my tomcat. It uses datasource to connect
> to DB.
>
> My questions is:
>
> When I create InitialContext() inside MBean's constructor and pass the
> envContext to DBManager class to lookup datasource it works fine. However
> when I create InitialContext() in DBManager  class, it fails.

IIRC what InitialContext() sees as its environment highly depends on
what classloader is active. That is TCCL =
Thread.getContextClassLoader().

So while it is run from within web application your TCCL = your
webapp's classloader.

When it is invoked from jconsole it might be a separate Thread, not
related to your web application.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message