admin管理员组文章数量:1434949
I am setting up a legacy Web application and having a few questions. Currently the web application packed ojdbc jar under WEB-INF/lib
and Tomcat context.xml
has a resource tag referring to JNDI datasoure. It's Oracle database so the connection string is through oci
(I am using Windows system)
<Resource name="jdbc/MainSource"
auth="Container" type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:oci:@username/password@tnsinstance"
validationQuery="SELECT sysdate from DUAL;"
jdbcInterceptors="ConectionState" />
From what I can see, the Tomcat server don't have any ojdbc.jar
under $CATALINA_HOME/lib
directory. Then here are my questions
- How could the application run on JNDI if ojdbc is only available under
WEB-INF/lib
? - Does OCI exempt the JNDI from providing the ojdbc jar (my understanding, it should not because Tomcat still look for implementation of
driverClassName
)?
Updated: A little further details to question2 - there is Oracle client installed on the server and within the installation there is ojdbc jar file, which should be in $PATH
after ORACLE_HOME
being registered. However I still don't think Tomcat server will reach out to OS $PATH
to get ojdbc jar even if it is an Oracle OCI connection, according to Tomcat JNDI doc
I am setting up a legacy Web application and having a few questions. Currently the web application packed ojdbc jar under WEB-INF/lib
and Tomcat context.xml
has a resource tag referring to JNDI datasoure. It's Oracle database so the connection string is through oci
(I am using Windows system)
<Resource name="jdbc/MainSource"
auth="Container" type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:oci:@username/password@tnsinstance"
validationQuery="SELECT sysdate from DUAL;"
jdbcInterceptors="ConectionState" />
From what I can see, the Tomcat server don't have any ojdbc.jar
under $CATALINA_HOME/lib
directory. Then here are my questions
- How could the application run on JNDI if ojdbc is only available under
WEB-INF/lib
? - Does OCI exempt the JNDI from providing the ojdbc jar (my understanding, it should not because Tomcat still look for implementation of
driverClassName
)?
Updated: A little further details to question2 - there is Oracle client installed on the server and within the installation there is ojdbc jar file, which should be in $PATH
after ORACLE_HOME
being registered. However I still don't think Tomcat server will reach out to OS $PATH
to get ojdbc jar even if it is an Oracle OCI connection, according to Tomcat JNDI doc
- You should provide more detailed information, how your application gets a connection to the database and clarify your problem. – Roman C Commented Nov 17, 2024 at 16:01
2 Answers
Reset to default 0Fallback to application-scoped resources occurs when an application avoids using the container-managed JNDI datasource and instead relies on resources bundled and loaded within the application itself. This can happen due to explicit configuration or as a backup mechanism when JNDI resources fail to initialise.
If the ojdbc.jar is missing from $CATALINA_HOME/lib, Tomcat cannot initialise the JNDI datasource, however, the application can still function if it directly loads the driver from WEB-INF/lib. Many legacy web applications were not designed to use container-managed JNDI datasources by default. They often have hardcoded connection logic as a fallback.
- You should put ojdbc jar in $CATALINA_HOME/lib.
- No
版权声明:本文标题:java - Tomcat - Oracle JNDI connection - how application can run without ojdbc jar in $CATALINA_HOMElib - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745630763a2667260.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论