将 META-INF/context.xml 的内容移动到 tomcat/conf

发布于 2024-11-01 03:57:26 字数 1294 浏览 1 评论 0原文

我们试图从 war 文件中取出环境特定的配置设置,这样我们就可以将相同的 war 文件部署到 dev/test/prod tomcat 服务器,而不必更改 war 配置文件的内容。

当我将数据库连接的 META-INF/context.xml 移动到 conf/server.xml 时,数据库连接不再工作,出现以下错误,有人知道为什么会这样吗?

server.xml:

<GlobalNamingResources>
    ....
    <Resource
            url="jdbc:oracle:thin:@hostname:1521/something"
            username="username"
            name="jdbc/mydb"
            password="password"
            auth="Container"
            driverClassName="oracle.jdbc.driver.OracleDriver"
            maxActive="5" maxIdle="2" maxWait="10000"
            removeAbandoned="true"
            type="javax.sql.DataSource"
            />
</GlobalNamingResources>

错误如下:(

INFO: Deploying web application directory ROOT
Problem reading system configuration. Cannot create JDBC driver of class '' for connect URL 'null' (java.io.IOException: Cannot create JDBC driver of class '' for connect URL 'null')
java.io.IOException: Cannot create JDBC driver of class '' for connect URL 'null'
    at au.edu.unimelb.helper.SettingManager.loadSettings(SettingManager.java:212)
    at au.edu.unimelb.helper.SettingManager.<init>(SettingManager.java:53)

是的,odjbc6.jar 文件位于 $TOMCAT_HOME/lib/ 中)

We are trying to take the environment specific configuration settings out of our war files, so we can deploy the same war file to dev/test/prod tomcat servers and not have to change the contents of the war config file.

When I move the META-INF/context.xml for the database connection to the conf/server.xml the database connection no longer works, with the following error, anyone know why this would be?

server.xml:

<GlobalNamingResources>
    ....
    <Resource
            url="jdbc:oracle:thin:@hostname:1521/something"
            username="username"
            name="jdbc/mydb"
            password="password"
            auth="Container"
            driverClassName="oracle.jdbc.driver.OracleDriver"
            maxActive="5" maxIdle="2" maxWait="10000"
            removeAbandoned="true"
            type="javax.sql.DataSource"
            />
</GlobalNamingResources>

The error is as follows:

INFO: Deploying web application directory ROOT
Problem reading system configuration. Cannot create JDBC driver of class '' for connect URL 'null' (java.io.IOException: Cannot create JDBC driver of class '' for connect URL 'null')
java.io.IOException: Cannot create JDBC driver of class '' for connect URL 'null'
    at au.edu.unimelb.helper.SettingManager.loadSettings(SettingManager.java:212)
    at au.edu.unimelb.helper.SettingManager.<init>(SettingManager.java:53)

(And yes the odjbc6.jar file is in $TOMCAT_HOME/lib/)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

短叹 2024-11-08 03:57:26

终于解决了,tomcat文档有点误导。您可以将 META-INF/context.xml 的内容直接放入 $TOMCAT_HOME/conf/context.xml 中,它就可以正常工作。

Finally worked it out, the tomcat documentation was slightly misleading. You can put the contents of your META-INF/context.xml straight into $TOMCAT_HOME/conf/context.xml and it works just fine.

ˉ厌 2024-11-08 03:57:26

context.xml 中可能缺少 (在 Web 应用程序的 META-INF/context.xml$TOMCAT_HOME/conf/ 中) context.xml,如下所示:

        <ResourceLink name="jdbc/mydb"
              type="javax.sql.DataSource"
              global="jdbc/mydb"/> 

There might be missing a <ResourceLink> in context.xml (either in the web application's META-INF/context.xml or in $TOMCAT_HOME/conf/context.xml, like so:

        <ResourceLink name="jdbc/mydb"
              type="javax.sql.DataSource"
              global="jdbc/mydb"/> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文