DB2 datasource

I’m having trouble with a db2 datasource, I have added the db2 jar files and actually was able to create and verify the datasource, but receive the following error when I try to run a query.

Lucee 5.0.0.252 Error (java.lang.ClassNotFoundException)
Message	sun.io.ByteToCharConverter
Cause	java.lang.ClassNotFoundException

Java Stacktrace	lucee.runtime.exp.NativeException: sun.io.ByteToCharConverter 
 	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
 	at com.ibm.db2.jcc.c.r.a(r.java:151) 
 	at com.ibm.db2.jcc.a.d.a(d.java:971) 
 	at com.ibm.db2.jcc.a.db.a(db.java:1721) 
 	at com.ibm.db2.jcc.a.db.a(db.java:1649) 
 	at com.ibm.db2.jcc.a.db.n(db.java:569) 
 	at com.ibm.db2.jcc.a.db.j(db.java:256) 
 	at com.ibm.db2.jcc.a.db.c(db.java:56) 
 	at com.ibm.db2.jcc.a.r.c(r.java:53) 
 	at com.ibm.db2.jcc.a.sb.h(sb.java:166) 
 	at com.ibm.db2.jcc.c.yc.n(yc.java:1129) 
 	at com.ibm.db2.jcc.c.yc.a(yc.java:1765) 
 	at com.ibm.db2.jcc.c.yc.e(yc.java:707) 
 	at com.ibm.db2.jcc.c.yc.execute(yc.java:691) 
 	at lucee.runtime.type.util.QueryUtil.execute(QueryUtil.java:257) 
 	at lucee.runtime.type.QueryImpl.execute(QueryImpl.java:265) 
 	at lucee.runtime.type.QueryImpl.(QueryImpl.java:219) 
 	at lucee.runtime.tag.Query.executeDatasoure(Query.java:820) 
 	at lucee.runtime.tag.Query.doEndTag(Query.java:583) 
 	at promocodes.queries.qrylistpromocodes_cfm$cf.call(E:\lucee\tomcat\webapps\ROOT\promoCodes\queries\qryListPromoCodes.cfm:16) 
 	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:863) 
 	at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:808) 
 	at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:803) 
 	at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:794) 
 	at promocodes.display.dspcodes_cfm$cf.call(E:\lucee\tomcat\webapps\ROOT\promoCodes\display\dspCodes.cfm:1) 
 	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:863) 
 	at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:808) 
 	at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:803) 
 	at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:794) 
 	at promocodes.index_cfm$cf.call(E:\lucee\tomcat\webapps\ROOT\promoCodes\index.cfm:47) 
 	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:863) 
 	at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:808) 
 	at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:803) 
 	at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:226) 
 	at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:43) 
 	at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2250) 
 	at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2242) 
 	at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2210) 
 	at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:846) 
 	at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:103) 
 	at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:62) 
 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) 
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 
 	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) 
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 
 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) 
 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) 
 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) 
 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) 
 	at mod_cfml.core.invoke(core.java:152) 
 	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) 
 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) 
 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528) 
 	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099) 
 	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) 
 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520) 
 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476) 
 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
 	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
 	at java.lang.Thread.run(Thread.java:745) 
 Caused by: java.lang.ClassNotFoundException: sun.io.ByteToCharConverter 
 	... 66 more

Looks like the JDBC driver is attempting to use sun.io.ByteToCharConverter and it cannot find it. That class is probably only part of the Oracle (formerly Sun) JRE. Are you using OpenJDK or the Oracle version?


Pete Freitag
https://foundeo.com/

I’m using the oracle version of Java and the driver is from IBM

Possibly the version of the driver you are using is not compatible with Java 8 (because it is using this undocumented class, which Oracle may have removed):

1 Like

I had actually ran across the same article, and had added the db2jcc4.jar version of the driver. Problem was, I left the db2jcc.jar file in the directory so it was still using that version. Now that I removed the file and restarted, I can now run queries.

Thanks for your help