eclipse Tomcat JNDI 资源 - 找不到类:oracle.jdbc.xa.client.OracleXADataSource
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6472494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tomcat JNDI Resource - Class not found: oracle.jdbc.xa.client.OracleXADataSource
提问by John Strickler
The Problem
问题
Anytime I start my Tomcat server via Eclipse I always get a Class not founderror:
每当我通过 Eclipse 启动我的 Tomcat 服务器时,我总是得到一个Class not found错误:
SEVERE: Exception processing Global JNDI Resources
javax.naming.NamingException: Class not found: oracle.jdbc.xa.client.OracleXADataSource
at org.apache.naming.factory.BeanFactory.getObjectInstance(BeanFactory.java:136)
The Setup
设置
My server.xmlfile has a resource setup like:
我的server.xml文件有一个资源设置,如:
<GlobalNamingResources>
<Resource name="sub1" auth="Container"
type="oracle.jdbc.xa.client.OracleXADataSource"
factory="org.apache.naming.factory.BeanFactory"
user="****" password="*****"
URL="**************************************" />
</GlobalNamingResources>
context.xmlhas an entry that looks like so:
context.xml有一个看起来像这样的条目:
<ResourceLink name="dataSource/sub1" global="sub1" type="javax.sql.DataSource" />
On my application, I'm using Oracle's JDBC driver - classes12.jar
在我的应用程序中,我使用 Oracle 的 JDBC 驱动程序 - classes12.jar
The Question
问题
What do I need to fix on the Tomcat server so that it can find the appropriate class - oracle.jdbc.xa.client.OracleXADataSource
. My first guess would be that classes12.jarneeds to be copied to a folder somewhere on the server. I'm not even totally sure where the folder on Windows for Eclipse... any help would be appreciated.
我需要在 Tomcat 服务器上修复什么才能找到合适的类 - oracle.jdbc.xa.client.OracleXADataSource
. 我的第一个猜测是需要将classes12.jar复制到服务器上某处的文件夹中。我什至不完全确定 Windows 上的 Eclipse 文件夹在哪里......任何帮助将不胜感激。
Thanks!
谢谢!
回答by Vineet Reynolds
Assuming Tomcat 6, the required library needs to be copied to $CATALINA_HOME\lib
.
假设Tomcat 6,需要将需要的库复制到$CATALINA_HOME\lib
.
From the Tomcat documentation on setting up JDBC DataSources:
从关于设置 JDBC DataSources的Tomcat 文档:
1. Install Your JDBC Driver
Use of the JDBC Data Sources JNDI Resource Factory requires that you make an appropriate JDBC driver available to both Tomcat internal classes and to your web application. This is most easily accomplished by installing the driver's JAR file(s) into the $CATALINA_HOME/lib directory, which makes the driver available both to the resource factory and to your application.
1. 安装您的 JDBC 驱动程序
JDBC 数据源的使用 JNDI 资源工厂要求您为 Tomcat 内部类和 Web 应用程序提供适当的 JDBC 驱动程序。这最容易通过将驱动程序的 JAR 文件安装到 $CATALINA_HOME/lib 目录中来实现,这使得驱动程序可用于资源工厂和您的应用程序。
Also, I would avoid using classes12.zip
. It is meant to be used in Java 1.2 and 1.3 runtime environments only. Use ojdbc14.jar
if you are stuck with Java 1.4. Or use the recommended ojdbc6.jar
/ojdbc5.jar
for the Java 6 or Java 5 environments.
另外,我会避免使用classes12.zip
. 它仅适用于 Java 1.2 和 1.3 运行时环境。使用ojdbc14.jar
,如果你被卡住的Java 1.4。或者为 Java 6 或 Java 5 环境使用推荐的ojdbc6.jar
/ ojdbc5.jar
。
回答by Matt Ball
The simplest fix, assuming that OracleXADataSource
is a class in classes12.jar
, is to copy that JAR into Tomcat's lib directory.
假设它OracleXADataSource
是 中的一个类,最简单的修复方法classes12.jar
是将该 JAR 复制到Tomcat 的 lib 目录中。
- Tomcat 5:
$CATALINA_HOME/common/lib
- Tomcat 6:
$CATALINA_HOME/lib
- 雄猫5:
$CATALINA_HOME/common/lib
- 雄猫6:
$CATALINA_HOME/lib
回答by duffymo
Not classes12.jar; that's JDK 1.2 vintage. Your Oracle JDBC driver JAR ought to match your JDK and Oracle versions (e.g. ojdbc16.jar for JDK 1.6).
不是classes12.jar;那是 JDK 1.2 版本。您的 Oracle JDBC 驱动程序 JAR 应该与您的 JDK 和 Oracle 版本匹配(例如 JDK 1.6 的 ojdbc16.jar)。
Put that in your Tomcat /server/lib for Tomcat version 5.x and /lib for Tomcat version 6.x and higher.
对于 Tomcat 5.x 版,请将其放入 Tomcat /server/lib 中,对于 Tomcat 6.x 版及更高版本,请将其放在 /lib 中。
I'd also recommend not altering your server.xml file. Better to put that information in your project's META-INF/context.xml file.
我还建议不要更改您的 server.xml 文件。最好将该信息放在项目的 META-INF/context.xml 文件中。
回答by JB Nizet
From the documentation:
从文档:
Drivers for older Oracle versions may be distributed as *.zip files rather than *.jar files. Tomcat will only use *.jar files installed in $CATALINA_HOME/lib
旧 Oracle 版本的驱动程序可能以 *.zip 文件而不是 *.jar 文件的形式分发。Tomcat 将只使用安装在 $CATALINA_HOME/lib 中的 *.jar 文件
So yes, you have to put the jar in $CATALINA_HOME/lib
所以是的,你必须把罐子放在 $CATALINA_HOME/lib
回答by Srikanth Venkatesh
Copy the classes12.jar in tomcat's /common/lib directory .
复制tomcat的/common/lib目录下的classes12.jar。