Adding datasource programmatically to JNDI context in embedded tomcat 7
问题 I'm trying to register a new datasource before the server starts but on lookup execution I'm getting javax.naming.NameNotFoundException: Name [jdbc/db] is not bound in this Context. Unable to find [jdbc]. This is how I start tomcat: Tomcat tomcat = new Tomcat(); //... ContextResource resource = new ContextResource(); resource.setName("jdbc/db"); resource.setAuth("Container"); resource.setType("javax.sql.DataSource"); resource.setScope("Sharable"); resource.setProperty("driverClassName", "org