Announcement Announcement Module
Collapse
No announcement yet.
ObjectNotFoundException on migration from spring 1.2.8 to 2.0.2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ObjectNotFoundException on migration from spring 1.2.8 to 2.0.2

    Hi. My web application works fine with spring 1.2.8 and hibernate 3.1.3.
    When I upgrade to spring 2.0.2 and hibernate 3.2.1.ga (just update jars with maven2), I got ObjectNotFoundException when i load profile object after update it.
    Profile class has one-to-many relationship with Permission class. The database is updated right, but hibernate throws exception about permission of the profile when i try to load profile from database!
    What is wrong? I look forward your answer and thanks in advance!

    obs. im using ehcache

  • #2
    Its hard to know what the problem is without seeing the stacktrace.

    Comment


    • #3
      Hello,

      Follows the stacktrace and pojos and hbms.

      Comment


      • #4
        I would have thought this is related to Hibernate rather than Spring. The exception says it can't find a specific item in the database e.g. Permission 735. I know it might be a stupid question, but does this item actually exist?

        Comment


        • #5
          When hibernate update profile object, old permissions are deleted and new permissions are created at the database. It seems cache problem, because when i try to load the profile again, hibernate try to load old permissions, thats the error ObjectNotFoundException.
          When i restart the application, updated profile object references new permissions and hibernate loads ok!
          I didnt change any code, just hibernate and springframework jars!
          Any suggestions?

          Comment


          • #6
            I would first turn caching off, just to take that out of the equation. Is it possible to see the code that is causing the error? It would be good if you could give me a step-by-step description of how you get the error, or a test case.

            Comment


            • #7
              I turn caching off and it works! Well, now we know where the problem is with caching!

              Let me post a stey-by-step description when the cache is on:

              1 - using the web app (myfaces + spring + hibernate), I access the page to update a profile bean. I set new permissions and submit the page. It works ok and the profile bean has new permissions (profile table and permission table are updated ok).

              2 - i access another page to list profile. the page reloads all profiles, including the updated profile. Here, there is no problem because the permissions are not loaded yet.

              3 - when i try to access the profile view page, the error occurs!

              Im posting the code of remaining classes and spring transaction configuration. I cut the classes and xml because upload size file limit, but the method name are preserved!

              Is there any new cache parameter to set or any new behaviour?

              Thanks in advance!

              Comment


              • #8
                The problem is with hibernate 3.2.1ga !!!
                I tested with hibernate 3.2.0ga and hibernate 3.2.2 ga (recently released) and it works!
                There was no problem with spring! I could upgrade fine!
                Thanks in advance!

                Comment


                • #9
                  Mmmmm interesting. Did you find a bug report that pointed you to this solution, or did you just try it?

                  Comment


                  • #10
                    Just some tries:
                    I tried to upgrade spring 1.2.8 to 2.0.2 first. It worked!
                    After, I tried to upgrade hibernate 3.1.3 to 3.2.0.ga and it worked too! When I tried to upgrade to 3.2.1.ga, it failed. Today, when i visited hibernate home page, i saw 3.2.2.ga release (not at maven repository yet!). I downloaded it, tested and it worked!

                    Comment


                    • #11
                      Oh well, if all else fails download the latest version! , glad you got it working anyway.

                      Comment


                      • #12
                        Ive just updated to hibernate 3.2.2.ga and it works!!!

                        Comment


                        • #13
                          I'm running into the same issue with Hibernate 3.2.2ga. It looks like the HibernateTemplate.load(Class, Serializable) method is returning a Hibernate proxied empty entity (all the properties are null). When my code attempts to use the seemingly valid entity I get a org.hibernate.ObjectNotFoundException...

                          Comment


                          • #14
                            The last user who had this problem seemed to resolve it with an upgrade, obviously this hasn't working in your case. I would suggest writing a simple TestCase that highlights the problem. If you can then post the code and applicationContext.xml people can have a look and try to help. Otherwise, it's really hard to know what's wrong.

                            Comment

                            Working...
                            X