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]

Reply via email to