I got it to work by removing the <env-entry> from web.xml. I believe
this is a regression because it works correctly under 5.5.17. Under
5.5.17 it finds the env entry with or without having defined in web.xml.
Under 6.0.33 having the env entry defined in web.xml *prevents* it from
finding it.


On Thu, 2011-09-22 at 09:10 -0700, Leo Donahue - PLANDEVX wrote:
> >-----Original Message-----
> >From: Tim Watts [mailto:t...@cliftonfarm.org]
> >Subject: [tomcat-6.0.33] META-INF/context.xml Environment not working
> >
> >=== context.xml ================================================
> ><Context unpackWAR="false" privileged="false"
> >antiResourceLocking="false" antiJARLocking="false">
> >     <Environment
> >             name="configName"
> >
> >     value="${catalina.base}/local/xbasic/config/master.properties"
> >             description="Full path name of the config file."
> >             type="java.lang.String"/>
> >
> ></Context>
> 
> 
> In my context.xml, I use type="javax.sql.DataSource", and I'm using a 
> <Resource> element instead of <Environment>
> 
>       <Resource
>         name="configName"
>               auth="Container"
>               type="javax.sql.DataSource"
>               username="username"
>               password="password"
>               driverClassName="whatever driver you have"
>             url="your jdbc driver connection stuff"/>
> 
>       <resource-ref>
>               <description>DB Connection</description>
>               <res-ref-name>configName</res-ref-name>
>               <res-type>javax.sql.DataSource</res-type>
>               <res-auth>Container</res-auth>
>       </resource-ref>
> 
> >=== web.xml ================================================
> ><?xml version="1.0" encoding="UTF-8"?>
> ><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >xmlns="http://java.sun.com/xml/ns/javaee";
> >xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
> >xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> >http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID"
> >version="2.5">
> >  <display-name>Archetype Created Web Application</display-name>
> >  <servlet>
> >    <servlet-name>Controller</servlet-name>
> >    <servlet-class>org.cliftonfarm.xbasic.Controller</servlet-class>
> >  </servlet>
> >  <servlet-mapping>
> >    <servlet-name>Controller</servlet-name>
> >    <url-pattern>/*</url-pattern>
> >  </servlet-mapping>
> >  <env-entry>
> >     <env-entry-name>configName</env-entry-name>
> >     <env-entry-type>java.lang.String</env-entry-type>
> >  </env-entry>
> ></web-app>
> 
> 
> I don't have a <env-entry> in my web.xml
> 
> 
> >=== Servlet constructor ========================================
> >public class Controller extends HttpServlet {
> >    private static final long serialVersionUID = 1L;
> >    private String configName;
> >
> >    /**
> >     * @throws NamingException
> >     * @see HttpServlet#HttpServlet()
> >     */
> >    public Controller() throws NamingException {
> >        super();
> >        // get & store JNDI info
> >        configName =
> >InitialContext.doLookup("java:comp/env/configName"); // line 28
> >        log(getClass().getName() +": Successfully initialized.
> >configName=[" +configName +"]");
> >    }
> >...
> 
> My version of this code, with your name:
> 
>     private DataSource ds;
> 
>     public void createDataSource(){
>         // Setup the DataSource Context
>         try{
>             Context ctx = new InitialContext();
>             ds = (DataSource) ctx.lookup("java:comp/env/configName");
> 
>         } catch (NamingException ex){
>             
> FacesContext.getCurrentInstance().getExternalContext().log("DataSource lookup 
> failed", ex);
>         }
>     }



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

Reply via email to