Hello Terracotta Gurus,
Our app stores detached Hibernate entities (some of them use lazy loading) as HTTP session attributes, and uses the OSIV (Open Session in View) pattern. When using Tomcat clustering, lazy loading works correctly with hydrated entities after session failover.
When I disable Tomcat clustering and try implementing Terracotta Web Sessions (open source version) following the Express installation guide, session replication seems to work, but lazy loading operations start throwing:
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
If I comment out the TerracottaTomcat70xSessionValve in Context.xml, and enable Tomcat clustering, everything works as expected again after a forced failover.
Does the Web Sessions product support this use case? Or would we have to use eager loading if we wanted to try Web Sessions?
I'm sorry, but I couldn't find the answers in the Terracotta documentation or on the web.
tc-config.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<servers secure="false" xmlns:tc="http://www.terracotta.org/config" xmlns:con="http://www.terracotta.org/config" xmlns="">
<server bind="0.0.0.0" host="127.0.0.1" name="node-1">
<data>C:/libs/terracotta/server/node1/data</data>
<logs>C:/libs/terracotta/server/node1/logs</logs>
<statistics>C:/libs/terracotta/server/statistics</statistics>
<dso-port bind="0.0.0.0">9510</dso-port>
<jmx-port bind="0.0.0.0">9520</jmx-port>
<l2-group-port bind="0.0.0.0">9530</l2-group-port>
<data-backup>C:/libs/terracotta/server/node1/data-backup</data-backup>
<index>C:/libs/terracotta/server/node1/index</index>
<dso>
<client-reconnect-window>120</client-reconnect-window>
<persistence>
<mode>permanent-store</mode>
</persistence>
<garbage-collection>
<enabled>true</enabled>
<verbose>false</verbose>
<interval>3600</interval>
</garbage-collection>
</dso>
</server>
<server bind="0.0.0.0" host="127.0.0.1" name="node-2">
<data>C:/libs/terracotta/server/node2/data</data>
<logs>C:/libs/terracotta/server/node2/logs</logs>
<statistics>C:/libs/terracotta/server/statistics</statistics>
<dso-port bind="0.0.0.0">9511</dso-port>
<jmx-port bind="0.0.0.0">9521</jmx-port>
<l2-group-port bind="0.0.0.0">9531</l2-group-port>
<data-backup>C:/libs/terracotta/server/node2/data-backup</data-backup>
<index>C:/libs/terracotta/server/node2/index</index>
<dso>
<client-reconnect-window>120</client-reconnect-window>
<persistence>
<mode>permanent-store</mode>
</persistence>
<garbage-collection>
<enabled>true</enabled>
<verbose>false</verbose>
<interval>3600</interval>
</garbage-collection>
</dso>
</server>
<mirror-groups>
<mirror-group>
<members>
<member>node-1</member>
<member>node-2</member>
</members>
</mirror-group>
</mirror-groups>
<ha>
<mode>networked-active-passive</mode>
<networked-active-passive>
<election-time>5</election-time>
</networked-active-passive>
</ha>
</servers>
<system xmlns:tc="http://www.terracotta.org/config" xmlns:con="http://www.terracotta.org/config" xmlns="">
<configuration-model>production</configuration-model>
</system>
<clients xmlns:tc="http://www.terracotta.org/config" xmlns:con="http://www.terracotta.org/config" xmlns="">
<logs>C:/libs/terracotta/client/logs</logs>
</clients>
</tc:tc-config>
Environment:
Terracotta Server 3.7.3 (also tried 3.7.4) - ehCache 2.6.3, Web Sessions
Hibernate 3.2.7
Spring 2.5.5
Spring TC Server (Tomcat 7.0.25)
Thanks so much for your time.