Ehcache not replicating - (solution)

江枫思渺然 提交于 2020-01-03 05:35:08

问题


Thought I'd let this out to anyone having similar problems.

Info: Running linux (ubuntu), x64, latest java-version (1.7.25), latest tomcat (7.40).

I had set up two apache tomcats locally, and the same webapp on both tomcats, to test some ehcache functionality and the cache replicated and all was great.

Once I set up a dedicated server with the second tomcat instance the EhCache didn't replicate between my PC and the server (still in the testing phase).

All the configs were basically the same without of course the ip-addresses being different. As I wasn't using the hostname of the server and computer from the DNS, i instead had added hostnames into the /etc/hosts-file on both the pc and the server - thinking this would be sufficient.

After a couple of hours being a hater - grinding my teeth - I decided to remove all added entries to /etc/hosts, and instead use the boring hostnames in the DNS of our company (pc-103-15-87.xxxxx.com and pc-104-15-87.xxxxx.com ) and then everything worked.

Running 'wireshark' before I had the solution it showed me that the both ehcache-instances were chatting, but the ip-address '127.0.0.1' (probably used as some sort of callback address), was "mentioned" in the communication between both ehcache instances.

This led me to remove everything I had added in /etc/hosts and use the DNS resolvable names. Now everything in 'wireshark' showed me all the correct ip-addresses and everything was gold.

Hope this will help anyone with a similar problem.

XML:

The info for the peer:

<cacheManagerPeerProviderFactory
    class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
    properties="peerDiscovery=manual,
    rmiUrls=//pc-103-15-87.xxxxx.com:40002/persons|//pc-103-15-87.xxxxx.com:40002/wordCache"/>

and the listener on this server:

<cacheManagerPeerListenerFactory 
    class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
    properties="hostname=pc-104-15-87.xxxxx.com, port=40002, socketTimeoutMillis=3000"/>

回答1:


The solution was to use the hostnames that where in the DNS of the organization, and not rely on my own entries in /etc/hosts



来源:https://stackoverflow.com/questions/17314121/ehcache-not-replicating-solution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!