Tomcat JNDI资源名称别名 [英] Tomcat JNDI resource name aliases

查看:120
本文介绍了Tomcat JNDI资源名称别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建具有多个名称(同义词,别名)的JNDI Tomcat资源?
类似于

Is it possible to create a JNDI tomcat resource with multiple names (synonyms, aliases)? Something like

<Resource
      name="jdbc/product-ds"
      alias="jdbc/product-cfg-ds"
      type="com.mchange.v2.c3p0.ComboPooledDataSource"
      ...
/>

我需要这个,因为有两个模块使用相同的DataSource,但具有不同的JNDI名称。最简单的解决方案是同步这些名称,但是不幸的是,目前尚无法实现。

I need this, because there are two modules which use the same DataSource, but with different JNDI name. The simplest solution will be to sync those names, but unfortunately it's not possible at the moment.

推荐答案

您可以执行此操作。我花了一段时间才弄清楚正确的顺序。您需要做的是在GlobalNamingResources部分的server.xml(tomcat / conf / server.xml)中定义jdbc / product-ds,如下所示:

You can do this. It took me a while to work out the correct sequence. What you need to do is define the jdbc/product-ds in your server.xml (tomcat/conf/server.xml) in the GlobalNamingResources section kind of like this:

    <GlobalNamingResources>
        <Resource name="jdbc/product-ds " auth="Container"
          type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
          url="jdbc:oracle:thin:@127.0.0.1:1521:mysid"
          username="scott" password="tiger" maxActive="20" maxIdle="10"
          maxWait="-1"/>
    </GlobalNamingResources>

然后您可以在服务器context.xml(tomcat / conf / context.xml)中重命名

Then you can rename this in your server context.xml (tomcat/conf/context.xml)

就像这样:

<ResourceLink 
        name="jdbc/product-cfg-ds"
        global="jdbc/product-ds"
        type="javax.sql.DataSource"/>

然后为服务器上部署的所有应用程序重命名全局名称。我不认为全局jdbc / product-ds可以在任何应用程序中使用,如果您确实想要它,则需要添加:

The global name is then renamed for all applications deployed on the the server. I don't think the global jdbc/product-ds will be available in any application, if you did want it you'd need to add:

<ResourceLink 
        name="jdbc/product-ds"
        global="jdbc/product-ds"
        type="javax.sql.DataSource"/>

这篇关于Tomcat JNDI资源名称别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