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:[EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
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]

Reply via email to