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

Wrong manifest file read #1

Closed
frederikhegger opened this issue Mar 14, 2019 · 8 comments

Comments

Projects
None yet
2 participants
@frederikhegger
Copy link

commented Mar 14, 2019

I experienced a problem, when using getVersionNameFromManifest() in combination with a JAR. Then unfortunately, a META-INF/MANIFEST.MF from the classpath is read, and not the one from the actual package which includes the "versionName".

In my simple example the META-INF/MANIFEST.MF from sun.net.www.protocol.jar.JarURLConnection:jar:file:/C:/Program%20Files/Java/jdk1.8.0_172/jre/lib/charsets.jar!/META-INF/MANIFEST.MF is read and thus does not find the key "versionName".

The problem can be tracked down to the code part where the manifest is read using the classloader:

https://github.com/triologygmbh/versionName/blob/d36a6c2e7bf6d35597adb54779d383f63de332b6/versionName/src/main/java/de/triology/versionname/VersionNames.java#L72
https://github.com/triologygmbh/versionName/blob/d36a6c2e7bf6d35597adb54779d383f63de332b6/versionName/src/main/java/de/triology/versionname/VersionNames.java#L201

@schnatterer

This comment has been minimized.

Copy link
Member

commented Mar 18, 2019

Could you provide some more info?

  • How can this reproduced?
    There is a JAR example in the repo. What did you do differently for your issue to occur?
  • What JDK are you on?
@frederikhegger

This comment has been minimized.

Copy link
Author

commented Mar 19, 2019

I can reproduce it using the example from your repository and JDK 1.8.0_172:

grafik

@schnatterer

This comment has been minimized.

Copy link
Member

commented Mar 19, 2019

Thanks, I'll look into it and get back once I know more.

schnatterer added a commit that referenced this issue Mar 21, 2019

Jenkins: Adds assertion for running on openJDK.
This is related to the hypothesis that #1 is caused on OpenJDK only.

schnatterer added a commit that referenced this issue Mar 21, 2019

@schnatterer

This comment has been minimized.

Copy link
Member

commented Mar 21, 2019

That's a tough one!
Could not reproduce the issue with oracle JDK neither locally, nor on our jenkins, which ran on Oracle JDK 8u 202.

I could however reproduce your issue with docker:

docker run --rm -it -v $(pwd):/app piegsaj/oracle-jre:1.8.0_102-b14 java -jar /app/examples/jar/target/jar-1.0.3-SNAPSHOT-jar-with-dependencies.jar
1.0.3-SNAPSHOT (2019-03-21T09:43:49Z, branch develop, commit d36a6c2)
docker run --rm -it -v $(pwd):/app openjdk:8u102-jre java -jar /app/examples/jar/target/jar-1.0.3-SNAPSHOT-jar-with-dependencies.jar

Where the second command did not return anything.
So let me guess: You're running OpenJDK? Another option is that this issue is Windows-related.

Anyways, I implemented a proof of concept that fixed the issue for my docker test stated above.

Don't know if this fixes the issue on your side as well. So could you please validate this

  • by checking out, building and running the develop branch or e2ecd21?
  • Alternatively, you could use the versionName jar SNAPSHOT dependency from here.
@frederikhegger

This comment has been minimized.

Copy link
Author

commented Mar 22, 2019

Actually, I am using the Oracle JDK. Strange though.

I am going to try your changes today and come back to you then.

In any case, thanks for fast reply.

@frederikhegger

This comment has been minimized.

Copy link
Author

commented Mar 22, 2019

I can confirm that your changes made it working also for my machines and configurations.

Thanks a lot.

Will you prepare the release soon?

@schnatterer

This comment has been minimized.

Copy link
Member

commented Mar 28, 2019

I will create a new release in the next couple of days.
While I'm on it, this repo will be moved to a new home @cloudogu, which will most likely result in new maven coordinates and package names.
I suggest you use GitHub's watch feature for releases.

@frederikhegger

This comment has been minimized.

Copy link
Author

commented Mar 28, 2019

Perfect. Thanks a lot for the quick fix and info about the upcoming move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.