当前位置:   article > 正文

Tomcat中JNDI数据源去掉java:/comp/env/_tomcat context 怎么清掉添加的源码

tomcat context 怎么清掉添加的源码

http://my.oschina.net/u/574870/blog/193782

摘要
Tomcat 中JNDI数据源去掉java:/comp/env/

 

Weblogictomcat的数据源配置不一样,每次在本地跑时都得修改数据源配置,

aaDs要改成java:/comp/env/aaDs

索性自己编译一个tomcat去掉前面的java:/comp/env/

过程如下.

Tomcat的源码下载及编译在此不再赘述,只说明修改的地方.

修改org.apache.naming.java.javaURLContextFactory getInitialContext方法,

true改为false

  1. public Context getInitialContext(Hashtable environment)
  2. throws NamingException {
  3. if (ContextBindings.isThreadBound() ||
  4. (ContextBindings.isClassLoaderBound())) {
  5. // Redirect the request to the bound initial context
  6. //true改为false
  7. return new SelectorContext(environment, false);
  8. } else {
  9. // If the thread is not bound, return a shared writable context
  10. if (initialContext == null)
  11. initialContext = new NamingContext(environment, MAIN);
  12. return initialContext;
  13. }
  14. }




修改org.apache.naming.SelectorContextparseName方法,

不判断initialContext直接返回name

  1. protected String parseName(String name)
  2. throws NamingException {
  3. if ((!initialContext) && (name.startsWith(prefix))) {
  4. return (name.substring(prefixLength));
  5. } else {
  6. //不判断initialContext直接返回name
  7. // if (initialContext) {
  8. return (name);
  9. /* } else {
  10. throw new NamingException
  11. (sm.getString("selectorContext.noJavaUrl"));
  12. }*/
  13. }
  14. }




修改org.apache.catalina.core. NamingContextListenerparseName方法,

直接取namingContext作为compCtx, envCtx不作叛断

  1. private void createNamingContext()
  2. throws NamingException {
  3. // Creating the comp subcontext
  4. //直接取namingContext作为compCtx, envCtx不作叛断
  5. // if (container instanceof Server) {
  6. compCtx = namingContext;
  7. envCtx = namingContext;
  8. /* } else {
  9. compCtx = namingContext.createSubcontext("comp");
  10. envCtx = compCtx.createSubcontext("env");
  11. }*/
  12. int i;
  13. if (log.isDebugEnabled())
  14. log.debug("Creating JNDI naming context");
  15. if (namingResources == null) {
  16. namingResources = new NamingResources();
  17. namingResources.setContainer(container);
  18. }





声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/239507
推荐阅读
相关标签
  

闽ICP备14008679号