You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Darren <dl...@gmail.com> on 2006/02/17 17:00:27 UTC

Where to place JNDI sections for customer deployment

Hi,

I am running Tomcat 5.5.9 and would like to deploy an application (as  
a war file) to various customers, but I am having trouble finding the  
best place for JNDI lookups.  During development I kept everything  
inside the war file and placed my JNDI entries in $WAR/META-INF/ 
context.xml, but I don't want customers to have to edit the  
context.xml in the war file on their systems.

So, I added the following into $WAR/WEB_INF/web.xml

   <resource-ref>
     <description>DB Connection</description>
     <res-ref-name>jdbc/db</res-ref-name>
     <res-type>javax.sql.DataSource</res-type>
     <res-auth>Container</res-auth>
   </resource-ref>
   <resource-ref>
     <description>Email Server Settings</description>
     <res-ref-name>bean/email</res-ref-name>
     <res-type>somepackage.EmailServerConfiguration</res-type>
     <res-auth>Container</res-auth>
   </resource-ref>

Now I am unsure where to add the following ....

<Context path="/mycontext" docBase="mycontext"
          crossContext="true" reloadable="true" debug="1">

     <Resource name="jdbc/db" auth="Container"  
type="javax.sql.DataSource"
               maxActive="10" maxIdle="15" maxWait="10000"
               removeAbandoned="true" removeAbandonedTimeout="300"  
logAbandoned="true"
               driverClassName="com.mysql.jdbc.Driver"  
username="user" password="pass"
               url="jdbc:mysql://localhost:3306/db? 
autoReconnect=true" />

     <Resource name="bean/email" auth="Container"
               type="somepackage.EmailServerConfiguration"
               factory="org.apache.naming.factory.BeanFactory"
               host="localhost" port="25" />

</Context>

I tried adding it into $CATALINA/conf/server.xml inside the following  
host definition

<Host name="localhost" appBase="webapps"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">

