Trying to bundle hazelcast-kubernetes-plugin in micro payara

88 views
Skip to first unread message

Lars Lorenzen

unread,
Apr 24, 2017, 8:59:05 AM4/24/17
to Payara Forum
Hi, i am trying to bundle the hazelcast kubernetes plugin in the payara micro jar. 
In the old version 164 i could just use java -cp "hazelcast-kubernetes-plugin.jar:micro-uber-jar.jar" but that does not work anymore with 171.
So i tried to bundle the jar dependency inside the micro jar but now i get 

SEVERE: Error creating Uber Jar /Users/llorenzen/work/develop/micro-hazelcast/target/server.jar
java
.util.zip.ZipException: STORED entry where compressed != uncompressed size
 at java
.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:220)
 at java
.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
 at fish
.payara.micro.impl.UberJarCreator.buildUberJar(UberJarCreator.java:192)
 at fish
.payara.micro.impl.PayaraMicroImpl.packageUberJar(PayaraMicroImpl.java:2084)
 at fish
.payara.micro.impl.PayaraMicroImpl.main(PayaraMicroImpl.java:199)
 at sun
.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun
.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java
.lang.reflect.Method.invoke(Method.java:498)
 at fish
.payara.micro.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
 at fish
.payara.micro.boot.loader.Launcher.launch(Launcher.java:107)
 at fish
.payara.micro.boot.loader.Launcher.launch(Launcher.java:70)
 at fish
.payara.micro.boot.PayaraMicroLauncher.main(PayaraMicroLauncher.java:72)
 at fish
.payara.micro.PayaraMicro.main(PayaraMicro.java:358)

Is there any other way to include the hazelcast kuberentes plugin in the micro payara?

I'm also having the same problem with a custom logger formatter jar that i want to include.

An example project can be found here: https://github.com/dreamit-de/payara-micro-hazelcast-k8s

Thanks


Ondrej Mihályi

unread,
May 5, 2017, 4:01:16 AM5/5/17
to Payara Forum
Hi Lars,

The recommended way so far is to add classes to Payara Micro is to bundle the classes/JARs into a deployed WAR application. There is simply no other simple way how to do it. 

Classloading of internal Payara Micro classes and everything found on the same classpath has changed in version 171. This change was made after careful thought with the aim to solve repetitive issues with the old way of packaging, when all classes from different internal modules and the classpath were packaged together in a flat structure, causing lot of collisions and unexpected behavior.

Since version 171, Payara Micro loads classes from within the payara-micro.jar file with a special classloader and ignores classes added on the classpath with the -cp argument. We're considering adding support for loading classes on the base classpath, but we haven't analyzed that yet thoroughly enough.

Your approach of putting the JARs into the payara-micro.jar could work, but due to optimizations we did to speed up the boot process, nested JARs have to be uncompressed - that's why you get the exception after you put the hazelcast JAR inside. The same optimization is also present for example in standalone JARs generated by Spring Boot framework. You may work around this by repackaging the original Hazelcast JAR as an uncompressed one and then place it inside Payara Micro JAR. We'll add support for properly adding external libraries into the main JAR via a command line argument or even support reading classes passed by the -cp option in the future, but I can't promise any time frame for that.

Ondrej

Dňa pondelok, 24. apríla 2017 14:59:05 UTC+2 Lars Lorenzen napísal(-a):

Lars Lorenzen

unread,
May 5, 2017, 4:15:31 AM5/5/17
to Payara Forum
Hi Ondrej,

Thank you very much for looking into this. Hazelcast is used for the clustering so adding the library to our .war file does not work. Great to hear that you are planning to add support for additinal jar files.

I managed to work around this by not using the UberJar but a deployment from the command line. I'm still packaging the hazelcast-kubernetes.jar inside the micro jar but i'm no longer executing the uber jar builder. The payara micro start does not have problems with double-zipped jars :)

Lars
Reply all
Reply to author
Forward
0 new messages