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

Incorrect resolution of sources with two executions #362

Closed
szarza opened this issue Sep 6, 2023 · 18 comments
Closed

Incorrect resolution of sources with two executions #362

szarza opened this issue Sep 6, 2023 · 18 comments
Labels
bug-external Issue concerns an external dependency question

Comments

@szarza
Copy link

szarza commented Sep 6, 2023

Environment:

  • Quarkus 3
  • Open JDK 17
  • Linux Fedora 38

Problem Description:

Having two executions, it seems plugin performs an incorrect resolution of directories an sources, because in the second execution (calypso) resolves the schemaDirectory of the first one (sercom).

Attached an extract of the pom.xml file (pom.extract.txt) and a build log file (build.log)

Please notice that the schemaDirectory resolved in the second executions is wrong.

[INFO] Invoking jaxb30:0.16.0:generate (calypso) @ hermes.client
[INFO] Started execution.
[INFO] Using new MavenCatalogResolver
[INFO] EntityResolver using catalogResolver null
[INFO] EntityResolver set to [org.jvnet.jaxb2.maven2.resolver.tools.ReResolvingEntityResolverWrapper - entityResolver=[org.jvnet.jaxb2.maven2.resolver.tools.MavenCatalogResolver - dependencyResourceResolver=org.jvnet.mjiip.v_3_0.XJC30Mojo@39c5a105; catalogManager=org.apache.xml.resolver.CatalogManager@492fa72a; log=org.apache.maven.monitor.logging.DefaultLog@513fab1e]]

[INFO] schemaDirectory = /home/szarza/proyectos/cestel/hermes/client/src/main/bindings/sercom

