【问题标题】:Individual XML files located in $CATALINA_HOME/conf/[enginename]/[hostname]/位于 $CATALINA_HOME/conf/[enginename]/[hostname]/ 中的单个 XML 文件
【发布时间】:2013-02-11 21:19:33
【问题描述】:

我正在使用 tomcat 7 开发 Java Web 应用程序
我想在我的战争之外使用自定义名称拥有context.xml 文件。我在这个文件中定义了数据库资源。

根据tomcat documentation,我把context.xml.default文件放在CATALINA_HOME/conf/[enginename]/[hostname]/目录下,就可以得到数据库配置了。

现在,我想重命名 context.xml.default 并放置与我的上下文路径匹配的自定义文件名。如果这样做,我将无法再获取数据库配置,并且我的应用程序会抛出异常:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

这是我的context.xml.default 文件的内容:

<Context
crossContext="true"
reloadable="true" >

 <Resource
    name="jdbc/myDS"
    auth="Container"
    driverClassName="oracle.jdbc.driver.OracleDriver"
    factory="com...encription.util.EncryptedDataSourceFactory"
    logAbandoned="true"
    maxActive="30"
    maxIdle="10"
    maxWait="1000"
    password="encryptedPass"
    removeAbandoned="true"
    removeAbandonedTimeout="60"
    type="javax.sql.DataSource"
    url="jdbc:oracle:thin:@myIP:myPort:FRONT"
    username="username" />

【问题讨论】:

    标签: java tomcat configuration datasource context.xml


    【解决方案1】:

    我使用的配置是正确的,但问题是 eclipse 使用 {catalina_base}/wtpwebapps 目录来部署 Web 应用程序。

    我在 eclipse 的服务器配置中用 webapps 更改了 wtpwebapps 文件夹 现在一切正常。

    【讨论】:

    • 很高兴您发现了错误。但是看到我写完整问题的意思了吗?你从来没有提到任何关于在 Eclipse 中运行的事情......
    【解决方案2】:

    错误可能是由于缺少 JDBC 驱动程序造成的。尝试将 Oracle 驱动程序放入 %TOMCAT_HOME%/common/lib 目录。

    另一种可能性是,您在 conf/catalina/localhost 中缺少特定于 Web 应用程序的 context.xml(名为 &lt;NAME_OF_WEBAPP&gt;.xml)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-16
      • 2012-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-25
      相关资源
      最近更新 更多