Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

It's been a while since I dipped my feet into Oracle Coherence but I figured that I'd revisit the topic again. In 2018 after upgrading to WebLogic 12.2, I started to experience some class loader issues, this unfortunately impacted how my web services were loading Coherence configuration. It turned out that the tangosol-coherence-override.xml file wasn't being loaded from the WEB-INF/classes directory and I needed a different solution.

After some initial tinkering, everything worked fine when I had a single web service deployed, but when I tried to deploy multiple services that used Coherence, the following exception would get thrown during service startup...
java.lang.IllegalStateException: Service "ReplicatedCache" has been started by a different configurable cache factory.

Ugh! Maybe I needed to look at my class loader configuration in better detail, but I felt like there should be a very simple solution for this.

This article was a great help, but it wasn't the final solution. I didn't want to specify the entire Coherence cache configuration programatically but I did want to control which configuration file was loaded by Coherence using code in my web service's PostConstruct annotated method.

Discussing the issue with a Coherence engineer, this is something I ended up coming up with...
ExtensibleConfigurableCacheFactory.Dependencies deps =
ExtensibleConfigurableCacheFactory factory =
new ExtensibleConfigurableCacheFactory(deps);
ClassLoader loader = this.getClass().getClassLoader();
NamedCache nc = factory.ensureCache("MY_CACHE", loader);

The key was the ExtensibleConfigurableCacheFactory.DependenciesHelper class. The file, my-coherence-cache-config.xml, was bundled with my web service (WEB-INF/classes) and contained all the Coherence cache configuration that was needed for a specific web service. Now different web services could load their own configurations! The main down-side was that I needed to keep track of the factory class.

In the end I didn't use this approach and opted for an even simpler solution, which I'll discuss in another article. Update: the simpler solution blog post is here - Easiest way to specify custom Coherence cache configuration with WebLogic 12c.


Skip down to comments...
Hope you found this post useful...

...so please read on! I love writing articles that provide beneficial information, tips and examples to my readers. All information on my blog is provided free of charge and I encourage you to share it as you wish. There is a small favour I ask in return however - engage in comments below, provide feedback, and if you see mistakes let me know.

If you want to show additional support and help me pay for web hosting and domain name registration, donations, no matter how small, are always welcome!

Use of any information contained in this blog post/article is subject to this disclaimer.
comments powered by Disqus
Other posts you may like...