java.lang.NoClassDefFoundError:无法初始化类 java.net.ProxySelector

发布于 2024-08-16 04:13:50 字数 2969 浏览 7 评论 0原文

我遇到了一个 java 应用程序不断抛出的问题:

java.lang.NoClassDefFoundError:无法初始化类 java.net.ProxySelector。

我正在运行 Suse Linux 10.3 并运行 java 1.6.0。我的 CLASSPATH 设置为

/usr/lib/jvm/jre-1.6.0-openjdk/lib。

似乎没有其他用户遇到此错误,因此我假设这是我的设置。对于那些想知道该应用程序是 yamj 的人 (http://code.google.com/p/moviejukebox/< /a>)

关于可能缺少什么或者我可能做错了什么有什么想法吗?

编辑错误的完整跟踪如下:

java.lang.NoClassDefFoundError:无法初始化类 java.net.ProxySelector 在 sun.net.www.protocol.http.HttpURLConnection$5.run(HttpURLConnection.java:736) 在 java.security.AccessController.doPrivileged(本机方法) 在 sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:732) 在 sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:672) 在 sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:997) 在 com.movi​​ejukebox.thetvdb.tools.XMLHelper.getEventReader(XMLHelper.java:19) 在 com.movi​​ejukebox.thetvdb.model.Mirrors.(Mirrors.java:30) 在 com.movi​​ejukebox.thetvdb.TheTVDB。(TheTVDB.java:37) 在 com.movi​​ejukebox.plugin.TheTvDBPlugin。(TheTvDBPlugin.java:57) 在 sun.reflect.GenerateConstructorAccessor2.newInstance(来源未知) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在 java.lang.reflect.Constructor.newInstance(Constructor.java:532) 在 java.lang.Class.newInstance0(Class.java:372) 在 java.lang.Class.newInstance(Class.java:325) 在com.movi​​ejukebox.plugin.DatabasePluginController.getMovieDatabasePlugin(DatabasePluginController.java:96) 在 com.movi​​ejukebox.plugin.DatabasePluginController.access$000(DatabasePluginController.java:30) 在 com.movi​​ejukebox.plugin.DatabasePluginController$1.initialValue(DatabasePluginController.java:44) 在 com.movi​​ejukebox.plugin.DatabasePluginController$1.initialValue(DatabasePluginController.java:39) 在 java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:160) 在 java.lang.ThreadLocal.get(ThreadLocal.java:150) 在 com.movi​​ejukebox.plugin.DatabasePluginController.scan(DatabasePluginController.java:70) 在 com.movi​​ejukebox.MovieJukebox.updateMovieData(MovieJukebox.java:1051) 在 com.movi​​ejukebox.MovieJukebox.access$100(MovieJukebox.java:80) 在 com.movi​​ejukebox.MovieJukebox$4.call(MovieJukebox.java:613) 在 com.movi​​ejukebox.MovieJukebox$4.call(MovieJukebox.java:600) 在 java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) 在 java.util.concurrent.FutureTask.run(FutureTask.java:166) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 在 java.lang.Thread.run(Thread.java

I'm running into a problem with a java app constantly throwing:

java.lang.NoClassDefFoundError: Could not initialize class java.net.ProxySelector.

I am running Suse Linux 10.3 and running java 1.6.0. My CLASSPATH is set to

/usr/lib/jvm/jre-1.6.0-openjdk/lib.

No other users seem to be having this error so I'm assuming its my setup. For those wondering the app is yamj (http://code.google.com/p/moviejukebox/)

Any ideas as to what maybe missing or what I maybe doing wrong?

Edit the full trace of the error is as follows:

java.lang.NoClassDefFoundError: Could not initialize class java.net.ProxySelector
at sun.net.www.protocol.http.HttpURLConnection$5.run(HttpURLConnection.java:736)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:732)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:672)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:997)
at com.moviejukebox.thetvdb.tools.XMLHelper.getEventReader(XMLHelper.java:19)
at com.moviejukebox.thetvdb.model.Mirrors.(Mirrors.java:30)
at com.moviejukebox.thetvdb.TheTVDB.(TheTVDB.java:37)
at com.moviejukebox.plugin.TheTvDBPlugin.(TheTvDBPlugin.java:57)
at sun.reflect.GeneratedConstructorAccessor2.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at com.moviejukebox.plugin.DatabasePluginController.getMovieDatabasePlugin(DatabasePluginController.java:96)
at com.moviejukebox.plugin.DatabasePluginController.access$000(DatabasePluginController.java:30)
at com.moviejukebox.plugin.DatabasePluginController$1.initialValue(DatabasePluginController.java:44)
at com.moviejukebox.plugin.DatabasePluginController$1.initialValue(DatabasePluginController.java:39)
at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:160)
at java.lang.ThreadLocal.get(ThreadLocal.java:150)
at com.moviejukebox.plugin.DatabasePluginController.scan(DatabasePluginController.java:70)
at com.moviejukebox.MovieJukebox.updateMovieData(MovieJukebox.java:1051)
at com.moviejukebox.MovieJukebox.access$100(MovieJukebox.java:80)
at com.moviejukebox.MovieJukebox$4.call(MovieJukebox.java:613)
at com.moviejukebox.MovieJukebox$4.call(MovieJukebox.java:600)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

