Java:由 MissingResourceException 引起的 InitationTargetException,但它确实存在

标签 java exception invocationtargetexception

当我在应用程序上运行方法时,出现以下异常,但缺少“JarSignerResources”的类位于我的类路径中(tools.jar 的一部分)。我以前从未见过这样的异常,它只发生在Linux(而不是OSX)上。谁能给我一些关于为什么会发生这种情况的见解?谢谢。

Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.ExceptionInInitializerError
    at com.wuntee.aat.smali.SmaliWorkshop.signJar(SmaliWorkshop.java:214)
    at com.wuntee.aat.smali.SmaliController.rebuildAndSignApk(SmaliController.java:223)
    at com.wuntee.aat.view.Gui$13.widgetSelected(Gui.java:354)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at com.wuntee.aat.view.Gui.open(Gui.java:135)
    at com.wuntee.aat.view.Gui$1.run(Gui.java:112)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at com.wuntee.aat.view.Gui.main(Gui.java:108)
    ... 5 more
Caused by: java.util.MissingResourceException: Can't find bundle for base name sun.security.tools.JarSignerResources, locale en_US
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1427)
    at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1250)
    at java.util.ResourceBundle.getBundle(ResourceBundle.java:705)
    at com.wuntee.aat.security.tools.JarSigner.<clinit>(JarSigner.java:96)
    ... 17 more

这发生在代码中的此时:

public static void signJar(String keystore, String keystorePassword, String jarFile, String alias) throws Exception{
    JarSigner js = new JarSigner();
    js.signJar(keystore, keystorePassword, jarFile, alias);
}

最佳答案

sun.* 包不是受支持的公共(public)接口(interface)的一部分。您可能没有在 Linux 上使用 sun jdk。

不保证直接调用 sun.* 包的 Java 程序可以在所有 Java 兼容平台上运行。事实上,即使在同一平台上的 future 版本中,也不能保证这样的程序能够正常工作。

参见here了解详情

关于Java:由 MissingResourceException 引起的 InitationTargetException,但它确实存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7688200/

相关文章:

java - JPA2 :i use a JoinColumn as queryparam to create a query and a exception occurred , 为什么

java - 如何解决for循环中的InvocableTargetException? (寻找整个堆栈跟踪)

c# - 执行文件io时如何正确处理异常

android - android 中的 java.lang.reflect.invocationtargetexception

java - 启动 JavaFX 应用程序时的内部 NPE

java - 使用 JdbcUserDetailsManager 与自己的 UserDetailsS​​ervice

java - 从 Spring Boot JSON 响应中删除 "_embedded"和 "_links"

面临异常时构造函数中的c++空闲内存分配

c# - 关闭表单时的 StackOverflow