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

XML merger fails in native-image on custom XPath with MissingResourceException: Could not load any resource bundle by com.sun.org.apache.xpath.internal.res.XPATHErrorResources #1038

Open
hohwille opened this issue Feb 14, 2025 · 5 comments
Assignees
Labels
bug Something isn't working intellij IntelliJ IDE from Jet-Brains merger

Comments

@hohwille
Copy link
Member

hohwille commented Feb 14, 2025

Expected behavior

As a IDEasy user, I want to be able to run my IDE (IntelliJ) seamless without errors so that I can focus on development in my project and do not have to worry about IDEasy itself.

Actual behavior

$ ide intellij
...
Failed to merge workspace file D:\projects\project\workspaces\main\.idea\workspace.xml with update template D:\projects\project\settings\intellij\workspace\update\.idea\workspace.xml and setup file D:\projects\project\settings\intellij\workspace\setup\.idea\workspace.xml!
com.devonfw.tools.ide.merge.xmlmerger.XmlMergeException: Merge strategy combine failed on /project[@version='4']/component[@name='RunManager']
        at com.devonfw.tools.ide.merge.xmlmerger.XmlMergeStrategy.merge(XmlMergeStrategy.java:69)
        at com.devonfw.tools.ide.merge.xmlmerger.XmlMergeStrategy.combineChildNodes(XmlMergeStrategy.java:113)
        at com.devonfw.tools.ide.merge.xmlmerger.XmlMergeStrategy$1.doMerge(XmlMergeStrategy.java:29)
        at com.devonfw.tools.ide.merge.xmlmerger.XmlMergeStrategy.merge(XmlMergeStrategy.java:65)
        at com.devonfw.tools.ide.merge.xmlmerger.XmlMerger.merge(XmlMerger.java:123)
        at com.devonfw.tools.ide.merge.xmlmerger.XmlMerger.doMerge(XmlMerger.java:82)
        at com.devonfw.tools.ide.merge.FileMerger.merge(FileMerger.java:50)
        at com.devonfw.tools.ide.merge.DirectoryMerger.merge(DirectoryMerger.java:69)
        at com.devonfw.tools.ide.merge.DirectoryMerger.merge(DirectoryMerger.java:73)
        at com.devonfw.tools.ide.merge.DirectoryMerger.merge(DirectoryMerger.java:73)
        at com.devonfw.tools.ide.tool.ide.IdeToolCommandlet.configureWorkspace(IdeToolCommandlet.java:83)
        at com.devonfw.tools.ide.tool.ide.IdeToolCommandlet.run(IdeToolCommandlet.java:48)
        at com.devonfw.tools.ide.context.AbstractIdeContext.applyAndRun(AbstractIdeContext.java:926)
        at com.devonfw.tools.ide.context.AbstractIdeContext.run(AbstractIdeContext.java:844)
        at com.devonfw.tools.ide.cli.Ideasy.runOrThrow(Ideasy.java:95)
        at com.devonfw.tools.ide.cli.Ideasy.run(Ideasy.java:59)
        at com.devonfw.tools.ide.cli.Ideasy.main(Ideasy.java:133)
        at java.base@21.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: java.lang.IllegalStateException: Failed to compile XPath expression com.sun.org.apache.xpath.internal.jaxp.XPathImpl@6f540eb8
        at com.devonfw.tools.ide.merge.xmlmerger.matcher.IdComputer.evaluateExpression(IdComputer.java:68)
        at com.devonfw.tools.ide.merge.xmlmerger.matcher.ElementMatcher.matchElement(ElementMatcher.java:61)
        at com.devonfw.tools.ide.merge.xmlmerger.XmlMergeStrategy.combineChildNodes(XmlMergeStrategy.java:107)
        at com.devonfw.tools.ide.merge.xmlmerger.XmlMergeStrategy$1.doMerge(XmlMergeStrategy.java:29)
        at com.devonfw.tools.ide.merge.xmlmerger.XmlMergeStrategy.merge(XmlMergeStrategy.java:65)
        ... 17 more
Caused by: javax.xml.xpath.XPathExpressionException: java.util.MissingResourceException: Could not load any resource bundle by com.sun.org.apache.xpath.internal.res.XPATHErrorResources
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:179)
        at com.devonfw.tools.ide.merge.xmlmerger.matcher.IdComputer.evaluateExpression(IdComputer.java:56)
        ... 21 more
Caused by: java.util.MissingResourceException: Could not load any resource bundle by com.sun.org.apache.xpath.internal.res.XPATHErrorResources
        at java.xml@21.0.2/jdk.xml.internal.SecuritySupport.lambda$getResourceBundle$5(SecuritySupport.java:321)
        at java.base@21.0.2/java.security.AccessController.executePrivileged(AccessController.java:129)
        at java.base@21.0.2/java.security.AccessController.doPrivileged(AccessController.java:319)
        at java.xml@21.0.2/jdk.xml.internal.SecuritySupport.getResourceBundle(SecuritySupport.java:314)
        at java.xml@21.0.2/jdk.xml.internal.SecuritySupport.getResourceBundle(SecuritySupport.java:303)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.res.XPATHMessages.createXPATHMessage(XPATHMessages.java:57)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathParser.java:641)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.consumeExpected(XPathParser.java:562)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.Predicate(XPathParser.java:1936)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.Step(XPathParser.java:1724)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.RelativeLocationPath(XPathParser.java:1624)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.LocationPath(XPathParser.java:1595)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.PathExpr(XPathParser.java:1310)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.UnionExpr(XPathParser.java:1225)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.UnaryExpr(XPathParser.java:1131)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1052)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.AdditiveExpr(XPathParser.java:994)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.RelationalExpr(XPathParser.java:919)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.EqualityExpr(XPathParser.java:859)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.AndExpr(XPathParser.java:823)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.OrExpr(XPathParser.java:796)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.Expr(XPathParser.java:779)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(XPathParser.java:148)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:207)
        at java.xml@21.0.2/com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:166)
        ... 22 more

