Reputation: 2308
I have to make changes to an old project which uses J2SE 1.4. Now as I run the project I get the error
javax.servlet.ServletException: The character set 'IBM437' is supported by the JSE 1.1 API, but not the J2SE 1.4 API. This requires fixing the Java Runtime Environment! Please read the Javadoc of this error class for more information. at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:498) at org.apache.jsp.download_orders_action_jsp._jspService(download_orders_action_jsp.java:131) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92) at javax.servlet.http.HttpServlet.service(HttpServlet.java:720) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187) at javax.servlet.http.HttpServlet.service(HttpServlet.java:720) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:199) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:145) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:139) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2460) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:119) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:157) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:534)
It is being used by a zip file creator. M question is how can I add this support to J2SE 1.4. Googling the problem got me to this page , but i dont get what to do from this page. Any help will be greatly appreciated.
code for making the zip files , which is being called from the jsp and where i think the real problem is
String zipFilename = currentDumpDirName + ".zip";
de.schlichtherle.io.File srcDir = new de.schlichtherle.io.File(currentDumpRootDir);
de.schlichtherle.io.File zipFile = new de.schlichtherle.io.File(dumpRootDir, zipFilename);
boolean zippedSuccessfully = srcDir.copyAllTo(zipFile);
zipFile.umount();
as one can see from the root cause of the exception
de.schlichtherle.io.archive.spi.AbstractArchiveDriver$InconsistentCharsetSupportError: The character set 'IBM437' is supported by the JSE 1.1 API, but not the J2SE 1.4 API. This requires fixing the Java Runtime Environment! Please read the Javadoc of this error class for more information. at de.schlichtherle.io.archive.spi.AbstractArchiveDriver.(AbstractArchiveDriver.java:92) at de.schlichtherle.io.archive.zip.Zip32Driver.(Zip32Driver.java:136) at de.schlichtherle.io.archive.zip.Zip32Driver.(Zip32Driver.java:71) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:274) at java.lang.Class.newInstance0(Class.java:308) at java.lang.Class.newInstance(Class.java:261) at de.schlichtherle.io.ArchiveDriverRegistry.createArchiveDriver(ArchiveDriverRegistry.java:267) at de.schlichtherle.io.ArchiveDriverRegistry.getArchiveDriver(ArchiveDriverRegistry.java:240) at de.schlichtherle.io.DefaultArchiveDetector.getArchiveDriver(DefaultArchiveDetector.java:324) at de.schlichtherle.io.File.init(File.java:892) at de.schlichtherle.io.File.init(File.java:810) at de.schlichtherle.io.File.(File.java:556) at de.schlichtherle.io.File.(File.java:522) at uk.co.planetbeyond.photoprintingserver.OrdersPackagingService.packageOrders(OrdersPackagingService.java:43) at org.apache.jsp.download_orders_action_jsp._jspService(download_orders_action_jsp.java:118) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92) at javax.servlet.http.HttpServlet.service(HttpServlet.java:720) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187) at javax.servlet.http.HttpServlet.service(HttpServlet.java:720) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:199) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:145) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:139) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2460) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:119) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:955) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:157) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:534) Caused by: java.nio.charset.UnsupportedCharsetException: IBM437 at java.nio.charset.Charset.forName(Charset.java:486) at de.schlichtherle.io.archive.spi.AbstractArchiveDriver.testJSE14Support(AbstractArchiveDriver.java:112) at de.schlichtherle.io.archive.spi.AbstractArchiveDriver.(AbstractArchiveDriver.java:89) ... 53 more
Upvotes: 3
Views: 1733
Reputation: 76709
You appear to be using IBM437
as the canonical name or alias of the charset, and according to the same page that you linked, it is not listed as a valid name or alias. Instead, IBM-437
is listed, which appears to be the right name, and you ought to specify that instead.
I don't see any code posted in the question, that uses the String literal IBM437
in code, and going by the stacktrace I suspect that you've specified this in a JSP (which gets compiled into a Servlet that uses the Jasper engine) either in the pageEncoding
attribute or in the contentType
attribute of the page
directive. So, you ought to replace IBM437
to IBM-437
in the JSP, and recompile the same.
Also, you haven't specified whether your project must use the IBM-437
character set. I suspect that the IBM-437
character set is being used due to one of more system properties like file.encoding
being set to IBM-437
. If you do not intend to use IBM-437
, you ought to start considering use of a canonical name or alias like UTF-8 throughout your code, so that your application does not have any misplaced assumptions about the character set of the input data or output responses that it is dealing with.
Updated answer
Based on the new stack trace and the posted code, the following could be deduced:
IBM437
character set support in your JRE is due to the underlying requirement of encoding file entries in a ZIP file using the IBM437
character set, also known as CP437
.IBM437
character set in any form. Note the emphasis in the previous line. Apparently, TrueZIP 6 ships with support for IBM437
, even though the JRE may not support this character set. TrueZIP uses the SPI provider concept in Java NIO that is available since Java 1.4 for supporting additional charsets that are not natively supported by the JRE; in this particular case, the IBM437
character set is supported via the de.schlichtherle.nio.charset.IBM437Charset
class that must be present in your truezip-6.jar file. The JAR file must also contain the following file: META-INF/services/java.nio.charset.spi.CharsetProvider
with the content being de.schlichtherle.nio.charset.spi.CharsetProvider
(i.e. the charset provider embedded within TrueZIP that registers the IBM437Charset
class).Based on the above, you ought to verify the following:
IBM437
character set, and TrueZIP relies on the embedded character set provider to support the IBM437
character set. Since, CharsetProvider
s are looked up using the current thread's context classloader (noted in the CharsetProvider
Java API documentation), the inability to load TrueZIP's CharsetProvider
will result in the InconsistentCharsetSupportError
being thrown. In most web applications, the current thread's context classloader also happens to be the web application's class loader (that loads classes from WEB-INF\lib
and WEB-INF\classes
), but this is not necessarily true. In the event that the context classloader is not the web application classloader, you would have to place the truezip-6.jar
file in the classpath of the context classloader instead of WEB-INF\lib.CharsetProvider
implementation, by running your code in a standalone JRE (from the commandline) instead of running it in a web-application; remember to place truezip-6.jar in the classpath of the application.<jre>/lib/ext
) of the JRE used by the web-application's container. This ought to be attempted only if you are unable to get the current thread's context classloader to load the TrueZIP CharsetProvider
, and only when you've verified that the problem is with loading the CharsetProvider
.Upvotes: 4