but this meant the mycontext application was always visible in the  
manager and did not autodeploy when a war file was placed in  
$CATALINA/webapps (undeploy didn't appear to work either).  I tried  
without the Context wrapper and the JNDI lookups failed.

I see when an application is deployed tomcat makes it's own context  
configuration within $CATALINA/conf/Catalina/$HOST/$CONTEXT.xml which  
appears a good place to put the JNDI lookups.  Only problem is this  
file is removed by tomcat when the application is undeployed.

Am sure there must be a standard solution to this, so can anyone tell  
me how it is 'meant' to be done?

Thanks,
Darren

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


RE: Where to place JNDI sections for customer deployment

Posted by Tim Lucia <ti...@yahoo.com>.
Sorry - I was not clear.  You need to define the resources (not the
contexts), before you can refer to them.  In your context, you specify the
name (think symlink) of the resource as a reference, and in the global
context, the customer fills in a datasource, mailsession, etc., for that
name.

See here:

http://tomcat.apache.org/tomcat-5.5-doc/config/globalresources.html

Tim

> -----Original Message-----
> From: Darren [mailto:dledmonds@gmail.com] 
> Sent: Friday, February 17, 2006 7:15 PM
> To: Tomcat Users List
> Subject: Re: Where to place JNDI sections for customer deployment
> 
> 
> I have been testing this (as if I was a customer) so I can write  
> instructions for the customers.  I tried adding my JNDI entries into  
> $CATALINA/conf/server.xml within a Context declaration, but 
> it seemed  
> to prevent me deploying the war file correctly.  While testing I use  
> the manager application to deploy/undeploy, but when the 
> entries were  
> added into server.xml deploying no longer expanding the war file  
> automatically and undeploying did not work (probably because that  
> Context had an entry in server.xml).  If you restart tomcat, the war  
> file is expanded correctly so there is a way around this, but I'd  
> quite like customers to be able to deploy/undeploy without 
> trouble so  
> I can send them updated war files as necessary.
> 
> On 17 Feb 2006, at 17:18, Tim Lucia wrote:
> 
> > You should have the *customer* add these to the global data
> > sources, using
> > the admin tool, or by adding the xml fragments (you can ship) to  
> > server.xml
> > themselves.
> >
> > Tim
> >
> >
> > -----Original Message-----
> > From: Darren [mailto:dledmonds@gmail.com]
> > Sent: Friday, February 17, 2006 11:00 AM
> > To: users@tomcat.apache.org
> > Subject: Where to place JNDI sections for customer deployment
> >
> > Hi,
> >
> > I am running Tomcat 5.5.9 and would like to deploy an application
> > (as a war
> > file) to various customers, but I am having trouble finding the  
> > best place
> > for JNDI lookups.  During development I kept everything inside the  
> > war file
> > and placed my JNDI entries in $WAR/META-INF/ context.xml, but I  
> > don't want
> > customers to have to edit the context.xml in the war file on their  
> > systems.
> >
> > So, I added the following into $WAR/WEB_INF/web.xml
> >
> >    <resource-ref>
> >      <description>DB Connection</description>
> >      <res-ref-name>jdbc/db</res-ref-name>
> >      <res-type>javax.sql.DataSource</res-type>
> >      <res-auth>Container</res-auth>
> >    </resource-ref>
> >    <resource-ref>
> >      <description>Email Server Settings</description>
> >      <res-ref-name>bean/email</res-ref-name>
> >      <res-type>somepackage.EmailServerConfiguration</res-type>
> >      <res-auth>Container</res-auth>
> >    </resource-ref>
> >
> > Now I am unsure where to add the following ....
> >
> > <Context path="/mycontext" docBase="mycontext"
> >           crossContext="true" reloadable="true" debug="1">
> >
> >      <Resource name="jdbc/db" auth="Container" 
> > type="javax.sql.DataSource"
> >                maxActive="10" maxIdle="15" maxWait="10000"
> >                removeAbandoned="true" removeAbandonedTimeout="300" 
> > logAbandoned="true"
> >                driverClassName="com.mysql.jdbc.Driver"
> > username="user" password="pass"
> >                url="jdbc:mysql://localhost:3306/db?
> > autoReconnect=true" />
> >
> >      <Resource name="bean/email" auth="Container"
> >                type="somepackage.EmailServerConfiguration"
> >                factory="org.apache.naming.factory.BeanFactory"
> >                host="localhost" port="25" />
> >
> > </Context>
> >
> > I tried adding it into $CATALINA/conf/server.xml inside the
> > following host
> > definition
> >
> > <Host name="localhost" appBase="webapps"
> >         unpackWARs="true" autoDeploy="true"
> >         xmlValidation="false" xmlNamespaceAware="false">
> >
> > but this meant the mycontext application was always visible in the
> > manager
> > and did not autodeploy when a war file was placed in 
> $CATALINA/webapps
> > (undeploy didn't appear to work either).  I tried without 
> the Context
> > wrapper and the JNDI lookups failed.
> >
> > I see when an application is deployed tomcat makes it's own context 
> > configuration within 
> $CATALINA/conf/Catalina/$HOST/$CONTEXT.xml which 
> > appears a good place to put the JNDI lookups.  Only problem is this
> > file is
> > removed by tomcat when the application is undeployed.
> >
> > Am sure there must be a standard solution to this, so can anyone
> > tell me how
> > it is 'meant' to be done?
> >
> > Thanks,
> > Darren
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


Re: Where to place JNDI sections for customer deployment

Posted by Darren <dl...@gmail.com>.
I have been testing this (as if I was a customer) so I can write  
instructions for the customers.  I tried adding my JNDI entries into  
$CATALINA/conf/server.xml within a Context declaration, but it seemed  
to prevent me deploying the war file correctly.  While testing I use  
the manager application to deploy/undeploy, but when the entries were  
added into server.xml deploying no longer expanding the war file  
automatically and undeploying did not work (probably because that  
Context had an entry in server.xml).  If you restart tomcat, the war  
file is expanded correctly so there is a way around this, but I'd  
quite like customers to be able to deploy/undeploy without trouble so  
I can send them updated war files as necessary.

On 17 Feb 2006, at 17:18, Tim Lucia wrote:

> You should have the *customer* add these to the global data  
> sources, using
> the admin tool, or by adding the xml fragments (you can ship) to  
> server.xml
> themselves.
>
> Tim
>
>
> -----Original Message-----
> From: Darren [mailto:dledmonds@gmail.com]
> Sent: Friday, February 17, 2006 11:00 AM
> To: users@tomcat.apache.org
> Subject: Where to place JNDI sections for customer deployment
>
> Hi,
>
> I am running Tomcat 5.5.9 and would like to deploy an application  
> (as a war
> file) to various customers, but I am having trouble finding the  
> best place
> for JNDI lookups.  During development I kept everything inside the  
> war file
> and placed my JNDI entries in $WAR/META-INF/ context.xml, but I  
> don't want
> customers to have to edit the context.xml in the war file on their  
> systems.
>
> So, I added the following into $WAR/WEB_INF/web.xml
>
>    <resource-ref>
>      <description>DB Connection</description>
>      <res-ref-name>jdbc/db</res-ref-name>
>      <res-type>javax.sql.DataSource</res-type>
>      <res-auth>Container</res-auth>
>    </resource-ref>
>    <resource-ref>
>      <description>Email Server Settings</description>
>      <res-ref-name>bean/email</res-ref-name>
>      <res-type>somepackage.EmailServerConfiguration</res-type>
>      <res-auth>Container</res-auth>
>    </resource-ref>
>
> Now I am unsure where to add the following ....
>
> <Context path="/mycontext" docBase="mycontext"
>           crossContext="true" reloadable="true" debug="1">
>
>      <Resource name="jdbc/db" auth="Container"
> type="javax.sql.DataSource"
>                maxActive="10" maxIdle="15" maxWait="10000"
>                removeAbandoned="true" removeAbandonedTimeout="300"
> logAbandoned="true"
>                driverClassName="com.mysql.jdbc.Driver"
> username="user" password="pass"
>                url="jdbc:mysql://localhost:3306/db?
> autoReconnect=true" />
>
>      <Resource name="bean/email" auth="Container"
>                type="somepackage.EmailServerConfiguration"
>                factory="org.apache.naming.factory.BeanFactory"
>                host="localhost" port="25" />
>
> </Context>
>
> I tried adding it into $CATALINA/conf/server.xml inside the  
> following host
> definition
>
> <Host name="localhost" appBase="webapps"
>         unpackWARs="true" autoDeploy="true"
>         xmlValidation="false" xmlNamespaceAware="false">
>
> but this meant the mycontext application was always visible in the  
> manager
> and did not autodeploy when a war file was placed in $CATALINA/webapps
> (undeploy didn't appear to work either).  I tried without the Context
> wrapper and the JNDI lookups failed.
>
> I see when an application is deployed tomcat makes it's own context
> configuration within $CATALINA/conf/Catalina/$HOST/$CONTEXT.xml which
> appears a good place to put the JNDI lookups.  Only problem is this  
> file is
> removed by tomcat when the application is undeployed.
>
> Am sure there must be a standard solution to this, so can anyone  
> tell me how
> it is 'meant' to be done?
>
> Thanks,
> Darren
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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


RE: Where to place JNDI sections for customer deployment

Posted by Tim Lucia <ti...@yahoo.com>.
You should have the *customer* add these to the global data sources, using
the admin tool, or by adding the xml fragments (you can ship) to server.xml
themselves.

Tim
 

-----Original Message-----
From: Darren [mailto:dledmonds@gmail.com] 
Sent: Friday, February 17, 2006 11:00 AM
To: users@tomcat.apache.org
Subject: Where to place JNDI sections for customer deployment

Hi,

I am running Tomcat 5.5.9 and would like to deploy an application (as a war
file) to various customers, but I am having trouble finding the best place
for JNDI lookups.  During development I kept everything inside the war file
and placed my JNDI entries in $WAR/META-INF/ context.xml, but I don't want
customers to have to edit the context.xml in the war file on their systems.

So, I added the following into $WAR/WEB_INF/web.xml

   <resource-ref>
     <description>DB Connection</description>
     <res-ref-name>jdbc/db</res-ref-name>
     <res-type>javax.sql.DataSource</res-type>
     <res-auth>Container</res-auth>
   </resource-ref>
   <resource-ref>
     <description>Email Server Settings</description>
     <res-ref-name>bean/email</res-ref-name>
     <res-type>somepackage.EmailServerConfiguration</res-type>
     <res-auth>Container</res-auth>
   </resource-ref>

Now I am unsure where to add the following ....

<Context path="/mycontext" docBase="mycontext"
          crossContext="true" reloadable="true" debug="1">

     <Resource name="jdbc/db" auth="Container"  
type="javax.sql.DataSource"
               maxActive="10" maxIdle="15" maxWait="10000"
               removeAbandoned="true" removeAbandonedTimeout="300"  
logAbandoned="true"
               driverClassName="com.mysql.jdbc.Driver"  
username="user" password="pass"
               url="jdbc:mysql://localhost:3306/db? 
autoReconnect=true" />

     <Resource name="bean/email" auth="Container"
               type="somepackage.EmailServerConfiguration"
               factory="org.apache.naming.factory.BeanFactory"
               host="localhost" port="25" />

</Context>

I tried adding it into $CATALINA/conf/server.xml inside the following host
definition

<Host name="localhost" appBase="webapps"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">

but this meant the mycontext application was always visible in the manager
and did not autodeploy when a war file was placed in $CATALINA/webapps
(undeploy didn't appear to work either).  I tried without the Context
wrapper and the JNDI lookups failed.

I see when an application is deployed tomcat makes it's own context
configuration within $CATALINA/conf/Catalina/$HOST/$CONTEXT.xml which
appears a good place to put the JNDI lookups.  Only problem is this file is
removed by tomcat when the application is undeployed.

Am sure there must be a standard solution to this, so can anyone tell me how
it is 'meant' to be done?

Thanks,
Darren

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



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