3 Replies Latest reply on Aug 14, 2004 7:05 AM by david.wade

    JBoss Hibernate

      I followed the wiki page for JBoss-Hibernate and download the additional files as specified by the document. After getting it all configured and getting a successful deployment, when I use a service that uses Hibernate for persistence I get the following:

      21:41:10,341 INFO [SessionContext] Generating Hibernate session for scoped bind
      21:41:10,902 INFO [SessionContext] Generating Hibernate session for scoped bind
      21:41:10,902 ERROR [LogInterceptor] RuntimeException:
      java.lang.NullPointerException
      at org.jboss.hibernate.session.SessionContext.registerSynch(SessionContext.java:244)
      at org.jboss.hibernate.session.SessionContext.openSession(SessionContext.java:232)
      at org.jboss.hibernate.session.SessionContext.prepareCall(SessionContext.java:117)
      at org.jboss.hibernate.session.EjbInterceptor.invoke(EjbInterceptor.java:67)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstance
      Interceptor.java:72)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:341)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.
      java:122)
      at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331
      )


      Can anyone help with this? Not really what version of the source was used to generate the jboss-hibernate.jar file in the wiki page, so I'm not sure if I missed something or if there still might be a problem with the jboss-hibernate code.

      Any clues and/or help would be much appreciated.

        • 1. Re: JBoss Hibernate
          marc_mulzer

          I did everything as described, including the update of the jar, the har deploys fine. But then I get a different error:

          java.lang.IllegalArgumentException: Unknown session scope for jndi name [java:/hibernate/SessionFactory]

          Also, when I verify my jboss.xml, then the

          <interceptor service="..." scope="..."/>
          does not validate against jboss_3_2.dtd.
          ------------------------------------------------------------------------

          Here my jboss.xml file:

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
          
          <jboss>
           <enterprise-beans>
           <session>
           <ejb-name>Event</ejb-name>
           <jndi-name>ejb/Event</jndi-name>
           </session>
           </enterprise-beans>
          
           <container-configurations>
           <container-configuration extends="Standard Stateless SessionBean">
           <container-name>Hibernate Stateless SessionBean</container-name>
           <call-logging>true</call-logging>
           <container-interceptors>
           <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
           <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
           <interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
           <!-- CMT -->
           <interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
           <interceptor transaction="Container" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
           <interceptor transaction="Container">org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor</interceptor>
           <!-- BMT not feasible using Hibernate interceptor with 'transaction' scope!!!! -->
           <!-- Notice that the service name is the same as that used to define the MBean -->
           <interceptor service="jboss.har:service=Hibernate" scope="transaction">org.jboss.hibernate.session.EjbInterceptor</interceptor>
           </container-interceptors>
           </container-configuration>
          </container-configurations>
          </jboss>

          ________________________________________________
          And here my hibernate-service.xml:

          <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
           <attribute name="DatasourceName">java:/DefaultDS</attribute>
           <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
           <attribute name="Dialect">net.sf.hibernate.dialect.HSQLDialect</attribute>
           <attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
           <attribute name="Hbm2ddlAuto">create-drop</attribute>
          </mbean>

          ____________________________________________________

          Here my ejb-jar.xml:

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
          
          <ejb-jar >
          
           <description>[CDATA[No Description.]]</description>
           <display-name>Generated by XDoclet</display-name>
          
           <enterprise-beans>
          
           <!-- Session Beans -->
           <session >
           <description>[CDATA[Description for Event]]</description>
           <display-name>Name for Event</display-name>
          
           <ejb-name>Event</ejb-name>
          
           <home>com.yankeezulu.flightlog.interfaces.EventHome</home>
           <remote>com.yankeezulu.flightlog.interfaces.Event</remote>
           <ejb-class>com.yankeezulu.flightlog.ejb.EventBean</ejb-class>
           <session-type>Stateless</session-type>
           <transaction-type>Container</transaction-type>
          
           </session>
          
           </enterprise-beans>
          
           <assembly-descriptor >
           <!-- transactions -->
           <container-transaction >
           <method >
           <ejb-name>Event</ejb-name>
           <method-name>*</method-name>
           </method>
           <trans-attribute>Required</trans-attribute>
           </container-transaction>
          
           <!-- finder transactions -->
           </assembly-descriptor>
          
          </ejb-jar>


          __________________________________________________________
          And here the business method in my session EJB:

          /**
           * Business method
           * @ejb.interface-method view-type = "remote"
           */
           public void createEvent(String title, Date date) {
          
           session = org.jboss.hibernate.session.SessionContext.getSession("java:/hibernate/SessionFactory");
           try {
          
           Transaction tx = session.beginTransaction();
           EventVO event = new EventVO();
           event.setTitle(title);
           event.setDate(date);
           session.save(event);
           tx.commit();
           session.close();
           }
           catch (HibernateException he){
           System.err.println(he.getMessage());
           }
           }


          How did you configure it? Can you send me your ear file? marc_mulzer@yahoo.com

          • 2. Re: JBoss Hibernate
            aloubyansky

            We decided to discuss Hibernate integration issues here
            http://forum.hibernate.org/viewforum.php?f=8&sid=74a08b0457b45bcfe449aea84187792c

            Please, post there. Thanks.

            • 3. Re: JBoss Hibernate
              david.wade

              You almost got it right.

              But you must reference the container configuration from your ejb in the jboss.xml.

              <jboss>
              
               <enterprise-beans>
              
               <session>
               <ejb-name>MyFacadeManager</ejb-name>
               <local-jndi-name>MyFacadeManagerLocal</local-jndi-name>
               <configuration-name>Hibernate Stateless SessionBean</configuration-name>
              
               <method-attributes />
               </session>
              
               ....
              


              I actually added that container configuration to standardjboss.xml to save repeating it in every ejb jar.