0

I am getting below error in Eclipse console when i try to start the web sphere LP server (WP 7).

[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)

I have added the required datasource in my 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 Jars are in the give location. Am i missing something or any pointer how to debug this ??

Thanks

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
Arbind Singh
  • 153
  • 1
  • 2
  • 12
  • your server.xml looks correct. Can you show the full stack trace of the CNFE? As well as any of your application's java code leading up the the stack CNFE – Andy Guibert Oct 06 '17 at 17:05
  • Are the db2jcc*.jar files really existing at ${server.config.dir}/resources/DB2 directory ? – M. Tamboli Oct 06 '17 at 17:30
  • @AndyGuibert Attached full error trace – Arbind Singh Oct 06 '17 at 17:41
  • @M.Tamboli Yes they exist. I have used design mode to get all jars included. – Arbind Singh Oct 06 '17 at 17:42
  • the second part of @njr 's answer has the fix to your issue. Namely, if something in your app (or libs your app is using) is using the JDBC driver classes directly, you also need to configure you application to have visibility to the JDBC library jars (by nesting a `` element under your ` – Andy Guibert Oct 06 '17 at 20:17

1 Answers1

2

If using a dataSource in server configuration, Liberty would try to load data source implementation classes such as

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

rather than the driver class that shows in the exception,

com.ibm.db2.jcc.DB2Driver

so a good guess (lacking the exception stack) is that your application may be trying to use DriverManager.getConnection instead of using the configured dataSource. If you really want to do this (you will be losing out on many capabilities provided by the application server such as global transaction enlistment and connection pooling) then you would need to make the JDBC driver libraries directly available to your application. For example,

<application location=...>
  <classloader commonLibraryRef="DB2JCCLib"/>
</application>
njr
  • 3,399
  • 9
  • 7