Forum Stats

  • 3,854,668 Users
  • 2,264,397 Discussions
  • 7,905,749 Comments

Discussions

2 hibernate machines against one database machine

856371
856371 Member Posts: 15
edited Oct 5, 2011 10:58AM in Java Servlet
Hibernate version: 3.3.1.GA
I have 2 separate versions of the Jetty servlet engine running on 2 different physical machines, working against one mysql database server machine.
I get loads of exceptions on both machines saying "an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)".
Do you have to use a distributed cache setup here? How does that work? (Also, We're using ehcache version 3.3.1.GA.)

Answers

  • 856371
    856371 Member Posts: 15
    Do you have to buy Terracotta or is it easy to set up a distributed ehcache?
  • jtahlborn
    jtahlborn Member Posts: 2,040
    no, you don't have to use distributed caching assuming you are using transactions correctly. this setup should work just fine as is, so you most likely have problems in your code.
  • 856371
    856371 Member Posts: 15
    edited Aug 26, 2011 4:53AM
    I don't get any exceptions when I test it with 4 threads on my local machine. The server has 24 threads. I start them via JMS.
    But don't the two hibernate caches have to communicate so they are in synch? Transactions? Hibernate handles all of that for me.

    Edited by: 853368 on 2011-aug-26 01:52
  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy
    edited Oct 5, 2011 10:58AM
    853368 wrote:
    Transactions? Hibernate handles all of that for me.
    WRONG. Hibernate (and JTA) HELPS you to do it, but you are still the captain on the ship and should rightfully want to keep it that way too. If you don't want to at least think about it then you are going to fall flat on your face eventually and usually in a production environment with people yelling at you that there is a deadline. Personal experience speaking here :(

    Don't offload responsibility to tools, use the tools to make your job easier.
This discussion has been closed.