Search code examples
javaexceptioninvocationtargetexception

Java: InvocationTargetException caused by MissingResourceException, but its there


When I run a method on my application, I get the following exception, but the class that is miss 'JarSignerResources' is in my classpath (part of tools.jar). I have never seen an exception like this before, and it only occurs on Linux (not OSX). Can anyone give me a bit of insight into why this would be happening? Thanks.

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

This happens at this point in the code:

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

Solution

  • The sun.* packages are not part of the supported, public interface. It is likely you are not using a sun jdk on linux.

    A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.

    see here for details