11 Replies Latest reply on Jul 27, 2005 10:12 AM by lol91

    Jboss4.0.2 and Hibernate3 problem

    luca.mandorlo

      Hi,

      I've this problem using hibernate3 and jboss.
      When I try to obtain the SessionFactory object always I see a nullPointerExcetpion :(

      When jboss start, then name of my SessionFactory seems to be right :

      SessionFactory successfully built and bound into JNDI [java:/hibernate/SpikeSessionFactory]

      How do I retrive this object? please help me!!!!

      Regards
      Luca Mandorlo

        • 1. Re: Jboss4.0.2 and Hibernate3 problem

          If you look higher up in your logs, you'll probably find the line:

          [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured

          This seems to be something new to 4.0.2/Hib3, but JIRA's down at the moment so I can't look to see if there are any bug reports out.

          Derek

          • 2. Re: Jboss4.0.2 and Hibernate3 problem

            I've been looking at the code for the JBoss Hibernate MBean and I don't see anything glaring. I'm wondering if maybe for some reason the Tomcat InitialContext is different from the JBoss InitialContext. If that were the case then you wouldn't be able to look up things in Tomcat that had been registered in JBoss. I'm going to explore this a little more.

            Derek

            • 3. Re: Jboss4.0.2 and Hibernate3 problem (closer)

              OK, this is starting to look like a stupid configuration issue. Please, someone with more experience step in. Here's what I've done so far:

              1. I made a single JSP called "test.jsp" that I placed in a directory called "test.war" in my deployment dir. When I run it, I get this:

              Context = javax.naming.InitialContext@171c0b8
              Factory1 = org.hibernate.impl.SessionFactoryImpl@1364534
              Factory2 = org.hibernate.impl.SessionFactoryImpl@1524a9d

              2. I copied test.jsp into my build directory and packaged into the war that I'm getting the issue on. Here's the output:

              Context = javax.naming.InitialContext@c20e9
              Factory1 = null
              Factory2 = null

              So, for some reason, the same JSP, when deployed without a web.xml, works fine. But when deployed with my web.xml, it blows up. Do I need to define resource-ref tags for these?

              Thanks,

              Derek

              • 4. Re: Jboss4.0.2 and Hibernate3 problem

                OK, I think I'm on the right track. I've traced the error messages:

                2005-05-27 18:59:57,104 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: hibernate/LocMasterFactory
                2005-05-27 18:59:57,104 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=ff808081042091fb01042095d4c20002
                2005-05-27 18:59:57,104 WARN [org.hibernate.impl.SessionFactoryObjectFactory] Not found: ff808081042091fb01042095d4c20002
                2005-05-27 19:05:29,763 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] {}


                and it looks like JBoss is deferring to the SessionFactoryObjectFactory to keep track of the singleton. This is looking a lot like a classloader issue, since the FastHashMap used by SessionFactoryObjectFactory is marked "final static". It appears that my two web apps are just getting different instances of that for some reason, because the last line of my log snippet is where SessionFactoryObjectFactory prints out the contents of NAMED_INSTANCES, and it's definitely empty :(. If no one chimes in over the weekend I'll open a JIRA case on it.

                Derek

                • 5. Re: Jboss4.0.2 and Hibernate3 problem

                  A lot of people are posting about this issue. I've opened a JIRA case:

                  http://jira.jboss.com/jira/browse/JBAS-1858

                  Derek

                  • 6. Re: Jboss4.0.2 and Hibernate3 problem
                    • 7. Re: Jboss4.0.2 and Hibernate3 problem

                      Removing all of the hibernate classes + dependencies solved this.

                      • 8. Re: Jboss4.0.2 and Hibernate3 problem
                        qiuwg

                         

                        "d-rock" wrote:
                        Removing all of the hibernate classes + dependencies solved this.



                        Apparently, I didn't have any hibernate jars in my war file, but I still have the same problem. I am using the Struts. And also I did one testing, once I directly use servlet or JSP page, it works fine, ...

                        Any idea about this? Does JBoss 4.0.1SP have this issue as well? If not, I might switch to the older version JBoss.

                        Bill

                        • 9. Re: Jboss4.0.2 and Hibernate3 problem
                          qiuwg

                           

                          "qiuwg" wrote:
                          "d-rock" wrote:
                          Removing all of the hibernate classes + dependencies solved this.



                          Apparently, I didn't have any hibernate jars in my war file, but I still have the same problem. I am using the Struts. And also I did one testing, once I directly use servlet or JSP page, it works fine, ...

                          Any idea about this? Does JBoss 4.0.1SP have this issue as well? If not, I might switch to the older version JBoss.

                          Bill


                          Please ignore my last post, I have resolved my problem, bind Hibernate 3 with JBoss JTA transaction works very well. No problem at all.

                          • 10. Re: Jboss4.0.2 and Hibernate3 problem
                            rjkimme

                            What does your configuration file look like in order to use the JTA with hib3 in Jboss4 with JNDI? We can't get our's figured right.

                            • 11. Re: Jboss4.0.2 and Hibernate3 problem
                              lol91

                              Hi,

                              I have the same problem, and I haven't hibernate jars in my war file ....

                              qiuwg can you tell me how did you have resolved the problem ??

                              Thanks a lot !