[INFO] schemaIncludes = [*.xsd]
[INFO] schemaExcludes = null
[INFO] disableDefaultExcludes = false
[INFO] BuildContext= org.sonatype.plexus.build.incremental.DefaultBuildContext@307af381
[INFO] Created scanner from buildContext: org.codehaus.plexus.util.DirectoryScanner@53d87b2d
[INFO] Scanner included files: [configapp.restapi.xsd]
[INFO] The resulting List is therefore: [/home/szarza/proyectos/cestel/hermes/client/src/main/bindings/sercom/configapp.restapi.xsd]
[INFO] schemaFiles (calced) = [/home/szarza/proyectos/cestel/hermes/client/src/main/bindings/sercom/configapp.restapi.xsd]
[INFO] getInputSources total [1: [[file:/home/szarza/proyectos/cestel/hermes/client/src/main/bindings/sercom/configapp.restapi.xsd]]
[INFO] getInputSources of: file:/home/szarza/proyectos/cestel/hermes/client/src/main/bindings/sercom/configapp.restapi.xsd

build.log
pom.extract.txt

@laurentschoelens
Copy link
Collaborator

Hi @szarza

First thanks for using maven-jaxb-plugin

I think you're currently using phax's fork : https://github.com/phax/maven-jaxb2-plugin, since groupId missmatches our plugin
We are currently working on jakarta support which may come soon.

I'll look at log provided and keep you updated.

Regards
Laurent

@laurentschoelens
Copy link
Collaborator

Fast analysis points that your two executions are done with same generateDirectory :

generateDirectory:/home/szarza/proyectos/cestel/hermes/client/target/generated-sources/xjc

With two executions, you should use seperate generateDirectory
See this wiki entry : https://github.com/highsource/jaxb-tools/wiki/Use-Separate-Target-Directories-for-Separate-Executions

Regards

@laurentschoelens
Copy link
Collaborator

I also invite you to move to newer jaxb-basics extension

<plugin>
  <groupId>org.jvnet.jaxb</groupId>
  <artifactId>jaxb2-basics</artifactId>
  <version>[latest is 2.0.5]</version>
</plugin>

@szarza
Copy link
Author

szarza commented Sep 7, 2023

I'm sorry for the mistake.
I've published the issue in the "phax" project (phax#16) specifying separate generateDirectory (which has no effect).

Also, changing jaxb-basics org.jvnet.jaxb2_commons by org.jvnet.jaxb gives me the error:
Unable to execute mojo: Execution null of goal com.helger.maven:jaxb40-maven-plugin:0.16.0:generate failed: A required class was missing while executing com.helger.maven:jaxb40-maven-plugin:0.16.0:generate: javax/xml/bind/JAXBException

Thank you.

@laurentschoelens
Copy link
Collaborator

Thanks for your reply, and don't worry, my guess is we could have the same issue with current version.

Tried to add a example project with 2 executions and no problem for our current version.
What is strange is I don't get the same output as yours regarding generation :

[INFO] --- jaxb-maven-plugin:2.0.7-SNAPSHOT:generate (b) @ jaxb-maven-plugin-tests-jt-362 ---

Since I don't know quarkus a lot, could you please attach a sample project to reproduce the issue please ?

@laurentschoelens
Copy link
Collaborator

Same output using phax fork's with jaxb30-maven-plugin

[INFO] --- jaxb30-maven-plugin:0.16.0:generate (b) @ jaxb-maven-plugin-tests-jt-362 ---

@laurentschoelens
Copy link
Collaborator

Since it's working with pure mvn way, I guess quarkus does it differently...
Are you running quarkus cli or mvn ?

@szarza
Copy link
Author

szarza commented Sep 8, 2023

Hi:

I was running "quarkus dev" command (to execute and debugging).

I have reduced my project leaving only the part of our interest (attached), and I've tested with the following commands:

quarkus dev
mvn quarkus:dev

In these cases, compiles without errors, but sources under target/generated-sources/xjc/calypso/ are not generated.

If I run mvn package, it gives an error that I do not understand

quarkus-jaxb.tar.gz

@laurentschoelens
Copy link
Collaborator

HI @szarza

Thanks for the sample
After debugging, it seems quarkus does some strange things by mixing configurations :

Explanations below : when setting schemaDirectory from 2nd execution, we got the below stacktrace

setSchemaDirectory:174, AbstractXJC2Mojo (org.jvnet.jaxb.maven)
[...]
executeMojo:114, DefaultBuildPluginManager (org.apache.maven.plugin)
executeMojo:120, MojoExecutor (org.twdata.maven.mojoexecutor)
executeGoal:697, DevMojo (io.quarkus.maven)

in executeGoal:697, DevMojo (io.quarkus.maven), I get the following var pluginExec = DevMojo$PluginExec, with in it :

  • execution.id = calypso
  • execution.configuration having 11 properties and containing : <?xml version="1.0" encoding="UTF-8"?> <schemaDirectory>[...]/src/main/bindings/calypso/xsd</schemaDirectory>

in executeMojo:120, MojoExecutor (org.twdata.maven.mojoexecutor), I get the following var exec = MojoExecution, with configuration that gets now 50 properties (!) and following value : <?xml version="1.0" encoding="UTF-8"?> <schemaDirectory default-value="src/main/resources" implementation="java.io.File">[...]/src/main/bindings/sercom</schemaDirectory>

Since it's quarkus class that calls the plugin, I'd rather create an issue in quarkus project, since the plugin only execute what it received.

As a workaround, maybe try to split the generation part outside from quarkus and then import the generated-code as maven-dependency ?

Regards

@laurentschoelens
Copy link
Collaborator

Found why quarkus does this, and it seems for me to be a bug : see io.quarkus.maven.DevMojo#getPluginConfig

They merge all the configuration that shares the same goal 🤷‍♂️

if (!plugin.getExecutions().isEmpty()) {
    for (PluginExecution exec : plugin.getExecutions()) {
        if (exec.getConfiguration() != null && exec.getGoals().contains(goal)) {
            mergedConfig = mergedConfig == null ? (Xpp3Dom) exec.getConfiguration()
                : Xpp3Dom.mergeXpp3Dom(mergedConfig, (Xpp3Dom) exec.getConfiguration(), true);
        }
    }
}

@laurentschoelens
Copy link
Collaborator

Hi @szarza

Just created issue on quarkus here

@laurentschoelens
Copy link
Collaborator

PR created : quarkusio/quarkus#35846

@laurentschoelens
Copy link
Collaborator

Hi @szarza

PR merged in main
Can you test against latest snapshot of quarkus ?

@szarza
Copy link
Author

szarza commented Sep 18, 2023

Hi @laurentschoelens:
Thank you for the great advance.
I can't test against snapshot of quarkus...

`
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Could not find artifact io.quarkus.platform:quarkus-bom:pom:999-SNAPSHOT @ line 30, column 16
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-arc:jar is missing. @ line 42, column 15
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-undertow:jar is missing. @ line 46, column 15
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-websockets:jar is missing. @ line 50, column 15
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-rest-client-reactive:jar is missing. @ line 55, column 15
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-rest-client-reactive-jaxb:jar is missing. @ line 59, column 15
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-scheduler:jar is missing. @ line 63, column 15
[ERROR] 'dependencies.dependency.version' for org.jboss.logmanager:log4j2-jboss-logmanager:jar is missing. @ line 68, column 15
[ERROR] 'dependencies.dependency.version' for org.apache.commons:commons-lang3:jar is missing. @ line 72, column 15
[ERROR] 'dependencies.dependency.version' for jakarta.xml.bind:jakarta.xml.bind-api:jar is missing. @ line 83, column 15
[ERROR] 'dependencies.dependency.version' for commons-codec:commons-codec:jar is missing. @ line 100, column 15
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project cestel.hermes:hermes.client:1.0 (/home/szarza/proyectos/cestel/lab/bugs/quarkus-jaxb/pom.xml) has 11 errors
[ERROR] Non-resolvable import POM: Could not find artifact io.quarkus.platform:quarkus-bom:pom:999-SNAPSHOT @ line 30, column 16 -> [Help 2]
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-arc:jar is missing. @ line 42, column 15
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-undertow:jar is missing. @ line 46, column 15
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-websockets:jar is missing. @ line 50, column 15
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-rest-client-reactive:jar is missing. @ line 55, column 15
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-rest-client-reactive-jaxb:jar is missing. @ line 59, column 15
[ERROR] 'dependencies.dependency.version' for io.quarkus:quarkus-scheduler:jar is missing. @ line 63, column 15
[ERROR] 'dependencies.dependency.version' for org.jboss.logmanager:log4j2-jboss-logmanager:jar is missing. @ line 68, column 15
[ERROR] 'dependencies.dependency.version' for org.apache.commons:commons-lang3:jar is missing. @ line 72, column 15
[ERROR] 'dependencies.dependency.version' for jakarta.xml.bind:jakarta.xml.bind-api:jar is missing. @ line 83, column 15
[ERROR] 'dependencies.dependency.version' for commons-codec:commons-codec:jar is missing. @ line 100, column 15

`

I don't know how to doit.

@laurentschoelens
Copy link
Collaborator

Here is the link of checking if issue is fixed in main in quarkus wiki using snapshots 😄

@laurentschoelens
Copy link
Collaborator

@szarza quarkus 3.4.0 has been released (followed by 3.4.1).
Can you test with real updated artifacts ? And confirm issue is fixed (in quarkus)

@szarza
Copy link
Author

szarza commented Sep 25, 2023

Hi @laurentschoelens:
I've tested with Quearkus 3.4.1 and everything is working as expected, so the issue is fixed.
Thank you very much!

@laurentschoelens laurentschoelens added the bug-external Issue concerns an external dependency label Sep 25, 2023
@laurentschoelens
Copy link
Collaborator

Closing issue as fixed by quarkus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-external Issue concerns an external dependency question
Projects
None yet
Development

No branches or pull requests

2 participants