Steps to reproduce (bug) / Use Case of feature request (enhancement)

  1. ide create testproject -
  2. icd testproject
  3. ide intellij
  4. shut down intellij
  5. ide intellij

Related/Dependent Issues

#992
#363

Comments/Hints:

Once again a limitation of GraalVM that we need to find a fix for asap.
See here for the XPath expression:
https://github.com/devonfw/ide-settings/blob/9551c1a222b64e958cdf1e8b01a952fa537241a6/intellij/workspace/update/.idea/workspace.xml#L38

Affected version:

  • 2025.02.001-beta-SNAPSHOT
@hohwille hohwille added the bug Something isn't working label Feb 14, 2025
@github-project-automation github-project-automation bot moved this to 🆕 New in IDEasy board Feb 14, 2025
@hohwille hohwille added blocker intellij IntelliJ IDE from Jet-Brains merger labels Feb 14, 2025
@hohwille
Copy link
Member Author

I found https://stackoverflow.com/questions/58581470/java-util-missingresourceexception-could-not-load-any-resource-bundle-by-com-su

I tried the suggested solution and it did not help at all.
GraalVM is cool but also a big mistry.

@hohwille hohwille removed the blocker label Feb 15, 2025
@hohwille
Copy link
Member Author

OK, I have some good news.
The error "only" occurs during error handling.
My XPath expression was incorrect as I was using AND instead of and as conjunction.
When I run the same in JVM, I get the better error message:

Caused by: javax.xml.xpath.XPathExpressionException: javax.xml.transform.TransformerException: ] erwartet, aber AND gefunden
	at java.xml/com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:174)
	at com.devonfw.tools.ide.merge.xmlmerger.matcher.IdComputer.evaluateExpression(IdComputer.java:56)
	... 22 more
Caused by: javax.xml.transform.TransformerException: ] erwartet, aber AND gefunden
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathParser.java:644)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.consumeExpected(XPathParser.java:562)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.Predicate(XPathParser.java:1936)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.Step(XPathParser.java:1724)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.RelativeLocationPath(XPathParser.java:1624)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.LocationPath(XPathParser.java:1595)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.PathExpr(XPathParser.java:1310)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.UnionExpr(XPathParser.java:1225)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.UnaryExpr(XPathParser.java:1131)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1052)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.AdditiveExpr(XPathParser.java:994)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.RelationalExpr(XPathParser.java:919)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.EqualityExpr(XPathParser.java:859)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.AndExpr(XPathParser.java:823)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.OrExpr(XPathParser.java:796)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.Expr(XPathParser.java:779)
	at java.xml/com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(XPathParser.java:148)
	at java.xml/com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:207)
	at java.xml/com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:166)
	... 23 more

While it would still be important to get this bug fixed, I removed the blocker label since the error only occurs when the user has configured an invalid XPath expression.
We need to get the required resource bundles included into the native image to produce more helpful error messages.
I was able to fix my syntax and then it is working fine again so I am not blocked any more.

@hohwille
Copy link
Member Author

As described here, I added cli/src/main/resources/META-INF/native-image/com.devonfw.tools.IDEasy/ide-cli/reachabilty-metadata.json:

{
  "bundles": [
    {
      "name": "com.sun.org.apache.xpath.internal.res.XPATHErrorResources",
      "locales": [
        "en",
        "de",
        "es",
        "it"
      ]
    }
  ]
}

It does not work. The JSON is ignored. I confirmed this by putting corrupted syntax into the JSON.
I also added this option to GraalVM:

<arg>--exact-reachability-metadata</arg>

And got this error:

Error: Unrecognized option(s): '--exact-reachability-metadata'

So it seems that this is only supported by newer versions of GraalVM.
Upgrading must not only take place locally but also in GitHub actions if we want to go for that.

@hohwille
Copy link
Member Author

I also changed resource-config.json to this:

{
  "resources": {
    "includes": [
      {"pattern": "nls/.*"}
      {
        "pattern": "nls/.*"
      },
      {
        "pattern": "com/sun/org/apache/xpath/internal/res/.*"
      }
    ]
  }
}

Still no luck, same error as before.
Have to give up again for now.
If someone can take over this issue who has some more time to continue working on this I would be very pleased.

@jan-vcapgemini jan-vcapgemini self-assigned this Feb 24, 2025
@jan-vcapgemini jan-vcapgemini moved this from 🆕 New to 🏗 In progress in IDEasy board Feb 24, 2025
@jan-vcapgemini
Copy link
Contributor

With the current build: 2025.02.002-beta-02_22_02-SNAPSHOT I can not reproduce this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working intellij IntelliJ IDE from Jet-Brains merger
Projects
Status: 🏗 In progress
Development

No branches or pull requests

2 participants