Skip to content

Conversation

@reda-alaoui
Copy link

Fix #28984

@elasticmachine
Copy link
Collaborator

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
@elasticmachine
Copy link
Collaborator

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?

Copy link
Member

@jasontedor jasontedor left a 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.

Copy link
Member

@jasontedor jasontedor left a 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.

@jasontedor jasontedor added the :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts label Mar 13, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Member

@jasontedor jasontedor left a 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.

@jasontedor jasontedor added :Delivery/Build Build or test infrastructure and removed :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts labels Mar 13, 2018
@reda-alaoui
Copy link
Author

I don't see how to check that except by creating a full Java 9 module?
Do you want me to add a java9 gradle consumer module?

@reda-alaoui
Copy link
Author

@jasontedor , I added a test module

@reda-alaoui
Copy link
Author

The added test module doesn't fail compilation when changes are reverted ...
Maybe it is just a Maven issue :/

@jasontedor
Copy link
Member

@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.

@reda-alaoui
Copy link
Author

reda-alaoui commented Mar 14, 2018

@jasontedor , would it be ok to replace the test Gradle module by a Maven module?
I would trigger its build via a gradle exec task.

@reda-alaoui
Copy link
Author

I am having issues with the added module because of gradle/gradle#3035.
I am not sure if I can disable compileJava fork in the submodule.

@tomdw
Copy link

tomdw commented Aug 10, 2018

@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?

@javanna
Copy link
Member

javanna commented Oct 2, 2018

@jasontedor do we want to get this merged? Or has it become outdated and maybe no longer needed?

@tomdw
Copy link

tomdw commented Oct 2, 2018

@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
Copy link
Contributor

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;
Copy link
Contributor

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 ).

Copy link

@tomdw tomdw Jan 17, 2019

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' ?

Copy link
Contributor

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.

Copy link

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?

Copy link

@tomdw tomdw Jan 27, 2019

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

Copy link
Contributor

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.

@MrGraversen
Copy link

MrGraversen commented Jan 29, 2019

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?

@jasontedor
Copy link
Member

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.

Copy link
Member

@jasontedor jasontedor left a 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 {
Copy link
Member

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?

@alpar-t
Copy link
Contributor

alpar-t commented Feb 4, 2019

Thanks for your contribution @reda-alaoui but we decided to remove the empty service files (#38192) and address jigsaw support more broadly #38299.

@alpar-t alpar-t closed this Feb 4, 2019
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Delivery/Build Build or test infrastructure Team:Delivery Meta label for Delivery team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java 9: requiring elasticsearch from module-info.java fails with "module not found"

10 participants