- java.lang.NoClassDefFoundError: sun/io/CharacterEncoding
In this article, we will discuss how to trouble shoot and resolve this issue.
JVM Option -verbose
When it comes to java.lang.NoClassDefFoundError exception, one thing we need to find out this who has thrown that exception. To trouble shoot class loading issues, the following JVM option comes in handy:
- -verbose
[Loaded oracle.webservices.annotations.PortableWebService from file:/scratch/perfgrp/mt/rup1/fusionapps/oracle_common/modules/oracle.webservices_11.1.1/wsclient-rt.jar]
[Loaded oracle.j2ee.ws.common.util.TestPageUtils from file:/scratch/perfgrp/mt/rup1/fusionapps/oracle_common/modules/oracle.webservices_11.1.1/wsclient-rt.jar]
[Loaded java.lang.UnsatisfiedLinkError from /scratch/perfgrp/JVMs/jdk1.8.0/jre/lib/rt.jar]
[Loaded java.lang.VerifyError from /scratch/perfgrp/JVMs/jdk1.8.0/jre/lib/rt.jar]
[Loaded com.bea.logging.ThrowableWrapper from file:/scratch/perfgrp/mt/rup1/fusionapps/modules/com.bea.core.logging_1.9.0.0.jar]
java.lang.NoClassDefFoundError: sun/io/CharacterEncoding
at oracle.j2ee.ws.common.util.TestPageUtils.encode(TestPageUtils.java:216)
at oracle.j2ee.ws.server.management.mbeans.WebServiceOperation.createTestPagePath(WebServiceOperation.java:276)
at oracle.j2ee.ws.server.management.mbeans.WebServiceOperation.initialize(WebServiceOperation.java:253)
at oracle.j2ee.ws.server.management.mbeans.WebServiceOperation.
at oracle.j2ee.ws.server.provider.GenericProviderInterceptorPipeline.registerWebServiceOperationMBean(GenericProviderInterceptorPipeline.java:175)
Truncated. see log file for complete stack trace
After some investigation, we finally identify that TestPageUtils class from wsclient-rt.jar is the culprit. In JDK 8, the following class:
- sun.io.CharacterEncoding
will be removed. It should be rewritten using:
- java.nio.charset.Charset.forName()
For example, here are our changes:
//String encoding = sun.io.CharacterEncoding.aliasName(givenEncoding.toUpperCase());
String encoding = java.nio.charset.Charset.forName(givenEncoding.toUpperCase()).name();
How to Patch wsclient-rt.jar with New Class?
After we got a fix for TestPageUtils class, we loaded the jar with new class. Note that from the -verbose output, we also know where TestPageUtils was loaded from. For instance, it was loaded from:
- /.../oracle_common/modules/oracle.webservices_11.1.1/wsclient-rt.jar
Here are the steps that we have taken to apply the patch:
- cd /.../oracle_common/modules/oracle.webservices_11.1.1
- mkdir tmpdir
- cd tmpdir
- cp ../wsclient-rt.jar .
- unzip wsclient-rt.jar
- cp <location of new patch>/TestPageUtils.class oracle/j2ee/ws/common/util
- jar uf /.../oracle_common/modules/oracle.webservices_11.1.1/wsclient-rt.jar oracle/j2ee/ws/common/util/TestPageUtils.class
- cd ..
- rm -rf tmpdir
3 comments:
This worked great,
In addition, a similar patch must be done for
/.../oracle_common/modules/oracle.jsp_11.1.1/ojsp.jar, within oracle/jsp/util/JspUtil.class
I have installed OBIEE (v. 11.1.1.9.0) on Weblogic 10.3.6., extending an existing domain. My requirement is to use JDK 8. When I start up the servers, the following error is encountered and BI fails to start. The error is while loading wsclient-rt.jar java.lang.NoClassDefFoundError: sun/io/CharacterEncoding at oracle.j2ee.ws.common.util.TestPageUtils.encode(TestPageUtils.java:216)
After a research figured out that sun.io,CharacterEncoding is removed from JDK 8. I am aware that JDK 8 is not supported on Weblogic 10.3.6. But, is there any way I could get the BI publisher running on Weblogic 10.3.6 using JDK 8 or is there any patch available for weblogic 10.3.6. supporting JDK 8?
Post a Comment