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

[QUESTION] Fail to compile xslt file during native-tests #422

Open
johanHenix opened this issue Apr 4, 2023 · 0 comments
Open

[QUESTION] Fail to compile xslt file during native-tests #422

johanHenix opened this issue Apr 4, 2023 · 0 comments
Labels
question Further information is requested

Comments

@johanHenix
Copy link

Hello,

I am trying to compile a resource .xslt file using javax.xml.transform.TransformerFactory#newTemplates(javax.xml.transform.Source).
My maven test passes but it fails during native-test goal.

Are you familiar with this error ? Is there a solution to compile such a file in a native image ?

Here is my test:

@Test
public void shouldCompileXslt() throws TransformerConfigurationException, MalformedURLException {
    URL xsltFileUrl = new URL("file:src/test/resources/file.xslt");
    TransformerFactory tFactory = TransformerFactory.newInstance();
    StreamSource streamSource = new StreamSource(xsltFileUrl.toExternalForm());

    // this breaks during native-tests
    tFactory.newTemplates(streamSource);
}

And the error during native-test is the following:

ERROR:  'Could not compile stylesheet'
FATAL ERROR:  'java.lang.NullPointerException'
           :null
XsltCompileTest > shouldCompileXslt() FAILED

Failures (1):
  JUnit Jupiter:XsltCompileTest:shouldCompileXslt()
    MethodSource [className = 'XsltCompileTest', methodName = 'shouldCompileXslt', methodParameterTypes = '']
    => javax.xml.transform.TransformerConfigurationException: java.lang.NullPointerException
       [email protected]/com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:1059)
       XsltCompileTest.shouldCompileXslt(XsltCompileTest.java:19)
       [email protected]/java.lang.reflect.Method.invoke(Method.java:566)
       org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
       org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
       [...]
     Caused by: java.lang.NullPointerException
       [email protected]/com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg.getFileName(ErrorMsg.java:264)
       [email protected]/com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg.<init>(ErrorMsg.java:237)
       [email protected]/com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.makeInstance(Parser.java:990)
       [email protected]/com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.startElement(Parser.java:1302)
       [email protected]/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:510)
       [...]

System Info:
OS: Windows 10 / Generating native images on WSL2 (Debian)
GraalVM Version: 22.3.0
Java Version: 11
Plugin Version (native-maven-plugin): 0.9.19

To Reproduce:
You can reproduce the issue with this simple repository: https://github.com/johanHenix/native-xslt-compile/

@johanHenix johanHenix added the question Further information is requested label Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant