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

ClassNotFoundException when using an JCache EntryProcessor PAYARA-1257 #759

Closed
OndroMih opened this issue Apr 18, 2016 · 19 comments
Closed
Assignees
Labels
Type: Enhancement Label issue as an enhancement request
Milestone

Comments

@OndroMih
Copy link
Contributor

This issue is created from GitHub gist by @ivannov:
https://gist.github.com/ivannov/906096dcff2100ccd5b2ef11f97362dd

More detailed information on Java EE Guardian mailing list: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/javaee-guardians/8QxcgzGdt1o/dMU0wqh0LgAJ

Summary:

We implemented our simple entry processor by the JCache spec.
cache.invoke() with the entry processor fails on java.lang.ClassNotFoundException: bg.jug.guestbook.entities.Comment

@fturizo
Copy link
Contributor

fturizo commented Dec 3, 2016

@OndrejM, any progress on this issue?

@OndroMih
Copy link
Contributor Author

OndroMih commented Dec 7, 2016

No progress, still to reproduce and confirm if it's a bug.

@ivannov
Copy link

ivannov commented Dec 7, 2016

@OndrejM as it was reported as a result of the Bulgarian JUG hackathon on JCache, here is a sample project:
https://github.com/bgjug/jcache-workshop

You can find there an application where it is reproduced and under the docs directory are the (pretty lengthy) instructions to get there

@jerrinot
Copy link
Contributor

jerrinot commented Dec 7, 2016

This will be indeed tricky to solve.

Hazelcast is part of Payara and it is not loaded by the same classloader as a webapp. When you do map.get() then I believe Payara set TCCL to the application classloader -> Hazelcast finds your application class when deserializing the result -> everything appears to work.

However when you invoke an entry processor then the receiving Hazelcast member is not deserializing it on user-thread -> TCCL is not set -> ClassNotFoundException

For Payara Micro this could be solved by setting Hazelcast classloader to the same classloader as the webapp uses, but I am not sure how to solve this in general.

@smillidge
Copy link
Contributor

It's possible we could write a classloader that could reach into the different deployed applications to look for classes and add that to Hazelcast. We did an experiment by creating one and bootstrapping Hazelcast with that classloader as its TCCL however that caused service loading issues in Hazelcast. We haven't tried the Config class. Another alternative we've been told may work is a custom Hazelcast Serializer.

@OndroMih OndroMih changed the title ClassNotFoundException when using an JCache EntryProcessor ClassNotFoundException when using an JCache EntryProcessor PAYARA-1257 Dec 7, 2016
@jerrinot
Copy link
Contributor

jerrinot commented Dec 9, 2016

Of course, I would never write something like this

(I double-checked the commit is not signed so I can still maintain plausible deniability :-D)

image

@smillidge
Copy link
Contributor

did it work though?

@jerrinot
Copy link
Contributor

jerrinot commented Dec 10, 2016

It did work. I deployed the demo application @ivannov linked + added a simple entry processor.

Then I started a standalone application with a Hazelcast client and invoked the entry processor from the client. The entry processor (packaged inside my WAR) was executed on a Payara member.

I talked to @vbekiaris about this and it appears a real solution would require 1st class multi-tenancy support inside Hazelcast. 1 app = 1 Hazelcast tenant. Otherwise there is really no good way to link a serialized blob to an application context. Unless you want to start a cluster per application.

@lprimak
Copy link
Contributor

lprimak commented Dec 10, 2016

Has anyone tried to put hazelcast into applibs classloader? That may be a good workaround until something is devised by Payara. I have some ideas on automating this.

@lprimak
Copy link
Contributor

lprimak commented Jan 4, 2017

I have an idea:
appRegistry can be used to cycle & delegate through all app class loaders (i.e. delegated class loader) and it's used for the Hazelcast serialize classloader. This would be simple and builds on the work I've already done

@jerrinot
Copy link
Contributor

@lprimak: you mean something like this?

one problem with this approach is that it breaks classloader isolation between applications. imagine you have different versions of a class packaged in different applications.

@smillidge
Copy link
Contributor

smillidge commented Jan 18, 2017

we could potentially put an indication into the serialization stream with a custom serializer that indicated the application the class is from.

App registry with a custom serializer should work

@lprimak
Copy link
Contributor

lprimak commented Jan 18, 2017

Yes, or something similar

@lprimak
Copy link
Contributor

lprimak commented Mar 1, 2017

@ivannov I am working on Payara fixes so your workarounds are no longer necessary

@lprimak
Copy link
Contributor

lprimak commented Mar 6, 2017

I am excited to report that the application now works correctly using the custom serializer.
Cleanup / productionalization of this will take some more doing, but the proof of concept works.

@lprimak
Copy link
Contributor

lprimak commented Mar 8, 2017

Guestbook app that works with these fixes:
jcache-workshop.zip

@lprimak lprimak added 4:Ready Type: Enhancement Label issue as an enhancement request and removed 3:DevInProgress labels Mar 9, 2017
@fturizo fturizo removed the 4:Ready label Mar 19, 2017
@OndroMih
Copy link
Contributor Author

Hi @ivannov,
This issue should be fixed now in master and will be available in version 172. If you have some time, you can test it even now with the latest nightly build (http://www.payara.fish/upstream_builds)

@OndroMih OndroMih added this to the Payara 172 milestone Apr 11, 2017
@lprimak
Copy link
Contributor

lprimak commented Jun 23, 2020

Relates to hazelcast/hazelcast#10875

@lprimak
Copy link
Contributor

lprimak commented Jun 23, 2020

Should work since 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Label issue as an enhancement request
Projects
None yet
Development

No branches or pull requests

7 participants