Hi, On debugging Tomcat (7.0.59), I noticed that the SelectorContext is initialized twice when a lookup is performed for JNDI defined in web application (META-INF/context.xml). When the lookup is performed, the Servlet first calls the init method of InitailContext and this "returns new SelectorContext(env, true)". Then it calls the lookup method of InitialContext which again initializes the SelectorContext but now it "returns new SelectorContext(env)" [where the SelectorContextor.initialContext is set to *false*] and then the lookup is performed.
Why is tomcat initializing the SelectorContext twice here? My Java Webapp Code which does the lookup: *initCtx = new InitialContext();* *Context envContext = (Context) initCtx.lookup("java:comp/env");* *DataSource dataSource = (DataSource) envContext.lookup("*jdbc/contextDB *");* Resource defined in META-INF/context.xml in webapp: <Resource name="jdbc/contextDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="user" password="user123" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/WebAppTestDB"/> Regards, *Niranjan Karunanandham*