Hi, I'm getting an exception when trying to access to my app that is making me crazy. I tried too many variants but none of them worked.
First of all, the structure:
I have one server called "front" running Glassfish 4 and the app deployed. The app uses Hibernate 3.3.2 and EhCache 2.6.6.
I have another server called "back" running MySQL and Terracotta Server 3.7.5 to handle the cache.
If I try to connect to "back" using my developing Glassfish 4 I get the same error that is getting "front".
But if I changed the Terracotta Server from "back" to my developing Terracotta Server it works great. The unique difference is both Glassfish and Terracotta Server are on the same machine.
Deploying application is fine but when I tried to load any URL on the app I get the following exception:
Code:
[2014-06-27T09:57:07.058+0200] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=44 _ThreadName=Thread-3] [timeMillis: 1403855827058] [levelValue: 800] [[
ERROR 27/06/2014 09:57:07.055 [jk-connector(2)]
find failed: net.sf.ehcache.CacheException: Uncaught exception in setPinned() - Pinning is not supported when local cache is disabled]]
[2014-06-27T09:57:07.081+0200] [glassfish 4.0] [SEVERE] [] [] [tid: _ThreadID=44 _ThreadName=Thread-4] [timeMillis: 1403855827081] [levelValue: 1000] [[
org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: Uncaught exception in setPinned() - Pinning is not supported when local cache is disabled
at net.sf.ehcache.hibernate.regions.EhcacheTransactionalDataRegion.put(EhcacheTransactionalDataRegion.java:151)
at net.sf.ehcache.hibernate.regions.EhcacheTransactionalDataRegion.put(EhcacheTransactionalDataRegion.java:126)
at net.sf.ehcache.hibernate.strategy.AbstractReadWriteEhcacheAccessStrategy.putFromLoad(AbstractReadWriteEhcacheAccessStrategy.java:93)
at net.sf.ehcache.hibernate.nonstop.NonstopAwareEntityRegionAccessStrategy.putFromLoad(NonstopAwareEntityRegionAccessStrategy.java:180)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:179)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
at org.hibernate.loader.Loader.doQuery(Loader.java:752)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2161)
at org.hibernate.loader.Loader.list(Loader.java:2121)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328)
(...)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:739)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:575)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:546)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:428)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:378)
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:744)
Caused by: net.sf.ehcache.CacheException: Uncaught exception in setPinned() - Pinning is not supported when local cache is disabled
at org.terracotta.modules.ehcache.store.ClusteredSafeStore.setPinned(ClusteredSafeStore.java:212)
at net.sf.ehcache.Cache.setPinned(Cache.java:4231)
at net.sf.ehcache.hibernate.regions.EhcacheTransactionalDataRegion.put(EhcacheTransactionalDataRegion.java:141)
... 70 more
The hibernate.cfg.xml configuration properties are:
Code:
<property name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</property>
<property name="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory</property>
<property name="net.sf.ehcache.configurationResourceName">ehcache-hibernate-2.6.6.xml</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.generate_statistics">false</property>
<property name="hibernate.cache.use_structured_entries">false</property>
The ehcache.xml file on the application is:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache-2.6.6.xsd"
updateCheck="false" monitoring="autodetect"
dynamicConfig="true" name="hibernate-cache">
<!-- Replicated caches between applications / ehcache servers -->
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual,
rmiUrls=//127.0.0.1:40001/common_objects_region|//127.0.0.1:40001/org.hibernate.cache.UpdateTimestampsCache|//127.0.0.1:40001/org.hibernate.cache.StandardQueryCache"/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostName=127.0.0.1, port=40001, socketTimeoutMillis=2000"/>
<terracottaConfig url="back:9510" />
<defaultCache
maxElementsInMemory="100"
maxElementsOnDisk="1000"
statistics="true"
eternal="false"
timeToIdleSeconds="43200"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LFU">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" listenFor="all" />
<terracotta clustered="true" consistency="eventual" localCacheEnabled="true" />
<persistence strategy="distributed" />
</defaultCache>
<cache
name="org.hibernate.cache.StandardQueryCache"
statistics="true"
maxElementsInMemory="5000"
maxElementsOnDisk="10000"
eternal="false"
timeToIdleSeconds="43200"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LFU">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" listenFor="all"/>
<terracotta clustered="true" consistency="eventual" localCacheEnabled="true" />
<persistence strategy="distributed" />
</cache>
<cache
name="org.hibernate.cache.UpdateTimestampsCache"
statistics="true"
maxElementsInMemory="5000"
maxElementsOnDisk="10000"
eternal="false"
timeToIdleSeconds="43200"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LFU">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" listenFor="all"/>
<terracotta clustered="true" consistency="eventual" localCacheEnabled="true" />
<persistence strategy="distributed" />
</cache>
<cache name="common_objects_region"
statistics="true"
maxElementsInMemory="100000"
maxElementsOnDisk="250000"
eternal="false"
timeToIdleSeconds="43200"
timeToLiveSeconds="86400"
memoryStoreEvictionPolicy="LFU">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" listenFor="all" />
<!-- <bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
properties="bootstrapAsynchronously=true,
maximumChunkSizeBytes=5000000"/>-->
<terracotta clustered="true" consistency="eventual" localCacheEnabled="true" />
<persistence strategy="distributed" />
</cache>
</ehcache>
And the tc-config.xml file on "back" is:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!--
All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
-->
<tc:tc-config xmlns:tc="http://www.terracotta.org/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-6.xsd">
<!-- Configuracion de high-availability -->
<tc-properties>
<property name="l1.healthcheck.l2.ping.enabled" value="true" />
<property name="l1.healthcheck.l2.ping.idletime" value="10000" />
<property name="l1.healthcheck.l2.ping.interval" value="2000" />
<property name="l1.healthcheck.l2.ping.probes" value="5" />
<property name="l1.healthcheck.l2.socketConnect" value="true" />
<property name="l1.healthcheck.l2.socketConnectTimeout" value="20" />
<property name="l1.healthcheck.l2.socketConnectCount" value="10" />
<!-- Client reconnection properties -->
<property name="l2.l1reconnect.enabled" value="true" />
<property name="l2.l1reconnect.timeout.millis" value="2000" />
<property name="l2.healthcheck.l1.ping.enabled" value="true" />
<property name="l2.healthcheck.l1.ping.idletime" value="10000" />
<property name="l2.healthcheck.l1.ping.interval" value="2000" />
<property name="l2.healthcheck.l1.ping.probes" value="5" />
<property name="l2.healthcheck.l1.socketConnect" value="true" />
<property name="l2.healthcheck.l1.socketConnectTimeout" value="20" />
<property name="l2.healthcheck.l1.socketConnectCount" value="10" />
</tc-properties>
<!-- Tell DSO where the Terracotta server can be found;
See
- Terracotta Configuration Guide and Reference
- About Terracotta Configuration Files
for additional information. -->
<servers>
<server host="back" name="cache">
<dso-port>9510</dso-port>
<jmx-port>9520</jmx-port>
<data>/opt/terracotta/server-data</data>
<logs>/var/log/terracotta/server-logs</logs>
<statistics>/opt/terracotta/server-statistics</statistics>
<dso>
<client-reconnect-window>15</client-reconnect-window>
<persistence>
<mode>permanent-store</mode>
</persistence>
<garbage-collection>
<enabled>true</enabled>
<verbose>false</verbose>
<interval>7200</interval> <!-- está en segundos -->
</garbage-collection>
</dso>
<l2-group-port bind="0.0.0.0">9530</l2-group-port>
<data-backup>/opt/terracotta/data-backup</data-backup>
<index>/opt/terracotta/server-data/index</index>
</server>
</servers>
</tc:tc-config>
I tried disabling Second Level Cache and enabling Query Cache:
Code:
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.cache.use_query_cache">true</property>
with these options the applications works fine, it only fails enabling Second Level Cache.
So many questions: What is it wrong in these config files? Do I need to have the Terracotta Server on same machine where is Glassfish installed? Am I missing some configuration options for this configuration?