Spring Framework
  1. Spring Framework
  2. SPR-7440

Tomcat 7.0.2 with web.xml version=3.0" & Hibernate 3.6.beta2: Cannot persist objects

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      When I use Hibernate to persist an object of a class which inherits from an abstract (entity) class: nothing happens if version=3.0" inside web.xml

      If I change version="2.5" then everything works fine. I'll attach a testcase. The war file is missing all Spring JARs and hibernate3.jar which can be downloaded at http://sourceforge.net/projects/hibernate/files/hibernate3/3.6.0.Beta2

      When you enable logging for Hibernate and set org.hibernate.SQL to level DEBUG, then you'll see that there is a SQL INSERT statement when web.xml has version="2.5", but there is no INSERT statement when changing to version="3.0".

      The issue described at https://jira.springframework.org/browse/SPR-7350 is gone. This is a new one.

        Issue Links

          Activity

          Hide
          Costin Leau added a comment -

          Scott, do you have a basic sample application that exhibits this problem that you attach to this issue or upload somewhere? I tried reproducing the problem before (as you can tell from the comments) to no avail.

          Show
          Costin Leau added a comment - Scott, do you have a basic sample application that exhibits this problem that you attach to this issue or upload somewhere? I tried reproducing the problem before (as you can tell from the comments) to no avail.
          Hide
          Scott Van Wart added a comment -

          Absolutely, it's the only reason I was able to comment on this. Apparently in my excitement I forgot to include the link ("...demo project someone was kind enough to publish a few years ago") .

          http://fadishei.wordpress.com/2010/01/05/spring-load-time-weaving-on-tomcat-does-it-really-work/

          I only had to rebind the JRE and Tomcat containers through Eclipse, and the example worked. I updated to Spring 3.1 and the example still worked. I changed 'version="2.5"' to 'version="3.0"' and it broke.

          Show
          Scott Van Wart added a comment - Absolutely, it's the only reason I was able to comment on this. Apparently in my excitement I forgot to include the link ("...demo project someone was kind enough to publish a few years ago") . http://fadishei.wordpress.com/2010/01/05/spring-load-time-weaving-on-tomcat-does-it-really-work/ I only had to rebind the JRE and Tomcat containers through Eclipse, and the example worked. I updated to Spring 3.1 and the example still worked. I changed 'version="2.5"' to 'version="3.0"' and it broke.
          Hide
          Costin Leau added a comment -

          Hi Scott,

          I've been able to reproduce the problem and find the culprit. Basically with web.xml 3.0+ as long as there's a HandleType registered (Spring MVC does register one) Tomcat 7 will load all classes under WEB-INF/classes (the jars as well I think). This happens before the app is started, as part of the web app initialization.
          So the classes (including your own) are loaded before AspectJ or Spring (and its LTW) are configured and can weave bytecode. There's frankly not much we can do and I'm taking offline with some of the Tomcat team to try to alleviate this problem.
          For now you need to stick either with web.xml 2.5 or add metadata-complete to your web.xml. Hopefully this won't be needed in long run - I'll keep you posted.

          Show
          Costin Leau added a comment - Hi Scott, I've been able to reproduce the problem and find the culprit. Basically with web.xml 3.0+ as long as there's a HandleType registered (Spring MVC does register one) Tomcat 7 will load all classes under WEB-INF/classes (the jars as well I think). This happens before the app is started, as part of the web app initialization. So the classes (including your own) are loaded before AspectJ or Spring (and its LTW) are configured and can weave bytecode. There's frankly not much we can do and I'm taking offline with some of the Tomcat team to try to alleviate this problem. For now you need to stick either with web.xml 2.5 or add metadata-complete to your web.xml. Hopefully this won't be needed in long run - I'll keep you posted.
          Hide
          Costin Leau added a comment -
          Show
          Costin Leau added a comment - Tomcat issue raised here: https://issues.apache.org/bugzilla/show_bug.cgi?id=52549
          Hide
          Adib Saikali added a comment -

          Hi Costin,

          I have spent the past week trying to figure out why Spring LTW does not work with Tomcat 7.0.25, finally I know why. I think it would be great to put a note in the LTW setup guide in the manual to warn people about the issue with Tomcat LTW.

          Show
          Adib Saikali added a comment - Hi Costin, I have spent the past week trying to figure out why Spring LTW does not work with Tomcat 7.0.25, finally I know why. I think it would be great to put a note in the LTW setup guide in the manual to warn people about the issue with Tomcat LTW.

            People

            • Assignee:
              Costin Leau
              Reporter:
              Juergen Zimmermann
              Last updater:
              Chris Beams
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                2 years, 10 weeks, 4 days ago