【发布时间】:2015-08-11 23:05:02
【问题描述】:
我面临与 WAS 插件文件夹中的 jar 相关的类路径问题。我的应用程序具有 IBM 特定代码,可以使用 com.ibm.ws.runtime jar 进行编译,如下所述。
位置:C:\Program Files\IBM\Websphere\AppServer\Plugins
源代码:
对象 obj = ((com.ibm.ws.rsadapter.jdbc.WSJdbcUtil.getNativeConnection((com.ibm.ws.rsadapter.jdbc.WSJdbcConnection)connect )));
这两个类都在 com.ibm.ws.runtime 中可用
通过在构建过程的类路径中包含 IBM runtime.jar 成功编译,但在 WAS 中部署后,我得到 ClassNotFoundException。谁能告诉我,如何在 WAS 的类路径中包含该插件文件夹,这样我就不会得到 ClassNotFoundException。我在 JVM 类路径中只添加了 runtime.jar,但它会抛出错误,因为它依赖于 IBM 的其他 jar。
错误: 原因:java.lang.ClassNotFoundException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection
更新: 目前它与 Jboss 服务器完美配合。代码如下。我的目标是提供与 Webpshere 相同的规定。
调用方法:
Connection connect = null;
connect = mDataSrc.getConnection();
unlockJDBC(connect);
private void unlockJDBC(Connection connect)
{
//This bit is JBoss specific but we are trying to avoid importing JBoss JAR files so we use reflection instead.
if (connect.getClass().getName().equals("org.jboss.resource.adapter.jdbc.WrappedConnection") || connect.getClass().getSuperclass().getName().equals("org.jboss.resource.adapter.jdbc.WrappedConnection"))
{
Method method = null;
try{
method = connect.getClass().getMethod("getUnderlyingConnection",null);
Connection conn = (Connection)method.invoke(connect, null);
if (conn != null){
connect = conn;
}
}
catch (InvocationTargetException e){
mLogger.severe(e.getTargetException().getMessage());
}
catch (Exception e){
mLogger.severe(e.toString());
}
}
if (connect instanceof ExtEmbeddedConnection){
ExtEmbeddedConnection embConnect = (ExtEmbeddedConnection)connect;
try{
embConnect.unlock("unlock");
}
catch (Exception e){
mLogger.severe(e.toString());
}
}
【问题讨论】:
标签: java jdbc websphere websphere-8