This content has been marked as final.
Show 3 replies
-
1. Re: JBoss Hibernate
marc_mulzer Aug 10, 2004 2:48 AM (in response to dstreev)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 Aug 12, 2004 7:43 AM (in response to dstreev)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 Aug 14, 2004 7:05 AM (in response to dstreev)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.