NoClassDefFoundError sun/io/ByteToCharConverter with InterBase JDBC driver [英] NoClassDefFoundError sun/io/ByteToCharConverter with InterBase JDBC driver

查看:25
本文介绍了NoClassDefFoundError sun/io/ByteToCharConverter with InterBase JDBC driver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 InterClient 7.5.1 和 8.1.5,在 Java 8 中创建新的 JDBC 连接失败

java.lang.NoClassDefFoundError: sun/io/ByteToCharConverter

这个类似乎被 InterClient JDBC 库引用或使用.Java 7 不会出现此错误.有没有办法解决此错误?

<小时>

此代码在 Java 8 上重现了该问题:

package com.example.so25365952;导入 java.sql.DriverManager;导入 java.sql.SQLException;导入 java.util.logging.Level;导入 java.util.logging.Logger;公共课主要{interbase.interclient.Connection conn;公共静态无效主(字符串 [] args){尝试 {Class.forName("interbase.interclient.Driver");DriverManager.getConnection("jdbc:interbase://localhost/data/mydb.gdb", "sysdba", "password123");} catch (ClassNotFoundException | SQLException ex) {Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);}}}

输出:

<块引用>

线程main"中的异常java.lang.NoClassDefFoundError:sun/io/ByteToCharConverter 在interbase.interclient.Connection.connect(Unknown Source) 在interbase.interclient.Connection.(Unknown Source) atinterbase.interclient.Driver.connect(Unknown Source) atjava.sql.DriverManager.getConnection(DriverManager.java:664) 在java.sql.DriverManager.getConnection(DriverManager.java:247) 在com.example.so25365952.Main.main(Main.java:14) 引起:java.lang.ClassNotFoundException: sun.io.ByteToCharConverter atjava.net.URLClassLoader$1.run(URLClassLoader.java:372) 在java.net.URLClassLoader$1.run(URLClassLoader.java:361) 在java.security.AccessController.doPrivileged(Native Method) 在java.net.URLClassLoader.findClass(URLClassLoader.java:360) 在java.lang.ClassLoader.loadClass(ClassLoader.java:424) 在sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 在java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 6 更多

解决方案

sun.* 和 sunw.* 包是内部的,因此不应使用.好像 InterClient 的某个人搞砸了.我建议您通过错误报告与他们联系,以便他们知道在将来的版本中修复此问题.

如果您迫不及待地等待未来的发布,并且愿意破坏一些许可证(我当然不推荐这样做).您可以通过从 此处,并使用 -Xbootclasspath 将其添加到引导类路径中,但这将是最后的手段.>

With InterClient 7.5.1 and 8.1.5, the creation of a new JDBC connection in Java 8 fails with

java.lang.NoClassDefFoundError: sun/io/ByteToCharConverter

This class seems to be referenced or used by the InterClient JDBC library. The error does not occur with Java 7. Is there a way to work around this error?


This code reproduces the problem on Java 8:

package com.example.so25365952;

import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    interbase.interclient.Connection conn; 

    public static void main(String[] args) {
        try {
            Class.forName("interbase.interclient.Driver");           
            DriverManager.getConnection("jdbc:interbase://localhost/data/mydb.gdb", "sysdba", "password123");           
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

Output:

Exception in thread "main" java.lang.NoClassDefFoundError: sun/io/ByteToCharConverter at interbase.interclient.Connection.connect(Unknown Source) at interbase.interclient.Connection.(Unknown Source) at interbase.interclient.Driver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at com.example.so25365952.Main.main(Main.java:14) Caused by: java.lang.ClassNotFoundException: sun.io.ByteToCharConverter at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 6 more

解决方案

The sun.* and sunw.* packages are internal and should not be used for exactly this reason. Seems like someone at InterClient screwed up. I'd advise you to contact them with a bug report, so they'll know to fix this for future releases.

If you can't wait for a future release, and are willing to break some licences (which I don't recommend of course). You may be able to create your own sun.io.ByteToCharConverter by copying the code from here, and adding it to the bootstrap classpath with -Xbootclasspath, but that would be a last resort.

这篇关于NoClassDefFoundError sun/io/ByteToCharConverter with InterBase JDBC driver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