1

I have a project which was on WebSphere 7.0. Currently I am carrying it to EAP 6.4. Java version is 1.6.

DB2 is the database I use. And the same driver that I used earlier in websphere is set under modules of jboss. Database connection is OK. But after Executequery method run I get the error

  JBWEB000289: Servlet InitServlet threw load() exception: 
  java.lang.ClassNotFoundException: sun.io.ByteToCharConverter from 

I googled it a lot and the only solution I found that I tried is setting

  -Ddb2.jcc.charsetDecoderEncoder=3

I set this under VM arguments of runtime, jboss eap 6.4.

I also tried to set this prop to properties that I set before database execution.

   props.setProperty("db2.jcc.charsetDecoderEncoder", "3");

But problem still exists.

This is the error message that I get. And it still exists.

  JBWEB000289: Servlet InitServlet threw load() exception: 
  java.lang.ClassNotFoundException: sun.io.ByteToCharConverter from

Here is the full log:

    14:41:38,389 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/cantekWeb]] (ServerService Thread Pool -- 62) 
    JBWEB000289: Servlet InitServlet threw load() exception: java.lang.ClassNotFoundException: sun.io.ByteToCharConverter from 
    [Module "deployment.cantek.ear.cantekWeb.war:main" from Service Module Loader]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.6.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.6.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.6.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.6.Final-redhat-1]
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.6.Final-redhat-1]
        at com.ibm.db2.jcc.b.r.a(r.java:157) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.c.d.a(d.java:986) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.c.fb.a(fb.java:1723) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.c.fb.a(fb.java:1651) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.c.fb.n(fb.java:570) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.c.fb.j(fb.java:257) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.c.fb.c(fb.java:57) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.c.s.c(s.java:42) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.c.wb.h(wb.java:169) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.b.id.p(id.java:1246) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.b.jd.a(jd.java:2275) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.b.jd.V(jd.java:505) [db2jcc-0.0.1.jar:]
        at com.ibm.db2.jcc.b.jd.executeQuery(jd.java:488) [db2jcc-0.0.1.jar:]
        at com.cimmy.service.data.Talep.loadSikayetKonular(Talep.java:138) [classes:]
        at com.cimmy.service.servlet.InitServlet.sikayetKonulari(InitServlet.java:472) [classes:]
        at com.cimmy.service.servlet.InitServlet.load(InitServlet.java:412) [classes:]
        at com.cimmy.service.servlet.InitServlet.init(InitServlet.java:220) [classes:]
        at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-2.jar:1.0.2.Final-redhat-2]
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1194) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1100) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3593) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:3802) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
        at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
        at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
        at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.0.Final-redhat-21.jar:7.5.0.Final-redhat-21]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [rt.jar:1.8.0_211]
        at java.util.concurrent.FutureTask.run(Unknown Source) [rt.jar:1.8.0_211]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_211]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_211]
        at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_211]
        at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Cantek Çetin
  • 41
  • 1
  • 7

2 Answers2

0

You should never use sun.* packages in your code. Not only are they not guaranteed to get carried over with new versions of Java, but as you noticed, some web containers will even prevent them being accessed at all.

I understand that in this case, the problem might be with the driver itself and not the code that you yourself have written. However, the above still applies. If the driver is open-source, you might want to tweak with the code, however, you might also upgrade to a newer version of the driver. You can find more details here:

NoClassDefFoundError sun/io/ByteToCharConverter with InterBase JDBC driver

or here:

https://www-01.ibm.com/support/docview.wss?uid=swg1IC74895

(the resolution suggests "Fixed in DB2 V9.7 FP5 JDBC drivers.")

Piotr Wilkin
  • 3,446
  • 10
  • 18
  • So, which version of the driver are you using? Have you tried using the newest version from here: http://www-01.ibm.com/support/docview.wss?uid=swg21363866 ? – Piotr Wilkin Jun 18 '19 at 11:05
  • Hi,thanks for the answer. I already checked all these pages and tried the solutions. but mostly problem occurs when they use Java 8. I am using Java 6 and still problem occurs. As mentioned in my question I have tried setting the suggested parameter to jvm start command. Nothing changed. I also tried to set it in the code. Results are same. I am using JBoss as server now. EAP 6.4, I have rt.jar in jre liblary folder. And project gets it properly. I really did not have a clue why this occurs. – Cantek Çetin Jun 18 '19 at 11:07
  • It's not about the rt.jar. It's about the webserver's classloader explicitly denying the loading of classes which are in the sun.* hierarchy. You might want to use a newer version of the DB2 driver. If you don't want to force that, you can instead tell EAP to forcefully allow loading the sun.* classes as mentioned here: https://stackoverflow.com/questions/43327178/jboss-eap-6-4-noclassdeffounderror-on-class-sun-security-jca-getinstance – Piotr Wilkin Jun 18 '19 at 11:09
  • I have tried both 3.72.44 version of db2jcc and 4.24.92 version of db2jcc4. both failed. – Cantek Çetin Jun 18 '19 at 11:12
  • Okay, then try enabling those imports manually in the webserver as described above. – Piotr Wilkin Jun 18 '19 at 11:15
  • I have these in my sun/jdk/main/modules.xml Arent these enough for that? Or should I create an other module including only these and make it global in standalone.xml like the requster did in referenced question? etc.... – Cantek Çetin Jun 18 '19 at 11:21
  • I added it in jboss deployment structure and it did not change. I tried it also in standalone.xml and error still there. This is the full log of the error trace. 14:41:38,389 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/cantekWeb]] (ServerService Thread Pool -- 62) JBWEB000289: Servlet InitServlet threw load() exception: java.lang.ClassNotFoundException: sun.io.ByteToCharConverter from [Module – Cantek Çetin Jun 18 '19 at 11:45
0

I made all the above changes which are also needed. But the real problem I faced was related to JBoss EAP 6.4 JRE settings. It was using 1.8 and since this version does not have needed classes in it it was throwing this error. So I made changes on that setting and made it to look at 1.7. After that this problem is solved.

Thanks for the help.

Cantek Çetin
  • 41
  • 1
  • 7