graal icon indicating copy to clipboard operation
graal copied to clipboard

[Native Image] Basic XML Signature usage fails with missing resource bundle

Open jerboaa opened this issue 3 weeks ago • 3 comments

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.

GraalVM Version

GraalVM build from master. Revision cca0ccd49b411efcf790be0f8e7805a36ad41d1c

Operating System and Version

Linux x86_64

Troubleshooting Confirmation

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

  1. javac TestXmlSigTransform.java
  2. native-image --no-fallback TestXmlSigTransform
  3. ./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

jerboaa avatar Dec 02 '25 14:12 jerboaa

/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"
    }
  ]
}

jerboaa avatar Dec 02 '25 14:12 jerboaa

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?

vjovanov avatar Dec 02 '25 16:12 vjovanov

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 avatar Dec 03 '25 10:12 loicottet

@loicottet Any update on this one? Will this be in the 25.0.2 update?

jerboaa avatar Dec 15 '25 16:12 jerboaa

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.

loicottet avatar Dec 16 '25 09:12 loicottet

OK. Thanks for the update!

jerboaa avatar Dec 16 '25 09:12 jerboaa