-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Java 9: requiring elasticsearch from module-info.java fails #29030
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
Conversation
|
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
1 similar comment
|
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
jasontedor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove author and date tags. Sorry, but these are a no-go. They are clutter at the top of the file, the information contained in them is available in commit history which is the single-source of truth for this information.
This does not constitute a review of the functionality being added, nor does it constitute and implicit "if you fix these we will pull this PR". Those will be considered separately.
jasontedor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, these are missing the license header.
|
Pinging @elastic/es-core-infra |
jasontedor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another issue here is that there are no build checks being added to ensure that we do not break this again.
|
I don't see how to check that except by creating a full Java 9 module? |
|
@jasontedor , I added a test module |
|
The added test module doesn't fail compilation when changes are reverted ... |
|
@reda-alaoui Thank you so much for pushing on this and adding a test, it really helps clarify the problem, ensure correctness, and would help us maintain this code if it were to be integrated. Since this is now appearing to be a Maven issue, I will put reviewing of this on hold. |
|
@jasontedor , would it be ok to replace the test Gradle module by a Maven module? |
|
I am having issues with the added module because of gradle/gradle#3035. |
|
@jasontedor as I understand it correctly it is not solely a maven issue, service providers have to be encapsulated in the module. Can the pr be merged to fix this to at least allow jdk 9 modules projects use elasticsearch on the module path as automatic module? |
|
@jasontedor do we want to get this merged? Or has it become outdated and maybe no longer needed? |
|
@javanna certainly not outdated as it is still a problem to use elasticsearch libraries on the modulepath. This pr fixes that. |
|
|
||
| apply plugin: 'elasticsearch.build' | ||
|
|
||
| sourceCompatibility = JavaVersion.VERSION_1_9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test folder is a collection of tools, and actual test projects live in qa, but for testing the build, I would move this to buildSrc/src/testKit and write a GradleIntegrationTestCase for it.
The source and target comparability can be parameters passed to the build so that we can test on newer than 9 also or control the Gradle version if we have too.
| * under the License. | ||
| */ | ||
| module jigsaw_consumer { | ||
| requires elasticsearch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the comments in the issue that this will in fact fail at runtime, i'm concerned this might send the wrong message.
If I understand this right, you are hitting this problem because you move all classpath to the module path in your application to create automatic modules. You are probably only using a client of elasticsearch, but since elasticsearch is a dependency, it gets added as a module and causes issues.
On the other hand, where this would fail if I understand @uschindler right, is if one embeds elasticsearch in another application to make use of it's functionality, but this is not something we support.
I'm a bit confused about why you would require elasticsearch and not one of the clients.
Could you clarify that ? Is the requires necessary to reproduce the issue ?
I'm thinking that a more common use-case would be to depend and require on the client ( elasticsearch would be a transitive dependency and still be added as an automatic module ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atorok I think some types needed to use a client are in the elasticsearch jar, so an application still needs elasticsearch jar on its path even if it does not embed it as server. e.g. https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/index/query/QueryBuilders.java is in the elasticsearch jar and is used to build queries towards elasticsearch (same for org.elasticsearch.search.aggregations.AggregationBuilders)
which maven dependency are you referring to with 'client' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct @tomdw , both org.elasticsearch.client:elasticsearch-rest-high-level-client and org.elasticsearch.client:transport depend on org.elasticsearch:elasticsearch. I'm assuming that an application would rather require one of those clients so it can talk to ES . I'm assuming you ended up having troubles with ES because you moved your classpath to module path, to make all jars automatic modules , which does include includes org.elasticsearch:elasticsearch as per the dependencies.
I think a test should rather have requires elasticsearch-rest-high-level-client; since this actually what users will have in their modules. requires elasticsearch; would be a line for when elasticsearch-rest-high-level-client would get a moule-info.
We could then go a step beyond ( not necessarily as part of this PR to have some code in the application that actually talks to a test cluster. I would expect the former to fail the same way without the fixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atorok unfortunately code using the high level rest client still needs to requires elasticsearch; next to the requires elasticsearch-rest-high-level-client; because org.elasticsearch.index.query.QueryBuilder and others are in the elasticsearch jar and you can't call high level client APIs taking it as argument without also requiring the module containing org.elasticsearch.index.query.QueryBuilder
Would be better if the query building classes are extracted into their own module, something like 'elasticsearch-common-client' which is then used as shared module. Then a dependency on 'elasticsearch' might be avoidable.
Doesn't take away though that the 'elasticsearch' jar is not respecting the java spec by including META-INF/services/... files which point to non-existing packages and classes. When will this be fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@atorok noticed another problem today: when you require elasticsearch-rest-high-level-client then you have a split package problem with elasticsearch.rest.client:
"reads package org.elasticsearch.client from both elasticsearch.rest.high.level.client and elasticsearch.rest.client"
which makes it impossible to use the high level rest client on the module path as automatic module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not arguing against fixing the missing classes, but I want to make sure that the test we add will be a complete representation of how one might integrate an elasticsearch client into a jigsaw application so it can even serve as an example of how to do it.
|
Hi @atorok and / or @jasontedor, At my company we are currently waiting on this fix. Otherwise, we'd have to stand up a new "search service", which runs Java 8 or otherwise don't use the module system - and I'm not super inclined to go this route. Could you share with us a possible timeline to get this merged, if you have it prioritised internally? |
I am sorry but we do not offer such timelines for releases, nor specific features, nor specific bug fixes. |
jasontedor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment about the change.
| * This marker is needed because Java 9 compiler expects the current package to contain at least one class during | ||
| * automodule descriptor derivation process. | ||
| */ | ||
| interface JigsawMarker { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these are necessary, we can remove the empty service files instead?
|
Thanks for your contribution @reda-alaoui but we decided to remove the empty service files (#38192) and address jigsaw support more broadly #38299. |
Fix #28984