西瓜 2024-08-23 04:13:50

ProxySelector 是一个抽象类。您是否想直接实例化它?

ProxySelector is an abstract class. Are you trying to instantiate it directly?

半枫 2024-08-23 04:13:50

我的 CLASSPATH 设置为
/usr/lib/jvm/jre-1.6.0-openjdk/lib。

不认为它应该在您的 CLASSPATH 中

尝试清除 CLASSPATH 并运行它

My CLASSPATH is set to
/usr/lib/jvm/jre-1.6.0-openjdk/lib.

don't think that should be in your CLASSPATH

try clearing the CLASSPATH and running it

旧时浪漫 2024-08-23 04:13:50

首先,您不必将“/usr/lib/jvm/jre-1.6.0-openjdk/lib”放在类路径中。 “java”命令应该将所有标准 J2SE 库放在 bootclasspath 上,而无需您执行任何操作。

其次,如果您向我们提供完整的堆栈跟踪,而不仅仅是异常消息,将会有所帮助。我怀疑真正的问题是 java.net.ProxySelector (或它所依赖的东西)在静态初始化期间失败。但只有堆栈跟踪才能证实这一点。

Firstly, you shouldn't have to put "/usr/lib/jvm/jre-1.6.0-openjdk/lib" on your classpath. The "java" command should put all of the standard J2SE libraries on the bootclasspath without you doing anything.

Second, it would help if you gave us the full stacktrace, not just the exception message. I suspect that the real problem is that java.net.ProxySelector (or something it depends on) is failing during static initialization. But only a stacktrace would confirm that.

鹿港小镇 2024-08-23 04:13:50

由于这是谷歌搜索中关于此错误的第二个结果,我想发布我发现的这段代码 在某个论坛帮助我解决了同样的异常。无法详细解释 - 这对我来说只是一个快速测试项目,所以我没有时间进行更深入的调查。

static { 
  try {
    Class c = Class.forName("sun.net.spi.DefaultProxySelector");
    if (c != null && ProxySelector.class.isAssignableFrom(c)) {
       theProxySelector = (ProxySelector) c.newInstance();
    }
  } catch (Exception e) {
    theProxySelector = null;
  }
}

Since it's second result in google search on this error, I want to post this piece of code I found at some forum that helped me with the same exception. Cannot explain in details - it was just a quick test project for me, so I didn't have time for deeper investigation.

static { 
  try {
    Class c = Class.forName("sun.net.spi.DefaultProxySelector");
    if (c != null && ProxySelector.class.isAssignableFrom(c)) {
       theProxySelector = (ProxySelector) c.newInstance();
    }
  } catch (Exception e) {
    theProxySelector = null;
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文