[
https://issues.apache.org/jira/browse/TOMEE-1723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15193105#comment-15193105
]
Romain Manni-Bucau edited comment on TOMEE-1723 at 3/14/16 11:05 AM:
---------------------------------------------------------------------
[~kmpraveen10] Great, I would recommand you to not use a static block but
either a @Singleton @Startup with a @PostConstruct - or any other EE startup
lifecycle hook - to init hazelcast and use
Thread.currentThread().getContextClassLoader() instead of
getClass().getClassLoader() to avoid surprises if any refactoring is done. It
also opens nicely the door to a clean shutdown (on the hazelcast lifecycle).
Here is an example for tomee 7:
{code}
public class HazelcastInstanceManager {
@Produces
@ApplicationScoped
public HazelcastInstance instance() {
return Hazelcast.newHazelcastInstance(/*config skipped to stay
concise*/);
}
public void destroy(@Disposes final HazelcastInstance instance) {
instance.getLifecycleService().shutdown();
}
public static class Start { // ensure it is started with the container and
not at first need
@Inject
private HazelcastInstance instance;
public void start(@Observes @Initialized(ApplicationScoped.class) Object
start) {
instance.getCluster();
}
}
}
{code}
was (Author: romain.manni-bucau):
[~kmpraveen10] Great, I would recommand you to not use a static block but
either a @Singleton @Startup with a @PostConstruct - or any other EE startup
lifecycle hook - to init hazelcast and use
Thread.currentThread().getContextClassLoader() instead of
getClass().getClassLoader() to avoid surprises if any refactoring is done. It
also opens nicely the door to a clean shutdown (on the hazelcast lifecycle).
> Hazelcast integration in TomEE
> ------------------------------
>
> Key: TOMEE-1723
> URL: https://issues.apache.org/jira/browse/TOMEE-1723
> Project: TomEE
> Issue Type: Bug
> Components: TomEE Core Server
> Affects Versions: 1.7.2
> Environment: J2EE application deployed in TomEE, using Hazelcast
> distributed executor APIs
> Reporter: Praveen
> Fix For: 1.7.3
>
>
> Tomee has Hazelcast jar in it's library. I am using TomEE1.7.2 which has
> Hazelcast 3.5 version. The application is deployed in multiple tomee
> instances and Hazelcast cluster has formed successfully. However when i tried
> distributed executor to execute the task on other JVM, the task executed
> successfully on other JVM but the control is not coming back to the source
> JVM. Finally the Future task timeouts and returns null. Other Hazelcast
> features (distributed map, cluster formation etc.) are working fine except
> distributed executor. I have used same version of Hazelcast in pom.xml with
> scope provided.
> Surprising behavior is - deleting the Hazelcast jar from Tomee library and
> including explicit dependency on Hazelcast jar of same version (3.5) in the
> application is working fine. Not able to comprehend this behavior.
> Using latest versions of Hazelcast (3.6.1) in TomEE also didn't solve the
> issue.
> Looks like an integration issue of TomEE with Hazelcast.
> Please investigate and let us know the solution and root cause.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)