Re: Configuring DataSources using jsp: reload context.xml?
The problem is now solved, though in a somewhat unsatisfying way. I wrote my own configuration file to store information about the data sources, and now I connect to databases using DriverManager. I'm still wondering about more elegant ways to do dynamical configuration of data sources. Would it be worth it to file a feature request for Tomcat, saying it should recreate the JNDI context when META-INF/context.xml changes? Any other ideas? Cheers, Jonas - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Configuring DataSources using jsp: reload context.xml?
That may work for new datasources but could create a problem for existing data sources specifically if they are already being used and have pooled connections. The existing pooled connections may be in use by the applications too. Restarting the tomcat after modifying datasource may be a better and simpler option. -Sameer --- On Tue, 7/8/08, Jonas Wagner [EMAIL PROTECTED] wrote: From: Jonas Wagner [EMAIL PROTECTED] Subject: Re: Configuring DataSources using jsp: reload context.xml? To: Tomcat Users List users@tomcat.apache.org Date: Tuesday, July 8, 2008, 1:50 PM The problem is now solved, though in a somewhat unsatisfying way. I wrote my own configuration file to store information about the data sources, and now I connect to databases using DriverManager. I'm still wondering about more elegant ways to do dynamical configuration of data sources. Would it be worth it to file a feature request for Tomcat, saying it should recreate the JNDI context when META-INF/context.xml changes? Any other ideas? Cheers, Jonas - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Configuring DataSources using jsp: reload context.xml?
Thanks Sameer for your reply! That may work for new datasources but could create a problem for existing data sources specifically if they are already being used and have pooled connections. The existing pooled connections may be in use by the applications too. Since the application connects to its datasources using the DriverManager class, I cannot use connection pooling. That's one of the reasons I tried using JNDI for such a long time :-( Restarting the tomcat after modifying datasource may be a better and simpler option. I have to restart (at least) the application anyway, because I open database connections in the init() of my servlet. Restarting Tomcat should not be necessary when using the DriverManager approach because Tomcat is not involved in the database connections. Using the JNDI approach, restarting Tomcat does not apply any changes made to the datasources (see my previous mails). Jonas - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Configuring DataSources using jsp: reload context.xml?
On Tue, Jul 8, 2008 at 08:53, Jonas Wagner [EMAIL PROTECTED] wrote: Since the application connects to its datasources using the DriverManager class, I cannot use connection pooling. That's one of the reasons I tried using JNDI for such a long time :-( I think it's possible to use DBCP connection pooling without JNDI. I haven't tried it, but there's some sample code here: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/ManualPoolingDataSourceExample.java?view=markup -- Len - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Configuring DataSources using jsp: reload context.xml?
Hi, Jonas Regarding your previous e-mails where you tried to overwrite META-INF\context.xml. Please note, that at deployment time this file is copied to /conf/Catalina/localhost/application_name.xml I think that you should either update the copy of that file and then restart Tomcat. If you update META-INF/context.xml then redeployment of the application is required. I guess that some of your actions with Eclipse IDE are causing redeployment. Maybe it is the step that calls Run As... Also, I suggest you to look at JMX interface of Tomcat. It allows to query and tune server components at run time. JMX servlet in Tomcat Manager application is an example of using it. (search the archives for more info on JMX) Best regards, Konstantin Kolinko 2008/7/7 Jonas Wagner [EMAIL PROTECTED]: Good morning, I'm still trying to figure out how I can cause tomcat to re-read JNDI resources. Here is one way I found out earlier: After further tests I found out that the server will reload JNDI data sources if all the following steps are performed: 1. Change the configuration 2. Execute _any_ servlet or jsp using the eclipse command Run As... Run on Server 3. Restart Tomcat As you can see, this only works from within Eclipse, and I have no clue how I could cause a JNDI reload in a production environment. In the meantime, I tried some further things, e.g. updating the last-modified-date of web.xml to cause a redeploy. I also did some more googling, but to no avail. Does anybody know a way to cause Tomcat to rebuild the JNDI context of an application? Or is there a better way to dynamically configure Data Sources? Any ideas are welcome. In the worst case I'd need to fall back on a custom config file and database connections using DriverManager, but this would destroy all benefits of pooled connections etc :-( Thanks, Jonas - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Configuring DataSources using jsp: reload context.xml?
Good morning, I'm still trying to figure out how I can cause tomcat to re-read JNDI resources. Here is one way I found out earlier: After further tests I found out that the server will reload JNDI data sources if all the following steps are performed: 1. Change the configuration 2. Execute _any_ servlet or jsp using the eclipse command Run As... Run on Server 3. Restart Tomcat As you can see, this only works from within Eclipse, and I have no clue how I could cause a JNDI reload in a production environment. In the meantime, I tried some further things, e.g. updating the last-modified-date of web.xml to cause a redeploy. I also did some more googling, but to no avail. Does anybody know a way to cause Tomcat to rebuild the JNDI context of an application? Or is there a better way to dynamically configure Data Sources? Any ideas are welcome. In the worst case I'd need to fall back on a custom config file and database connections using DriverManager, but this would destroy all benefits of pooled connections etc :-( Thanks, Jonas - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: Configuring DataSources using jsp: reload context.xml?
Thanks Hassan for your question. Are these data sources known in advance, or can the configuration tool user come up with an arbitrary new one at any time? These data sources will be known at the time of deployment, but as they are specific for each customer, I cannot write one META-INF/context.xml file that will do for everybody. That's why we had the idea of doing a configuration servlet. This servlet can modify/delete existing data sources as well as add new ones. The new ones are almost arbitrary, except that the servlet only allows to choose JDBC drivers that are installed on the system. An update on the problem: on my development server (managed by eclipse) restarting the server _sometimes_ seems to apply the changes. I haven't found out in which cases exactly. The changes are never applied when I deploy to a production server using a .war file, though. I tried adding META-INF/context.xml to WatchedResource, but this doesn't seem to help either. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Configuring DataSources using jsp: reload context.xml?
One more update on the problem: An update on the problem: on my development server (managed by eclipse) restarting the server _sometimes_ seems to apply the changes. I haven't found out in which cases exactly. The changes are never applied when I deploy to a production server using a .war file, though. After further tests I found out that the server will reload JNDI data sources if all the following steps are performed: 1. Change the configuration 2. Execute _any_ servlet or jsp using the eclipse command Run As... Run on Server 3. Restart Tomcat In particular, if step 2 is omitted, the configuration change is not effective. Also, it only works if I perform step 2 using eclipse's Run on Server. If I use firefox to access a servlet, it does not work. Also, just reloading the page in eclipse's internal browser doesn't work, I have to use Run on Server. What does eclipse do to tell Tomcat to reload my application? How could I reproduce this outside eclipse? Note that I did not make any changes to the files in eclipse. I just used Run on Server to start a servlet or jsp. Any help is appreciated, Jonas - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Configuring DataSources using jsp: reload context.xml?
Hello, I'm trying to write a configuration frontend for a webapp. This application uses several data sources, and it should be possible to change the username/password/database/... using the configuration frontend. My idea was that the configuration servlet would modify the META-INF/context.xml file of my webapp, more precicely the Resource entries in this file. However, it seems that changes to those entries are not recognized by Tomcat. Later I read on this mailing list ( http://marc.info/?l=tomcat-userm=121431733620462w=2 ) that JNDI resources are only reloaded on redeploy, so I think my approach is somewhat wrong... Are there any ideas on how to change JNDI resources from a webapp? One Idea of mine was to create a DataSource manually and then use Context.bind(). This seems to destroy the whole portability benefit of using JNDI, though. Also I'm unsure whether such a binding would persist if Tomcat is restarted. I'd appreciate any tipps. Jonas - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Configuring DataSources using jsp: reload context.xml?
On Wed, Jul 2, 2008 at 8:53 AM, Jonas Wagner [EMAIL PROTECTED] wrote: I'm trying to write a configuration frontend for a webapp. This application uses several data sources, and it should be possible to change the username/password/database/... using the configuration frontend. My idea was that the configuration servlet would modify the META-INF/context.xml file of my webapp, more precicely the Resource entries in this file. Are these data sources known in advance, or can the configuration tool user come up with an arbitrary new one at any time? -- Hassan Schroeder [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]