2017-10-06 62 views
0

當我嘗試啓動Web球體LP服務器(WP 7)時,在Eclipse控制檯中出現錯誤。啓動WAS LP服務器時發生錯誤ClassNotFoundException:com.ibm.db2.jcc.DB2Driver

[2017-10-06 12:04:46,952] [ERROR] com.ibatis.common.logging.jakarta.JakartaCommonsLoggingImpl.error [19] SimpleDataSource: Error while loading properties. Cause: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver 
java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver 
    at java.lang.Class.forNameImpl(Native Method) 
    at java.lang.Class.forName(Class.java:278) 
    at com.ibatis.common.resources.Resources.classForName(Resources.java:267) 
    at com.ibatis.common.resources.Resources.instantiate(Resources.java:283) 
    at com.ibatis.common.jdbc.SimpleDataSource.initialize(SimpleDataSource.java:199) 
    at com.ibatis.common.jdbc.SimpleDataSource.<init>(SimpleDataSource.java:116) 
    at com.ibatis.sqlmap.engine.datasource.SimpleDataSourceFactory.initialize(SimpleDataSourceFactory.java:31) 
    at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$9.process(SqlMapConfigParser.java:220) 
    at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121) 
    at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:105) 
    at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102) 
    at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102) 
    at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72) 
    at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51) 
    at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46) 
    at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63) 
    at com.pm.testdatamgt.persistence.util.SqlMapBuilder.build(SqlMapBuilder.java:67) 
    at com.pm.testdatamgt.persistence.util.SqlMapConfig.<clinit>(SqlMapConfig.java:71) 
    at com.pm.testdatamgt.persistence.util.SqlMapConfigFactory.getSqlMapInstance(SqlMapConfigFactory.java:37) 
    at com.pm.persistence.dao.impl.ReferenceCodeDaoImpl.getRefCatIdForSname(ReferenceCodeDaoImpl.java:95) 
    at com.pm..service.impl.ReferenceCodeServiceImpl.initAttributeNames(ReferenceCodeServiceImpl.java:99) 
    at com.pm.testdatamgt.startup.StartupServlet.loadVariables(StartupServlet.java:139) 
    at com.pm.testdatamgt.startup.StartupServlet.init(StartupServlet.java:125) 
    at javax.servlet.GenericServlet.init(GenericServlet.java:244) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1428) 
    at com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:1205) 
    at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:1173) 
    at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1075) 
    at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6595) 
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:468) 
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApplication(DynamicVirtualHost.java:463) 
    at com.ibm.ws.webcontainer.osgi.WebContainer.startWebApplication(WebContainer.java:1120) 
    at com.ibm.ws.webcontainer.osgi.WebContainer.access$000(WebContainer.java:104) 
    at com.ibm.ws.webcontainer.osgi.WebContainer$2.run(WebContainer.java:932) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:522) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:277) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 
    at java.lang.Thread.run(Thread.java:785) 

我已經添加了所需的數據源在我的server.xml

**<library id="DB2JCCLib"> 
     <fileset dir="${server.config.dir}/resources/DB2" includes="db2jcc.jar, db2jcc_license_cisuz.jar, db2jcc_license_cu.jar"/> 
</library> 
dataSource id="db2" jndiName="jdbc/db2"> 
    <jdbcDriver libraryRef="DB2JCCLib"> 
    </jdbcDriver> 
    <properties.db2.jcc databaseName="DB2" serverName="tsoc.nnnn.com" portNumber="5002"/> 
</dataSource>** 

DB2罐子是在給定的位置。 我缺少的東西或任何指針如何調試?

感謝

+0

您的server.xml看起來是正確的。你可以展示CNFE的完整堆棧跟蹤嗎?以及任何導致堆棧的應用程序的Java代碼CNFE –

+0

db2jcc * .jar文件是否確實存在於$ {server.config.dir}/resources/DB2目錄中? –

+0

@AndyGuibert附加完整的錯誤跟蹤 –

回答

2

如果使用在服務器配置一個數據源,自由會嘗試加載數據源的實現類,如

com.ibm.db2.jcc.DB2DataSource 
com.ibm.db2.jcc.DB2ConnectionPoolDataSource 
com.ibm.db2.jcc.DB2XADataSource 

,而不是驅動程序類,顯示的異常,

com.ibm.db2.jcc.DB2Driver 

所以一個很好的猜測(缺少異常堆棧)是您的應用程序可能試圖使用DriverManager.getConnection而不是使用co配置的數據源。如果您真的想這樣做(您將失去應用服務器提供的許多功能,如全局事務登記和連接池),那麼您需要使JDBC驅動程序庫直接供您的應用程序使用。 例如,

<application location=...> 
    <classloader commonLibraryRef="DB2JCCLib"/> 
</application> 
+0

謝謝。它解決了我的問題。 –