-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Bash embedded jar as repackaging option #1117
Comments
Do you have the source code? I'm not too keen to run a random jar on my computer :) |
Phil, can't share the code for this project, will see if I can create a single project that will replicate this issue. So far trying to move the NopSecurityManager out of the dependent jar into the spring-boot-sandbox build does not produce the error. So seems like the issue is even more convoluted and only revels itself when I try to do |
Here are the relevant security classes that I can share the source of:
TrivialPolicy.java
AllPermissionCollection.java
It seems that something weird only happens when I have
inside a class that lives in a different jar from where the |
I've done a bit of digging. I think this might be the root cause of the problem: |
Try adding |
Phil, that's exactly the cause. When setting the property, the test.run with embedded jar inside works just fine (as well as when calling explicitly java -jar spring-boot-sandbox.jar). What is VERY STRANGE, is why does Any thoughts or theories on what could cause this? |
I'm guessing that I didn't pick it up with any of the regular samples because they don't have a |
Just verified that this indeed only happens when running under JDK 1.8, when starting under 1.7 (I've rebuilt the jar using 1.7) there is no classloading problem, it only occurs in 1.8 when the system prop is not set. :( |
Interesting. I wonder if we are able to programmatically add the property? |
Would there be any possible undesirable side effects by not having the jar checking taking place? |
I can't foresee any, I wonder why the check was added in the first place? |
This is what I found when looking for the implementation of the checker - http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/util/zip/ZipFile.java#780 |
The check might try to do some security validation to try to prevent malicious jars that don't conform with strict format rules JDK imposes. I guess, since this only applies to the embedded jars, we can always just hard-code the So the template can look like this:
BTW, the template above does on-the-fly extraction of Would there be any interest in backing this into a gradle task as part of the gradle boot plugin to also be able to create not only executable jar but also an embedded runnable shell? |
Definitely there is interest. Maybe using some if the extended features of the Boot CLI shell wrapper for detecting JAVA_HOME etc (which we copied from groovy.sh). We would need Maven feature parity as well so pulling the code out into the shared tools would be a good plan. |
@wilkinsona I first found it while looking at Netflix/denominator build a long time ago, then searched google for a maven version. |
Update the Maven and Gradle plugin to generate fully executable jar files on Unix like machines. A launcher bash script is added to the front of the jar file which handles execution. The default execution script will either launch the application or handle init.d service operations (start/stop/restart) depending on if the application is executed directly, or via a symlink to init.d. See gh-1117
Tests are currently breaking on Windows:
|
When trying to run the application from a jar that has been embedded into an executable bash script, I get
ClassNotFoundException: org.springframework.context.support.LiveBeansView
When starting the application by using
java -jar <jar_name>
everything starts just fine.The command to generate the executable bash is:
cat stub.sh build/libs/spring-boot-sandbox.jar > test.run
stub.sh:
It seems that the problem stems with setting a custom
SecurityManager
https://www.dropbox.com/s/tlo43vlqtcnh5bb/spring-boot-sandbox.jar - works fine
https://www.dropbox.com/s/dbyb1cd8yxfr3li/test.run - creates errors at startup
The text was updated successfully, but these errors were encountered: