Weblogic與tomcat的數據源配置不同,每次在本地跑時都得修改數據源配置, java
aaDs要改爲java:/comp/env/aaDs apache
索性本身編譯一個tomcat去掉前面的java:/comp/env/ tomcat
過程以下. spa
Tomcat的源碼下載及編譯在此再也不贅述,只說明修改的地方. debug
true改成false code
public Context getInitialContext(Hashtable environment) throws NamingException { if (ContextBindings.isThreadBound() || (ContextBindings.isClassLoaderBound())) { // Redirect the request to the bound initial context //true改成false return new SelectorContext(environment, false); } else { // If the thread is not bound, return a shared writable context if (initialContext == null) initialContext = new NamingContext(environment, MAIN); return initialContext; } }
不判斷initialContext直接返回name blog
protected String parseName(String name) throws NamingException { if ((!initialContext) && (name.startsWith(prefix))) { return (name.substring(prefixLength)); } else { //不判斷initialContext直接返回name // if (initialContext) { return (name); /* } else { throw new NamingException (sm.getString("selectorContext.noJavaUrl")); }*/ } }
直接取namingContext做爲compCtx, envCtx不做叛斷
get
private void createNamingContext() throws NamingException { // Creating the comp subcontext //直接取namingContext做爲compCtx, envCtx不做叛斷 // if (container instanceof Server) { compCtx = namingContext; envCtx = namingContext; /* } else { compCtx = namingContext.createSubcontext("comp"); envCtx = compCtx.createSubcontext("env"); }*/ int i; if (log.isDebugEnabled()) log.debug("Creating JNDI naming context"); if (namingResources == null) { namingResources = new NamingResources(); namingResources.setContainer(container); }