Re: Tomcat Datasource , can we define them in war file (whithout accessing to Admin console)?
--- Wade Chandler <[EMAIL PROTECTED]> wrote: > --- Andre Van Klaveren <[EMAIL PROTECTED]> wrote: > > > Like Bruce said, you can define a DataSource as > part > > of your > > application's context. It's the same format as > the > > context definition > > in server.xml except it's deployed with your > > application as an XML > > file (context.xml) inside the META-INF directory > of > > the WAR. > > > > Here's a link to explain how to do it: > > > http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html > > > > They don't go into using context.xml but the same > > instructions can be > > applied to using the context.xml. > > > > > > > > On 12/26/05, Legolas Woodland > <[EMAIL PROTECTED]> > > wrote: > > > Hi > > > Thank you for reading my post. > > > Is it possible to make a data-source without > admin > > console ? > > > I mean by defining the data-source in web.xml or > > in Context.xml (i think > > > i read somewhere that we could put context.xml > > into meta-inf folder and > > > it will act like Context definition in admin > > console). > > > > > > is it mandatory that Tomcat shared library > folder > > contain my database > > > jdbc driver to have data-source ? > > > I mean can we bundle , our JDBC driver inside > war > > file and define the > > > data-source in war file too ? > Some drivers will need to be placed in the endorsed > folder as they will end up loading native libraries > which can access other code. I'm not sure where the > security file you would need to edit to not make > this > a requirement is if one even exists. My experience > with the MS SQL (not MySQL) driver is it needs to be > in this directory to work. You can change the > location of this directory using switches if you > need > it to be some where else for file and drive setup > reasons. > > Wade > See the -Djava.endorsed.dirs option in the Windows tomcat service configuration tool (Java tab) or the scripts for the Unices. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat Datasource , can we define them in war file (whithout accessing to Admin console)?
--- Andre Van Klaveren <[EMAIL PROTECTED]> wrote: > Like Bruce said, you can define a DataSource as part > of your > application's context. It's the same format as the > context definition > in server.xml except it's deployed with your > application as an XML > file (context.xml) inside the META-INF directory of > the WAR. > > Here's a link to explain how to do it: > http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html > > They don't go into using context.xml but the same > instructions can be > applied to using the context.xml. > > > > On 12/26/05, Legolas Woodland <[EMAIL PROTECTED]> > wrote: > > Hi > > Thank you for reading my post. > > Is it possible to make a data-source without admin > console ? > > I mean by defining the data-source in web.xml or > in Context.xml (i think > > i read somewhere that we could put context.xml > into meta-inf folder and > > it will act like Context definition in admin > console). > > > > is it mandatory that Tomcat shared library folder > contain my database > > jdbc driver to have data-source ? > > I mean can we bundle , our JDBC driver inside war > file and define the > > data-source in war file too ? Some drivers will need to be placed in the endorsed folder as they will end up loading native libraries which can access other code. I'm not sure where the security file you would need to edit to not make this a requirement is if one even exists. My experience with the MS SQL (not MySQL) driver is it needs to be in this directory to work. You can change the location of this directory using switches if you need it to be some where else for file and drive setup reasons. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat Datasource , can we define them in war file (whithout accessing to Admin console)?
Like Bruce said, you can define a DataSource as part of your application's context. It's the same format as the context definition in server.xml except it's deployed with your application as an XML file (context.xml) inside the META-INF directory of the WAR. Here's a link to explain how to do it: http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html They don't go into using context.xml but the same instructions can be applied to using the context.xml. On 12/26/05, Legolas Woodland <[EMAIL PROTECTED]> wrote: > Hi > Thank you for reading my post. > Is it possible to make a data-source without admin console ? > I mean by defining the data-source in web.xml or in Context.xml (i think > i read somewhere that we could put context.xml into meta-inf folder and > it will act like Context definition in admin console). > > is it mandatory that Tomcat shared library folder contain my database > jdbc driver to have data-source ? > I mean can we bundle , our JDBC driver inside war file and define the > data-source in war file too ? > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Virtually, Andre Van Klaveren Architect III, SCP Global Public Sector Unisys Corporation - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat Datasource , can we define them in war file (whithout accessing to Admin console)?
On 12/26/05, Legolas Woodland <[EMAIL PROTECTED]> wrote: > > Is it possible to make a data-source without admin console ? > I mean by defining the data-source in web.xml or in Context.xml (i think > i read somewhere that we could put context.xml into meta-inf folder and > it will act like Context definition in admin console). Yes, you can define your datasource in the application's META-INF/context.xml file. There are examples on the web, but I can provide an example if you contact me directly. I'd post a link but I'm writing this in a hurry. is it mandatory that Tomcat shared library folder contain my database > jdbc driver to have data-source ? > I mean can we bundle , our JDBC driver inside war file and define the > data-source in war file too ? I've not tried that but have assumed it's possible. -- Bruce Tong
RE: Tomcat Datasource , can we define them in war file (whithout accessing to Admin console)?
Hello, Note: This works at least since TC 5.5.7; I don't know exactly if it works for the previous versions. Just create a context.xml file (where you describe your datasources) in the META-INF directory of your .war file (unfortunately, you'll still need the jdbc jar file in common/lib). This file will be loaded when the application is deployed. Example of context.xml (for 2 datasources to Oracle DBs) : The datasources must then be referenced from the WEB-INF/web.xml file (to allow the lookup in the JNDI context of TC) : http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4"> [...] Resource ref to the Datasource configured in context.xml ojdbc14.jar must be copied to $CATALINA_HOME/common/lib jdbc/datasource1 javax.sql.DataSource Container Resource ref to the Datasource configured in context.xml ojdbc14.jar must be copied to $CATALINA_HOME/common/lib jdbc/datasource2 javax.sql.DataSource Container The lookup is done like this (without the try/catch blocks) : Context initCtx = new InitialContext(); Context envCtx = (Context)initCtx.lookup("java:comp/env"); // I usually cache envCtx to avoid recreating it DataSource ds = (DataSource)envCtx.lookup("jdbc/datasource1"); There is probably too much in this answer, but it will probably help for similar questions too. Best Regards, Jean-Pol. -Original Message- From: Khawaja Shams [mailto:[EMAIL PROTECTED] Sent: 27 December 2005 02:31 To: Tomcat Users List Subject: Re: Tomcat Datasource , can we define them in war file (whithout accessing to Admin console)? Hello, I am assuming that you are trying to define this datasource in order to do application server managed connection pooling. The closest I have done to what you described is declare a datasource as a global resource in the server.xml and refer to it in context definition. You can define a new context in the $CATALINA_HOME/conf/Catalina/localhost/APPNAME.xml. Here is an example: However, I still needed to put the jdbc jar file in the common/lib. I am not completely sure about this, but for application server to manage your datasource, one needs to make the proper jar file available to the app server by putting it in the common/lib as it will not look inside each deployed directory to perform application independent tasks. I am also curious to know if someone has found a way around this. Best Regards, Khawaja Shams On 12/26/05, Legolas Woodland <[EMAIL PROTECTED]> wrote: > > Hi > Thank you for reading my post. > Is it possible to make a data-source without admin console ? > I mean by defining the data-source in web.xml or in Context.xml (i think > i read somewhere that we could put context.xml into meta-inf folder and > it will act like Context definition in admin console). > > is it mandatory that Tomcat shared library folder contain my database > jdbc driver to have data-source ? > I mean can we bundle , our JDBC driver inside war file and define the > data-source in war file too ? > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat Datasource , can we define them in war file (whithout accessing to Admin console)?
Khawaja Shams wrote: Hello, I am assuming that you are trying to define this datasource in order to do application server managed connection pooling. The closest I have done to what you described is declare a datasource as a global resource in the server.xml and refer to it in context definition. You can define a new context in the $CATALINA_HOME/conf/Catalina/localhost/APPNAME.xml. Here is an example: I want to create a data source to have a application server managed pool of connection. but the problem is that i have no access to tomcat installation folder , so i can not change anythin in tomcat installation . they just allows to upload a war file. However, I still needed to put the jdbc jar file in the common/lib. I am not completely sure about this, but for application server to manage your datasource, one needs to make the proper jar file available to the app server by putting it in the common/lib as it will not look inside each deployed directory to perform application independent tasks. I am also curious to know if someone has found a way around this. A connection pool is application is application independent ? but i want the connection pool just for my own application. I will be happy if any one can tell me a trick to have application server managed pool without changing tomcat installation stuff. Best Regards, Khawaja Shams On 12/26/05, Legolas Woodland <[EMAIL PROTECTED]> wrote: Hi Thank you for reading my post. Is it possible to make a data-source without admin console ? I mean by defining the data-source in web.xml or in Context.xml (i think i read somewhere that we could put context.xml into meta-inf folder and it will act like Context definition in admin console). is it mandatory that Tomcat shared library folder contain my database jdbc driver to have data-source ? I mean can we bundle , our JDBC driver inside war file and define the data-source in war file too ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tomcat Datasource , can we define them in war file (whithout accessing to Admin console)?
Hello, I am assuming that you are trying to define this datasource in order to do application server managed connection pooling. The closest I have done to what you described is declare a datasource as a global resource in the server.xml and refer to it in context definition. You can define a new context in the $CATALINA_HOME/conf/Catalina/localhost/APPNAME.xml. Here is an example: However, I still needed to put the jdbc jar file in the common/lib. I am not completely sure about this, but for application server to manage your datasource, one needs to make the proper jar file available to the app server by putting it in the common/lib as it will not look inside each deployed directory to perform application independent tasks. I am also curious to know if someone has found a way around this. Best Regards, Khawaja Shams On 12/26/05, Legolas Woodland <[EMAIL PROTECTED]> wrote: > > Hi > Thank you for reading my post. > Is it possible to make a data-source without admin console ? > I mean by defining the data-source in web.xml or in Context.xml (i think > i read somewhere that we could put context.xml into meta-inf folder and > it will act like Context definition in admin console). > > is it mandatory that Tomcat shared library folder contain my database > jdbc driver to have data-source ? > I mean can we bundle , our JDBC driver inside war file and define the > data-source in war file too ? > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Tomcat Datasource , can we define them in war file (whithout accessing to Admin console)?
Hi Thank you for reading my post. Is it possible to make a data-source without admin console ? I mean by defining the data-source in web.xml or in Context.xml (i think i read somewhere that we could put context.xml into meta-inf folder and it will act like Context definition in admin console). is it mandatory that Tomcat shared library folder contain my database jdbc driver to have data-source ? I mean can we bundle , our JDBC driver inside war file and define the data-source in war file too ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]