Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find resource for bundle sun.security.util.Resources, key keytool.error #2

Open
GergesShamon opened this issue Sep 30, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@GergesShamon
Copy link

When to use this command:
dalvikvm ^
-cp keytool.dex ^
main ^
-genkeypair ^
-keystore keystore.jks ^
-alias androidkey ^
-validity 10000 ^
-keyalg RSA ^
-keysize 2048 ^
-storepass android ^
-keypass android

This is showing me an error:
Android keytool 2019 ported by Yutaka Aoki.

Exception in thread "main" java.util.MissingResourceException: Can't find resource for bundle sun.security.util.Resources, key keytool.error.
at java.util.ResourceBundle.getObject(ResourceBundle.java:448)
at java.util.ResourceBundle.getString(ResourceBundle.java:405)
at sun.security.tools.KeyTool.run(KeyTool.java:343)
at sun.security.tools.KeyTool.main(KeyTool.java:333)
at main.main(main.java:5)

@YutakaAoki
Copy link
Owner

YutakaAoki commented Oct 10, 2022

[1] Overview and Causes
Line 343 of KeyTool.java is
System.out.println(rb.getString("keytool.error.")+e);
And in the rb.getString("keytool.error."), the error occured,
which is caused by the absence of a resource named "keytool.error".
And the reason for it is that the preceding
parseArgs(args);
or
doCommands(out);
threw an exception.

In other words, when the error occurred, the code tried to display the cause of the error, but second error occurred in that code
.
Therefore, the double error has made it impossible to display the cause of the first error.

If you rewrite A as B, you will be able to display the cause of exception e.

System.out.println(rb.getString("keytool.error.") + e); // A, old line 343
--->
System.out.println("keytool error: " + e); // B, new "line 343"

  • Note that ^ is the line concatenation operator in the BAT file, so when writing directly in the shell, change it to a space.

(KeyTool.java)
private static final java.util.ResourceBundle rb =
java.util.ResourceBundle.getBundle("sun.security.util.Resources");
private void run(String[] args, PrintStream out) throws Exception {
try {
parseArgs(args);
if (command != null) {
doCommands(out);
}
} catch (Exception e) {
System.out.println(rb.getString("keytool.error.") + e); // line 343
if (verbose) {
e.printStackTrace(System.out);
}
if (!debug) {
System.exit(1);
} else {
throw e;
}

[2] Hint
https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/sun/security/util/Resources.java

package sun.security.util;

/**

  • This class represents the ResourceBundle

  • for javax.security.auth and sun.security.

*/
public class Resources extends java.util.ListResourceBundle {

private static final Object[][] contents = {
...

// keytool: Running part
{"keytool.error.", "keytool error: "},
{"Illegal.option.", "Illegal option: "},
...
};
....
}

[3] The same code as [2] is here in local source :
https://github.com/YutakaAoki/KeyTool/blob/master/src/sun/security/util/Resources.java

@YutakaAoki YutakaAoki added the bug Something isn't working label Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants