-
Notifications
You must be signed in to change notification settings - Fork 306
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
Cannot load Hazelcast and use Cache on new Payara with JDK8 #196
Comments
Hi David, can you double-check your EAR doesn't contain a JAR with JCache API or Hazelcast? I's just a shot in the dark, but it's worth checking. Is it working when you let Payara to inject the CachingProvider to your bean via CDI @Inject instead? |
No, Hazelcast is not present in EAR file. The second question is only for experiment, because this class is not a bean. But I will try it in some bean. |
CacheProvider is not injected at all (tried servlet, stateless bean, message listener) - it is null and no error is reported, except MessageListener, where it reported "unsatisfied ependency" to server.log. Injecting CacheManager (see jsr107/jsr107spec#208 ) causes stacktrace even in stateless bean (other beans are injected correctly):
I have no idea what to do. |
I can't reproduce with our test JCache application running on JDK1.8. OTOH all our test applications are Servlets and session beans in wars. Do you have a simple test case we can review as we may not have captured your specific deployment scenario in testing. I do know, which I note is missing from our documentation. Is that you must copy payara-jsr107.jar from glassfish/modules to domains/domain1/lib/applibs and reference it as a library during deployment to get injection to work in an EJB Session Bean. This is part of the EJB spec. |
Also dumb question I know. |
Also the discussions in jsr107/jsr107spec#208 are NOT in the JSR107 spec as is but are deferred to the next JCache release. |
Injection to bean works, but it is needed to enable Hazelcast in the server configuration also with "Dynamic" checked. Then comes another problem - server cannot be restarted, start ends with stopping the instance and this stacktrace:
|
Clear out your osgi-cache. |
We have seen this intermittently with a Ctrl-C and immediate restart |
Removing the osgi-cache does not help :(
Stopping and starting the domain is impossible without disabling hazelcast via domain.xml. |
Funny is that this exception I got even with Hazelcast disabled (I know, it's another mechanism, but ...). |
Do you have a test case EAR file we can inviestigate with? |
Now I used this code and I got "multiple cachingproviders" error again ...
But then I used your hack from HazelcastCore, it inspired me and I tried a bit of "shotgun debugging":
But this is not possible from an application:
Another attempt:
And once more ...
And surprise ...
But this behavior is really weird:
And this causes exception:
This seems that CachingProvider was compiled after HazelcastCachingProvider, but - then it should not work in any case. But when enabling the Hazelcast dynamically via appserver GUI it works without problems ... until restart of appserver. I don't get it. |
I will try to create some. |
What is your deployment structure and which jar in your deployment are you trying to load the caching provider in? Can you access the caching provider from JNDI? |
I have no problem deploying this https://github.com/smillidge/JCacheTestEAR As long as I ensure I reference payara-jsr107.jar as a libary If I then reference the servlet I get hex System.currentTimeMillis which doesn't change (as it is cached) and I get the System.out.println [#|2015-02-05T20:24:37.873+0000|INFO|Payara 4.1||_ThreadID=34;_ThreadName=Thread-9;_TimeMillis=1423167877873;_LevelValue=800;| [#|2015-02-05T20:24:37.873+0000|INFO|Payara 4.1||_ThreadID=34;_ThreadName=Thread-9;_TimeMillis=1423167877873;_LevelValue=800;| [#|2015-02-05T20:24:37.873+0000|INFO|Payara 4.1||_ThreadID=34;_ThreadName=Thread-9;_TimeMillis=1423167877873;_LevelValue=800;| |
Structure is standard: Now on my notebook I have changed port from 5900 to 5950. Hurray, domain started, but instead one port I got two and I don't understand how, but the first item is the second notebook. No, I don't have domain configured as cluster ...:
Okay, now the JNDI ... |
If you are loading the CachingProvider directly in the jar using the api Caching.getCachingProvider() you will get a different CachingProvider instance than the Payara in-built one, due to classloading. You need to inject via CDI, or lookup via JNDI to consistently get the correct CachingProvider instance. Hazelcast JCache cluster is independent of the Payara cluster and is determined by the multicast Group and multicast port. Therefore the two servers will form a JCache cluster even across separate Payara domains if the multicast settings are the same. |
Okay, if the server starts (asadmin stop-domain, wait until the process really stopped after asadmin reported it stopped, and run asadmin start-domain), then JNDI works perfectly. If I run asadmin restart-domain, Hazelcast does not start or starts broken (see previous stacktraces). Thanks for explanation, now everything seems logical, except one thing - simply, this is not true:
|
I think the restart bug is due to the classloader hack used to get around a problem in Hazelcast. This is no longer needed in Hazelcast 3.4. Removing the hack seems at initial first sight to solve the restart domain intermittent failure. See #154 for tracking the restart problem |
Perhaps an upgrade to Hazelcast 3.5 would help as well. I had an app that worked on Glassfish but was using Hazelcast embedded in the application as JCache is not part of the Java EE standard yet. Having Hazelcast be a part of the core JARs for the application server can introduce issues. |
specifically mine on JDK8 is
and on JDK7
I do use the jcache-1.0.0 dependency so that may add to the issue. |
I am also getting this error with Payara 4.1.2.172. |
@trajano Were you able to find a solution? I am getting that same error message on JDK8. |
You also need to remove |
See https://payara.gitbooks.io/payara-server/documentation/extended-documentation/classloading.html |
cache-api and jsr107-repackaged should not both be in the modules directory this is a bug on our side. |
I don't know if it is a bug of Payara, Hazelcast or JDK, but in unit test CachingProvider.class.isAssignableFrom(HazelcastCachingProvider.class) returns true. Following code is placed in a library deployed to Payara in EAR. Library is then used from EAR's EJB module.
System used: Kubuntu Linux 64bit
JDK used: OpenJDK 1.8.0u40b12, 1.8.0u40b23, Oracle JDK 1.8.0u31 - always same problem.
Code used:
Problematic code in Cache API (javax.cache.Caching):
The text was updated successfully, but these errors were encountered: