[Native Image] Basic XML Signature usage fails with missing resource bundle
Describe the Issue
When running the following program as native-image it fails at runtime with a java.lang.ExceptionInInitializerError:
import javax.xml.crypto.dsig.Transform;
import javax.xml.crypto.dsig.XMLSignatureFactory;
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
public class TestXMLSigTransform {
public static final XMLSignatureFactory FAC = XMLSignatureFactory.getInstance("DOM");
public static void main(String[] args) throws Exception {
TransformParameterSpec params = null;
Transform tr = FAC.newTransform(Transform.ENVELOPED, params);
System.out.println(tr);
}
}
Using the latest version of GraalVM can resolve many issues.
- [x] I tried with the latest version of GraalVM.
GraalVM Version
GraalVM build from master. Revision cca0ccd49b411efcf790be0f8e7805a36ad41d1c
Operating System and Version
Linux x86_64
Troubleshooting Confirmation
- [ ] I tried the suggestions in the troubleshooting guide.
Run Command
./testxmlsigtransform
Expected Behavior
Same as when run with java TestXMLSigTransform.java:
$ java TestXMLSigTransform.java
org.jcp.xml.dsig.internal.dom.DOMTransform@d130cf06
Actual Behavior
./testxmlsigtransform
Exception in thread "main" java.lang.ExceptionInInitializerError
at [email protected]/org.jcp.xml.dsig.internal.dom.XMLDSigRI$ProviderService.newInstance(XMLDSigRI.java:124)
at [email protected]/javax.xml.crypto.dsig.TransformService.getInstance(TransformService.java:246)
at [email protected]/org.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory.newTransform(DOMXMLSignatureFactory.java:377)
at TestXMLSigTransform.main(TestXMLSigTransform.java:11)
at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: java.util.MissingResourceException: Can't find bundle for base name com.sun.org.apache.xml.internal.security/resource/xmlsecurity, locale en_US
at [email protected]/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2012)
at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1664)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.localization.substitutions.Target_java_util_ResourceBundle$1.get(Target_java_util_ResourceBundle.java:125)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.localization.substitutions.Target_java_util_ResourceBundle$1.get(Target_java_util_ResourceBundle.java:122)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.MissingRegistrationUtils.runIgnoringMissingRegistrations(MissingRegistrationUtils.java:143)
at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:122)
at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1529)
at [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:921)
at [email protected]/com.sun.org.apache.xml.internal.security.utils.I18n.init(I18n.java:161)
at [email protected]/com.sun.org.apache.xml.internal.security.Init.dynamicInit(Init.java:121)
at [email protected]/com.sun.org.apache.xml.internal.security.Init.init(Init.java:100)
at [email protected]/org.jcp.xml.dsig.internal.dom.ApacheTransform.<clinit>(ApacheTransform.java:61)
... 5 more
Steps to Reproduce
javac TestXmlSigTransform.javanative-image --no-fallback TestXmlSigTransform./testxmlsigtransform
Additional Context
Also fails with the GraalVM 25.0.1 release. Passes with GraalVM 23.1.
Run-Time Log Output and Error Messages
No response
/cc @loicottet @vjovanov
This might be related to the new metadata handling for resource bundles? The json produced with -H:+MetadataTracingSupport at build time and -XX:TraceMetadata=path=$(pwd)/reports has:
{
"reflection": [
{
"type": "java.lang.StackTraceElement[]"
},
{
"type": "java.security.Provider[]"
}
],
"resources": [
{
"bundle": "com.sun.org.apache.xml.internal.security/resource/xmlsecurity"
}
]
}
Thanks for reporting!
at org.graalvm.nativeimage.builder/com.oracle.svm.core.MissingRegistrationUtils.runIgnoringMissingRegistrations(MissingRegistrationUtils.java:143) doesn't seem to do what it is supposed to. @loicottet can you handle this and backport to 25.0.2?
The issue is indeed simply a missing registration for the bundle com.sun.org.apache.xml.internal.security/resource/xmlsecurity. I'll add a conditional registration.
@loicottet Any update on this one? Will this be in the 25.0.2 update?
I don't have a working fix for this issue yet. I'm trying to make it work for 25.0.2 but I'm not sure whether it will make it in time.
OK. Thanks for the update!