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

Catalog resolution failure after upgrade to 0.15.1 #244

Closed
gigermocas opened this issue May 5, 2022 · 20 comments · Fixed by #329
Closed

Catalog resolution failure after upgrade to 0.15.1 #244

gigermocas opened this issue May 5, 2022 · 20 comments · Fixed by #329
Assignees
Milestone

Comments

@gigermocas
Copy link

Hello,

I have a fairly complex project with vendor supplied schemas and I use an XML Catalog.
After I upgraded to 0.15.1, xjc isn't able to find some schema files and breaks compilation.

I've attached a sample project that shows this: catalog-test.zip

The plugin's binding configuration seems to influence this behavior, as it only manifests if a bindings.xjb file is found.

@gigermocas
Copy link
Author

Overriding jaxb-xjc's version to version 2.3.3 seems to fix this (plugin uses 2.3.6)
I wasn't able to replicate this using jaxb-xjc directly (through its com.sun.tools.xjc.Driver abstraction), it works even on 2.3.6, so the issue may lie on some extra input I'm not providing.

@mattrpav
Copy link
Collaborator

Can you try with v2.3.5? There was a big gap b/w those versions.

Also-- might be good to open a ticket with xjc (v2.3.6 was released in Jan' of 2022)

jaxb project: https://github.com/eclipse-ee4j/jaxb-ri

@mattrpav mattrpav self-assigned this May 21, 2022
@mattrpav mattrpav added this to the 2.3.6 milestone May 21, 2022
@gigermocas
Copy link
Author

I've tried to do just that, but as I said, I haven't been able to create a minimal reproducible test.
Something like this works fine:

com.sun.tools.xjc.Driver.main(new String[] {
  "-nv",
  "-xmlschema",
  "src/main/resources/schemas/a.xsd",
  "-catalog", "src/main/resources/catalog.xml",
  "-b", "src/main/resources",
  "-d", "target/generated-sources/xjc",
  "-episode", "target/generated-sources/xjc/META-INF/sun-jaxb.episode"
});

Although I would agree that the problem probably lies within a bug in xjc, it may be triggered from some extra configuration maven-jaxb2-plugin is using or perhaps an interaction with some other dependency.

I can see this with all versions > 2.3.3.

I added the sample project to a repo: https://github.com/gigermocas/catalog-test

@krah034
Copy link

krah034 commented Jun 8, 2022

We are also using maven-jaxb2-plugin and I was curious were this error was from. So I used git bisect on eclipse-ee4j/jaxb-ri@acad929 as git bisect good acad9292 (the commit next to the release commit from 2.3.3 in the same branch of the 2.3.4+ release branch) and eclipse-ee4j/jaxb-ri@03d7370 for git bisect bad 03d73707.

After a few iterations of git bisect it identified eclipse-ee4j/jaxb-ri@b3a2c63 as the first breaking change. If one removes line 277 to 288 from DOMParser.java your sample project compiles. So either the way you declare the file path of the "missing" file is wrong or there is indeed a regression in DOMParser.parse( String systemId, boolean root ) : Document.

@gigermocas
Copy link
Author

Thanks! That helped.

I think I've narrowed it down to the plugin's usage of a ReResolvingInputSourceWrapper:
https://github.com/highsource/maven-jaxb2-plugin/blob/d87e47b6d26cb8bf7232e63aed6340bde242b03d/plugin-core/src/main/java/org/jvnet/jaxb2/maven2/resolver/tools/ReResolvingEntityResolverWrapper.java#L36-L41
The returning ReResolvingInputSourceWrapper's getSystemId() is now called by xjc:
https://github.com/eclipse-ee4j/jaxb-ri/blob/b3a2c63e69b5fe079f3b5664d51ecf0992ad30c4/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/internalizer/DOMForest.java#L277
getSystemId() returns the pre-resolved value, so that explains why it can't find the file.

@mattrpav
Copy link
Collaborator

mattrpav commented Jun 9, 2022

@gigermocas if you can narrow down the fix and make a PR, I'll cut a new release. I have been swamped lately and am running a few weeks behind on my planned jaxb work. Thx

@gigermocas
Copy link
Author

Sorry, I'm not sure how a solution for this would actually look like. I don't think I'm seeing the full picture.

@mattrpav
Copy link
Collaborator

Heads up... got pulled away on some things. Still planning to swing back to this

@mattrpav
Copy link
Collaborator

About to release 0.15.2 with updated jaxb 2.3.7 (which has some upstream fixes) and better jaxb dependency alignment

@michael-o
Copy link

michael-o commented Apr 25, 2023

Is this supposed to be fixed since I have upgraded to 0.15.2 with this CP:

[DEBUG]   (s) pluginArtifacts = [org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:maven-plugin:0.15.2:, org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-core:jar:0.15.2:compile, org.slf4j:slf4j-api:jar:1.7.25:compile, org.apache.commons:commons-lang3:jar:3.12.0:compile, com.sun.org.apache.xml.internal:resolver:jar:20050927:compile, org.glassfish.jaxb:txw2:jar:2.3.7:compile, org.apache.maven:maven-plugin-api:jar:2.0.9:compile, org.sonatype.plexus:plexus-build-api:jar:0.0.7:compile, org.apache.maven:maven-project:jar:2.0.9:compile, org.apache.maven:maven-settings:jar:2.0.9:compile, org.apache.maven:maven-profile:jar:2.0.9:compile, org.apache.maven:maven-model:jar:2.0.9:compile, org.apache.maven:maven-artifact-manager:jar:2.0.9:compile, org.apache.maven:maven-repository-metadata:jar:2.0.9:compile, org.apache.maven:maven-plugin-registry:jar:2.0.9:compile, org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile, junit:junit:jar:4.13.2:compile, org.hamcrest:hamcrest-core:jar:1.3:compile, classworlds:classworlds:jar:1.1-alpha-2:compile, org.codehaus.plexus:plexus-utils:jar:1.5.15:compile, org.jvnet.jaxb2.maven2:maven-jaxb23-plugin:jar:0.15.2:compile, jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile, jakarta.activation:jakarta.activation-api:jar:1.2.2:compile, org.glassfish.jaxb:jaxb-runtime:jar:2.3.7:compile, com.sun.istack:istack-commons-runtime:jar:3.0.12:compile, org.glassfish.jaxb:jaxb-xjc:jar:2.3.7:compile, org.glassfish.jaxb:xsom:jar:2.3.7:compile, com.sun.xml.bind.external:relaxng-datatype:jar:2.3.7:compile, org.glassfish.jaxb:codemodel:jar:2.3.7:compile, com.sun.xml.bind.external:rngom:jar:2.3.7:compile, com.sun.xml.dtd-parser:dtd-parser:jar:1.4.5:compile, com.sun.istack:istack-commons-tools:jar:3.0.12:compile, com.sun.activation:jakarta.activation:jar:1.2.2:compile, org.apache.maven.plugin-tools:maven-plugin-annotations:jar:3.5:compile, org.apache.maven:maven-artifact:jar:2.0.9:compile]

and it is still broken for me?

@mattrpav mattrpav removed this from the 2.3.6 milestone May 9, 2023
@sepe81
Copy link

sepe81 commented May 26, 2023

@michael-o Yes, the failure is still there. I tried it with 0.15.2 and 0.15.3. For me it works with 0.14.0

@laurentschoelens
Copy link
Collaborator

@mattrpav : found a way to fix this issue with small change and added a test project on local build that failed without the fix and succeded with the fix.
@gigermocas : we are currently working on jaxb-tools next release (pre-jakarta), the fix will be available soon I guess.
Thanks to all users that digged into this issue and helped me find a way to fix it

@laurentschoelens
Copy link
Collaborator

laurentschoelens commented Jul 6, 2023

Fix version candidate will be 2.0.4. Stay tuned 😄

@laurentschoelens
Copy link
Collaborator

@michael-o @sepe81 @gigermocas
Release of 2.0.4 should fix the issue
Thanks for your patience

@mattrpav mattrpav added this to the 2.0.4 milestone Aug 14, 2023
@michael-o
Copy link

@laurentschoelens, I cannot say that it works for me now:

[INFO] --- jaxb-maven-plugin:2.0.4:generate (generate-model) @ x2tc-proxy-import-ws-model ---
[INFO] Sources are not up-to-date, XJC will be executed.
[WARNING] ReResolvingEntityResolverWrapper : File file:/var/osipovmi/Projekte/x2tc-proxy/models/import-ws-model/src/main/resources/META-INF/x2tc-proxy-common.xsd does not exists.
[WARNING] ReResolvingEntityResolverWrapper : File file:/var/osipovmi/Projekte/x2tc-proxy/models/import-ws-model/src/main/resources/META-INF/x2tc-proxy-helper.xsd does not exists.
[ERROR] Error while parsing schema(s).Location [ jar:file:/var/osipovmi/Projekte/x2tc-proxy/models/helper-ws-model/target/x2tc-proxy-helper-ws-model-0.35.7-SNAPSHOT.jar!/META-INF/x2tc-proxy-common.xsd{24,34}].
org.xml.sax.SAXParseException: 'owningGroup' is already defined
    at com.sun.xml.xsom.impl.parser.ParserContext$1.reportError (ParserContext.java:150)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError (NGCCRuntimeEx.java:149)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError (NGCCRuntimeEx.java:152)

I need to analyze tomorrow what is happening here. With 0.14.0 it did work.

@laurentschoelens
Copy link
Collaborator

@laurentschoelens, I cannot say that it works for me now:

[INFO] --- jaxb-maven-plugin:2.0.4:generate (generate-model) @ x2tc-proxy-import-ws-model ---
[INFO] Sources are not up-to-date, XJC will be executed.
[WARNING] ReResolvingEntityResolverWrapper : File file:/var/osipovmi/Projekte/x2tc-proxy/models/import-ws-model/src/main/resources/META-INF/x2tc-proxy-common.xsd does not exists.
[WARNING] ReResolvingEntityResolverWrapper : File file:/var/osipovmi/Projekte/x2tc-proxy/models/import-ws-model/src/main/resources/META-INF/x2tc-proxy-helper.xsd does not exists.
[ERROR] Error while parsing schema(s).Location [ jar:file:/var/osipovmi/Projekte/x2tc-proxy/models/helper-ws-model/target/x2tc-proxy-helper-ws-model-0.35.7-SNAPSHOT.jar!/META-INF/x2tc-proxy-common.xsd{24,34}].
org.xml.sax.SAXParseException: 'owningGroup' is already defined
    at com.sun.xml.xsom.impl.parser.ParserContext$1.reportError (ParserContext.java:150)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError (NGCCRuntimeEx.java:149)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError (NGCCRuntimeEx.java:152)

I need to analyze tomorrow what is happening here. With 0.14.0 it did work.

Could you share more context about this error you have ?
With 2.0.3 do you have same error ?
Please share test project if needed for us to analyse

@michael-o
Copy link

@laurentschoelens, I cannot say that it works for me now:

[INFO] --- jaxb-maven-plugin:2.0.4:generate (generate-model) @ x2tc-proxy-import-ws-model ---
[INFO] Sources are not up-to-date, XJC will be executed.
[WARNING] ReResolvingEntityResolverWrapper : File file:/var/osipovmi/Projekte/x2tc-proxy/models/import-ws-model/src/main/resources/META-INF/x2tc-proxy-common.xsd does not exists.
[WARNING] ReResolvingEntityResolverWrapper : File file:/var/osipovmi/Projekte/x2tc-proxy/models/import-ws-model/src/main/resources/META-INF/x2tc-proxy-helper.xsd does not exists.
[ERROR] Error while parsing schema(s).Location [ jar:file:/var/osipovmi/Projekte/x2tc-proxy/models/helper-ws-model/target/x2tc-proxy-helper-ws-model-0.35.7-SNAPSHOT.jar!/META-INF/x2tc-proxy-common.xsd{24,34}].
org.xml.sax.SAXParseException: 'owningGroup' is already defined
    at com.sun.xml.xsom.impl.parser.ParserContext$1.reportError (ParserContext.java:150)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError (NGCCRuntimeEx.java:149)
    at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError (NGCCRuntimeEx.java:152)

I need to analyze tomorrow what is happening here. With 0.14.0 it did work.

Could you share more context about this error you have ? With 2.0.3 do you have same error ? Please share test project if needed for us to analyse

I will create a reproducer tomorrow since my project is too complex for this to analyze.

2.0.3 fails with a completely different error since catalog resolution from dependency artifact does not work:

[INFO]
[INFO] --- jaxb-maven-plugin:2.0.3:generate (generate-model) @ x2tc-proxy-helper-ws-model ---
[INFO] Sources are not up-to-date, XJC will be executed.
[WARNING] Error while parsing schema(s).Location [].
org.xml.sax.SAXParseException: Catalog points to non-existent resource: "file:/var/osipovmi/Projekte/x2tc-proxy/models/helper-ws-model/src/main/resources/META-INF/x2tc-proxy-common.xsd". Trying to reach "file:/v
ar/osipovmi/Projekte/x2tc-proxy/models/helper-ws-model/src/main/resources/META-INF/x2tc-proxy-common.xsd" directly.

I wil report a separate issue as soon as I have a sample project.

@laurentschoelens
Copy link
Collaborator

Thanks for your quick reply
Example provided by @gigermocas has been introduced in code baseline as test project to validate his error was fixed

@laurentschoelens
Copy link
Collaborator

Feel free to open new issue since error is different now

@michael-o
Copy link

Feel free to open new issue since error is different now

Done: #306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants