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

ClassGraph fails to discover resources and classes in Quarkus 2.7 during build time #641

Closed
michael-simons opened this issue Jan 31, 2022 · 2 comments

Comments

@michael-simons
Copy link
Contributor

First of all, I am super sorry for that really awful discussion over here quarkusio/quarkus#23312 in case you got swamped with notifications already. I didn't expect that.

As usually, I am using ClassGraph to find both resources and classes. I do this in Quarkus build time in the extension in question.

Working combination
Quarkus 2.6.2 plus ClassGraph 4.8.138

Broken combination
Quarkus 2.6.2 plus ClassGraph 4.8.138

JDK 17.

Here's the description from the discussion above. Down below I added the verbose log for both working and broken:

I maintain Neo4j-Migrations: https://github.com/michael-simons/neo4j-migrations, which let's you execute Cypher scripts (resources) and Java classes against Neo4j.

I use ClassGraph to discover those resources.
Since last release I do support Quarkus in native mode. To make this possible, I moved all discovering of things into build time / augmentation. That works well with Quarkus 2.6.x (all releases).

Those classes:

https://github.com/michael-simons/neo4j-migrations/blob/0db309476f9c737b1b4674193f838f7e3c74ec75/neo4j-migrations-quarkus-parent/runtime/src/main/java/ac/simons/neo4j/migrations/quarkus/runtime/StaticClasspathResourceScanner.java#L57-L70

and

https://github.com/michael-simons/neo4j-migrations/blob/0db309476f9c737b1b4674193f838f7e3c74ec75/neo4j-migrations-quarkus-parent/runtime/src/main/java/ac/simons/neo4j/migrations/quarkus/runtime/StaticJavaBasedMigrationDiscoverer.java#L48-L61

are invoked from a build time processor, both in 2 steps (creating the scanner, than executing them and adding things to the augmented classes), like this:

https://github.com/michael-simons/neo4j-migrations/blob/0db309476f9c737b1b4674193f838f7e3c74ec75/neo4j-migrations-quarkus-parent/deployment/src/main/java/ac/simons/neo4j/migrations/quarkus/deployment/MigrationsProcessor.java#L58-L83

With Quarkus 2.7.x this suddenly fails: https://github.com/michael-simons/neo4j-migrations/runs/5002711436?check_suite_focus=true#step:9:1522 no resources are found anymore.

What fails exactly is

try (var scanResult = new ClassGraph().acceptPaths(paths).scan()) {
			var resources = scanResult.getResourcesWithExtension(Defaults.CYPHER_SCRIPT_EXTENSION).stream()
}

and the counterpart for Java classes.

It doesn't work when I use the current thread class loader either.

It works during runtime, but this is not what I want.

So, I'm unsure where to open an issue: In ClassGraph or in Quarkus.
I have tendency towards Quarkus though, as ClassGraph hasn't change, but Quarkus seems to have.

The thing is reproducible with the above project in this branch https://github.com/michael-simons/neo4j-migrations/tree/dependabot/maven%2Fquarkus.version-2.7.0.Final

when building like this:

./mvnw -am -pl :neo4j-migrations-quarkus-integration-tests -pl :neo4j-migrations-quarkus -pl :neo4j-migrations-quarkus-deployment clean verify

Logs are attached, they are too large for the comment.

As usual, please let me know if I can point or help you in any other way or form.

log-working-quarkus26.txt

log-broken-quarkus27.txt

@lukehutch
Copy link
Member

This should be fixed via #642. I pushed out a new release, 4.8.139. Sorry for the delay in responding! Please let me know if further fixes are needed. Thank you for the report, and the fix!

@michael-simons
Copy link
Contributor Author

Thanks a ton, Luke and no worries and no need to apologize for time constraints. Most of us have.

Anyway, I can confirm it works as expected:

with Quarkus 2.6
michael-simons/neo4j-migrations#405

The combined upgrade to 2.7 and 4.8.139
michael-simons/neo4j-migrations#401

Thank you!

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

No branches or pull requests

2 participants