transport client fails in uber jar - no shortHash #21627

Closed
brackxm opened this Issue Nov 17, 2016 · 9 comments

Comments

Projects
None yet
9 participants
@brackxm
Contributor

brackxm commented Nov 17, 2016

Elasticsearch version: 5.0.1

Plugins installed: [ReindexPlugin, PercolatorPlugin, MustachePlugin, Netty3Plugin, Netty4Plugin, XPackPlugin]

JVM version: 1.8.0_112

OS version: osx 10.12.1

Description of the problem including expected versus actual behavior:

Getting the cluster node info fails when using the transport client from an uber jar.
Similar to #19930, but using the transport client.
NodeInfo.readFrom() triggers the initialisation of Build.CURRENT which fails with "Error finding the build shortHash"

Steps to reproduce:

  1. build uber jar with the transport client
  2. get cluster node info

Provide logs (if relevant):

Describe the feature:

Maybe get the build info from an elasticsearch specific file in the classpath, so it is more uber jar friendly.

@liorze

This comment has been minimized.

Show comment
Hide comment
@liorze

liorze Nov 20, 2016

You should create the jar using the maven-shade-plugin, by adding it to your pom file:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4.1</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals><goal>shade</goal></goals>
            <configuration>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>com.company.Application</mainClass>
                        <manifestEntries>
                            <Change></Change>
                            <Build-Date></Build-Date>
                        </manifestEntries>
                    </transformer>
                </transformers>
            </configuration>
        </execution>
    </executions>
</plugin>

You must have the Change and Build-Date entries in the manifest file. See here:

shortHash = manifest.getMainAttributes().getValue("Change");

liorze commented Nov 20, 2016

You should create the jar using the maven-shade-plugin, by adding it to your pom file:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4.1</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals><goal>shade</goal></goals>
            <configuration>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>com.company.Application</mainClass>
                        <manifestEntries>
                            <Change></Change>
                            <Build-Date></Build-Date>
                        </manifestEntries>
                    </transformer>
                </transformers>
            </configuration>
        </execution>
    </executions>
</plugin>

You must have the Change and Build-Date entries in the manifest file. See here:

shortHash = manifest.getMainAttributes().getValue("Change");

@jasontedor

This comment has been minimized.

Show comment
Hide comment
@jasontedor

jasontedor Nov 22, 2016

Member

Sorry, but I don't think we are going to modify our build process to support tearing our jar apart.

Member

jasontedor commented Nov 22, 2016

Sorry, but I don't think we are going to modify our build process to support tearing our jar apart.

@jasontedor jasontedor closed this Nov 22, 2016

@liorze

This comment has been minimized.

Show comment
Hide comment
@liorze

liorze Nov 22, 2016

@jasontedor, are you suggesting that you don't support running the transport client in a jar?

liorze commented Nov 22, 2016

@jasontedor, are you suggesting that you don't support running the transport client in a jar?

@jasontedor

This comment has been minimized.

Show comment
Hide comment
@jasontedor

jasontedor Nov 22, 2016

Member

are you suggesting that you don't support running the transport client in a jar?

I'm saying that if you tear our jar apart, you need to put it back together with all the pieces that we expect to be there (for example, having the manifest entires that we are looking for like you suggested previously).

Member

jasontedor commented Nov 22, 2016

are you suggesting that you don't support running the transport client in a jar?

I'm saying that if you tear our jar apart, you need to put it back together with all the pieces that we expect to be there (for example, having the manifest entires that we are looking for like you suggested previously).

@liorze

This comment has been minimized.

Show comment
Hide comment

liorze commented Nov 22, 2016

You should at least update the docs to avoid this confusion in the future.
https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_embedding_jar_with_dependencies.html

@jasontedor jasontedor reopened this Nov 22, 2016

@jasontedor

This comment has been minimized.

Show comment
Hide comment
@jasontedor

jasontedor Nov 22, 2016

Member

Okay, we will do that. Thanks for the heads up.

Member

jasontedor commented Nov 22, 2016

Okay, we will do that. Thanks for the heads up.

@jasontedor jasontedor removed the discuss label Dec 2, 2016

@jpountz jpountz added the adoptme label Dec 2, 2016

@csouthwell

This comment has been minimized.

Show comment
Hide comment
@csouthwell

csouthwell Apr 12, 2017

If your using Lein (w/clojure) how can you resolve the META-INF like using shade in maven?

If your using Lein (w/clojure) how can you resolve the META-INF like using shade in maven?

@tvernum

This comment has been minimized.

Show comment
Hide comment
@tvernum

tvernum Apr 13, 2017

Contributor

@csouthwell I think you're going to need to ask some Leiningen experts, the ES team doesn't have expertise in how to do things that we don't support, in a build tool that we don't support. Sorry.

My advice would be to hit stackoverflow (or a lein specific forum) and ask how to add specific entries to the manifest when running lein uberjar

Contributor

tvernum commented Apr 13, 2017

@csouthwell I think you're going to need to ask some Leiningen experts, the ES team doesn't have expertise in how to do things that we don't support, in a build tool that we don't support. Sorry.

My advice would be to hit stackoverflow (or a lein specific forum) and ask how to add specific entries to the manifest when running lein uberjar

@martijnvg

This comment has been minimized.

Show comment
Hide comment
@martijnvg

martijnvg Mar 14, 2018

Member

Closing issue. The paragraph about shading has been removed: ab2d74c

Member

martijnvg commented Mar 14, 2018

Closing issue. The paragraph about shading has been removed: ab2d74c

@martijnvg martijnvg closed this Mar 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment