Member Menu
 
 Monthly JBoss newsletter:
 
Hibernate Books
CaveatEmptor

Using Hibernate with JBoss

NOTE THAT THIS IS A PAGE MAINTAINED BY HIBERNATE USERS, NOT JBOSS INC!

Please read the Hibernate reference documentation and JBoss AS documentation before doing anything listed here!


This guide is intended for developers who use JBoss as the target platform for their J2EE applications.

The first method used here is derived from Konstantin Pribluda's Hibernate demo package in the forum - http://sourceforge.net/forum/message.php?msg_id=1801820 - and can be used on JBoss 3.0.x and 3.2 with Hibernate 1.2.2, and without XDoclet (which most developers use though).

The second discussion outlines the use of the service with JBoss 3.2.X, Hibernate 2.1 and XDoclet.

Steps to deploy a Hibernate 1.X or 2.0 service in JBoss

1. Prepare your JDBC DataSource for use with Hibernate.

Please refer to JBoss docs, or the examples included in the JBoss distribution.

2. Copy the necessary jars to ${JBOSS_HOME}/server/default/lib.

The following jars are required (maybe redundant?), which can be found in ${HIBERNATE_HOME}/lib:

  • cglib.jar
  • commons-collections.jar
  • commons-logging.jar
  • commons-lang.jar
  • jcs.jar
  • odmg.jar
  • and of course, hiberna

Due to some mysterious ClassLoader problems in JBoss, these jars have to be copied to ${JBOSS_HOME}/server/default/lib. And in addition, you may need to use the latest versions of the commons-*.jar if JBoss failed to start up after copying (the commons-*.jar in Hibernate's distribution seems to cause conflict with JBoss itself... maybe it means not all the commons-*.jar are necessary? :\).

3. Prepare the directory structure of the service archive.

The Hibernate service will be deployed as a service archive (SAR), which will include all the entity objects, mapping XML files, and the JBoss service XML file itself.

Prepare a directory structure like this:

org/mytest/objects/MasterAccount.class
org/mytest/objects/SubAccount.class
org/mytest/objects/Password.class
mappings/MasterAccount.hbm.xml
mappings/SubAccount.hbm.xml
mappings/Password.hbm.xml
META-INF/

4. Prepare the service XML file.

Fire up your favorite text editor and type in the Hibernate service MBean configuration, like the one below:

<server>
<mbean code="cirrus.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,
name=HibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<!-- Make it deploy ONLY after D.hbm.xml,  XXX SOMETHING IS MISSING HERE, PLEASE FIX !! XXX
mappings/SubAccount.hbm.xml,
mappings/Password.hbm.xml</attribute>
<attribute name="JndiName">java:/hibernate/HibernateFactory</attribute>
<attribute name="Datasource">java:/jdbc/DataSource</attribute>
<attribute name="Dialect">cirrus.hibernate.sql.MySQLDialect</attribute>
<attribute name="TransactionStrategy">cirrus.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">
cirrus.hibernate.transaction.JBossTransactionManagerLookup
</attribute>
<attribute name="UseOuterJoin">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">java:/UserTransaction</attribute>
</mbean>
</server>

The following classpaths will work with hibernate 2.x

<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,
name=HibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
<!-- Make it deploy ONLY after DataSource had been started -->
<attribute name="MapResources">mappings/Attribute.hbm.xml</attribute>
<attribute name="JndiName">java:/hibernate/HibernateFactory</attribute>
<attribute name="Datasource">java:/MySqlDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="UseOuterJoin">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
</mbean>
</server>

Of course, you will want to change the attributes above.

  • MapResources: a list of the mapping files used, separated by commas.
  • JndiName: the JNDI bound name of the Hibernate service.
  • Datasource: the JDBC data source this Hibernate service will use.
  • Dialect: the SQL dialect the Hibernate service will use. please refer to http://hibernate.bluemars.net/hib_docs/reference/html/session-configuration.html to see the list of available dialects.
  • UseOuterJoin: whether Hibernate should use outer join fetching.
  • ShowSql: prints out the SQL (actually a PreparedStatement) generated by Hibernate when set to true.

Save this file as jboss-service.xml and put it under META-INF of your directory structure.

5. Pack the directory up as a JAR with .sar as extension.

Issue a jar command to jar the above contents to a service archive, which ends with .sar. It is not required to use sar as its extension, just for some sort of conformance... :)

You may also want to do this job with an Ant target.

6. Copy the archive to ${JBOSS_HOME}/server/default/deploy.

You will then see the Hibernate service initialized. You may need to check with your mappings and/or jboss-service.xml in case any exception is thrown.

Using the JBoss MBean with Hibernate 2.1, JBoss 3.2.X and XDoclet

1. Prepare your JDBC DataSource for use with Hibernate.

Please refer to JBoss docs, or the examples included in the JBoss distribution.

2. Set up for XDoclet

See the excellent tutorial http://www.hibernate.org/72.html

The only differences are:

Use XDoclet 1.2beta4. Then you don't have to do "Calling XDoclet from your Ant build script" Step 4 because beta4 has been fixed for Hibernate 2.

Your hibernatedoclet Ant task should look as follows:

<!-- =================================================================== -->
<!-- generates the hibernate HBM.XML files and SAR descriptor -->
<!-- =================================================================== -->

<target name="generate-Hibernate"
description="Generates Hibernate class descriptor files."
depends="compile">

<!-- copy additional resources for the Hibernate XDoclet task to the mergedir -->

<copy todir="${build.resources}/sar/hibernate">
<fileset dir="${src.dir}">
<include name="**/hibernate/hibernate-properties-*.xml"/>
</fileset>
<fileset dir="${resources}/sar/hibernate">
<include name="jboss-service-custom.xdt"/>
</fileset>
</copy>

<!-- Execute the hibernatedoclet task -->
<hibernatedoclet
destdir="${build.resources}/sar/hibernate"
excludedtags="@version,@author,@todo,@see,@desc"
addedtags="@xdoclet-generated at ${TODAY}@copyright yourCompany,@author yourCompany,@version ${version}"
force="${xdoclet.force}"
mergedir="${build.resources}/sar/hibernate"
verbose="false">

<fileset dir="${src.dir}">
<include name="**/hibernate/*.java"/>
</fileset>

<hibernate version="2.0"/>

<jbossservice
destdir="${build.resources}/sar/hibernate"
serviceName="Hibernate"
jndiName="${hibernate.jndi.name}"
dataSource="${hibernate.datasource.name}"
dialect="${hibernate.dialect}"
useOuterJoin="true"
transactionManagerStrategy="net.sf.hibernate.transaction.JBossTransactionManagerLookup"
transactionStrategy="net.sf.hibernate.transaction.JTATransactionFactory"
userTransactionName="UserTransaction"
/>

</hibernatedoclet>
</target>

Running this target gets you all the hbm.xml s and a jboss-service.xml in the destdir, as follows:

jboss-service.xml
com/yourcompany/package1/YourClass1.hbm.xml
com/yourcompany/package1/YourClass2.hbm.xml
com/yourcompany/package1/YourClass3.hbm.xml
com/yourcompany/package1/subpackage2/YourClass4.hbm.xml
...

The jboss-service.xml looks like:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>

<!-- Generated file - Do not edit! -->

<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=Hibernate">
<depends>jboss.jca:service=RARDeployer</depends>
<attribute name="MapResources">com/yourcompany/package1/YourClass1.hbm.xml,
com/yourcompany/package1/YourClass2.hbm.xml,
com/yourcompany/package1/YourClass3.hbm.xml,
com/yourcompany/package1/subpackage1/YourClass4.hbm.xml
</attribute>
<attribute name="JndiName">java:/HibernateFactory</attribute>
<attribute name="Datasource">java:/myDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.PostgreSQLDialect</attribute>
<attribute name="UseOuterJoin">true</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
</mbean>

</server>

3. Package the Hibernate SAR

Again, an Ant task:


<!-- =================================================================== -->
<!-- Hibernate SAR build -->
<!-- =================================================================== -->

<target depends="generate-Hibernate" name="hibernate-sar">

<jar destfile="${build.lib}/hibernateStartup.sar">

<!-- Get the generated hbm.xml files -->
<fileset dir="${build.resources}/sar/hibernate">
<include name="**/*.hbm.xml"/>
</fileset>

<!--
<fileset dir="${lib.dir}">
<include name="cglib2.jar"/>
<include name="commons-collections.jar"/>
<include name="commons-logging.jar"/>
<include name="dom4j.jar"/>
<include name="hibernate2.jar"/>
<include name="odmg.jar"/>
<include name="ehcache.jar"/>
</fileset>
-->
<metainf dir="${build.resources}/sar/hibernate">
<include name="jboss-service.xml"/>
</metainf>
</jar>

<antcall target="hibernate-schemaexport" />

</target>

A couple of things to note:

  • I do not have my Hibernate Java class files in the SAR. In my case, the class files are used by the rest of my code including a WAR, so I have them in a separate jar that is in my EAR classpath. In my experience with JBoss, code in a WAR cannot find classes in a SAR.
  • See the next section for an explanation of why the fileset with the jars is commented out.

4. Hibernate Support jars and Final packaging

As of Hibernate 2.1 rc1, this is the set of jars from the Hibernate distribution that you need:

hibernate2.jar
cglib2.jar
commons-collections.jar
commons-logging.jar
dom4j.jar
odmg.jar
ehcache.jar

All other jars that Hibernate needs are supplied by the base JBoss default deployment.

As of 2.1 rc1, ehcache is the required and the only caching scheme you can use. The final release of 2.1 will allow you to change the caching scheme via:

<attribute name="CacheProvider">net.sf.ehcache.hibernate.Provider</attribute>

in the jboss-service.xml. See below for the implications for using XDoclet.

Each caching scheme requires a different set of supporting jars. Check out lib/libs-readme.txt in the Hibernate distribution about the requirements of the different schemes.

In the build of the SAR above, the fileset tag with the jars is commented out because I am still experimenting with the packaging. Currently, those jars go in my EAR and are referred to in my EAR application.xml (see below).

If you want to deploy the Hibernate SAR on its own outside of an EAR, including the above Hibernate related JARs in the SAR should work. Dropping this SAR into the server/default/deploy directory does a hot deploy.

In an EAR, I have:

hibernateStartup.sar (as built above)
myHibernateClasses.jar
hibernate2.jar
cglib2.jar
commons-collections.jar
commons-logging.jar
dom4j.jar
odmg.jar
ehcache.jar
meta-inf/application.xml
meta-inf/jboss-app.xml

My application.xml looks like:


<application>
<display-name>Company server</display-name>
<description>Company server</description>

<!-- uses session beans to get to Hibernate POJOs -->

<module>
<web>
<web-uri>CompanyUI.war</web-uri>
<context-root>/company</context-root>
</web>
</module>

<!-- Just session beans accessing hibernate -->

<module>
<ejb>companyEJB.jar</ejb>
</module>

<module>
<java>myHibernateClasses.jar</java>
</module>

<module>
<java>hibernate2.jar</java>
</module>

<module>
<java>cglib2.jar</java>
</module>

<module>
<java>commons-logging.jar</java>
</module>

<module>
<java>commons-collections.jar</java>
</module>


<module>
<java>dom4j.jar</java>
</module>

<module>
<java>odmg.jar</java>
</module>

<module>
<java>ehcache.jar</java>
</module>

</application>

My jboss-app.xml looks like:


<?xml version="1.0"?>

<jboss-app>
<loader-repository>company:loader=company.ear</loader-repository>

<module>
<service>hibernateStartup.sar</service>
</module>

</jboss-app>

5. Additional attributes for the SAR jboss-service.xml

  • MapResources
  • JndiName
  • UserName
  • Password
  • Datasource
  • Dialect
  • UseOuterJoin
  • ShowSql
  • UserTransactionName
  • TransactionStrategy
  • TransactionManagerLookupStrategy

UserTransactionName, TransactionStrategy and TransactionManagerLookupStrategy appear to be required under JBoss if you are using Hibernate transactions.

Based on looking at the code coming out for 2.1 final (but not 2.1 rc1, which still has only the original set of attributes from Hibernate 2), the following new attributes can appear in the jboss-service.xml:

  • MaxFetchDepth
  • JdbcFetchSize
  • CacheProvider
  • UseQueryCache
  • QuerySubstitutions
  • DefaultSchema

See the documentation elsewhere about hibernate.properties and hibernate.cfg.xml for details.

6. Generating a complete jboss-service.xml from XDoclet for Hibernate 2.1

If you check back in the section in the hibernatedoclet Ant task, you will see that the jbossservice tag has a limited set of attributes. With Hibernate 2.1, the set of attributes that can be given in the jboss-service.xml for the MBean is expanded, and there will be no out of the box method for setting them via the hibernatedoclet task in XDoclet 1.2beta4.

All is not lost! You can include a merge point for XDoclet, which is a file that is included as is by XDoclet into the jboss-service.xml.

In the mergedir directory specified in the hibernatedoclet task, put a file named jboss-service-custom.xdt. This should contain the text you want to include into the jboss-service.xml that you can't with hibernatedoclet, ala:

<depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
<attribute name="CacheProvider">net.sf.ehcache.hibernate.Provider</attribute>

There is a bug in XDoclet 1.2beta3 and 1.2beta4, which means the contents of jboss-service-custom.xdt are included in the wrong place. See the comments below for the fix.

Commentary

Question: What are the advantages to this as opposed to getting a pooled connection and relying on JBoss for transaction handling?

Using Object-Relation-Mapping make application layer seperated from the Database access layer. Compare with the tradition Object-Storage in EJB, it allow better control on the data in the relational database. Also connection pooling could be done inside Hibernate.

Question: Why will I want to use this method to integrate Hibernate service into JBoss?

Of course, you can use the traditional "hibernate.cfg.xml" or "hibernate.properties" method which will also work seamlessly in JBoss. However, using the JMX integration method, the Hibernate service is deployed as a JMX MBean, which you can modify its properties through the JMX console.

That is, you can change the JDBC data source the service uses, include/ exclude mapping files included in the .sar, enable/ disable SQL verbose to the console, etc. while the server is running.

This was (supposed to be) why the Hibernate JBoss MBean was written.

Not using the MBean

If you are going to try to get JBoss working without using the service, the libraries listed above are a good place to start. The classloader errors that JBoss gives are not necessarily for the actual class that is missing, JBoss merely reports the top-level class it was trying to load if there is a failure anywhere inside the transitive closure of all the libraries Hibernate needs. It can be very confusing and take a while to debug. So save yourself the hassle of trying to figure out what the minimum set of libraries that are needed from the distro -- this is the list.

The other thing to consider in regards to the JBoss classloader is that other strange errors can be introduced if you have utility code (static Session recovery methods, for instance) that is shared by both the web and EJB tiers of your app. If the code gets too complex, you can find yourself in the weeds trying to figure out why your webapp is suddenly throwing NoClassDefFoundError in a very strange location of the application that you had not touched for many days or weeks. This is often a sign of a new dependency within the common code that is causing the object graph to get much much larger (think about adding one person to your friendster.com account ;) and suddenly everything stops. So by using the service, you can isolate the dependencies better between the tiers and save yourself a visit from Mr. Murphy two days after you forgot all the classloader details that you had studied a month ago.

So, basically, use the MBean!

Other guides

JBossHibernate JBoss WIKI page (JBoss 4.0 and Hibernate)

http://www.jboss.org/wiki/Wiki.jsp?page=JBossHibernate

JBoss 4.0 includes Hibernate 2.1.5 and ready to use Hibernate.

JBossHibernate-old JBoss WIKI page (JBoss 3.x.x and Hibernate)

http://www.jboss.org/wiki/Wiki.jsp?page=JBossHibernate-old

A bit obsolete guide.


  NEW COMMENT

Mr. Murphy 29 Oct 2003, 10:52 csak
I'm a newbie at J2EE technoilogies, so this might not be relevant.
For my installation of JBoss (3.2.1) the UserTransaction service's JNDI
name is not "java:/UserTransaction" but "UserTransaction". This can be
verified on the JMX console.
Thus the correct syntax of a hibernate2 service would be:

<server>
<mbean code="net.sf.hibernate.jmx.HibernateService"
name="jboss.jca:service=HibernateFactory,
                            name=HibernateFactory">
    <depends>jboss.jca:service=RARDeployer</depends>
    <depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
    <!-- Make it deploy ONLY after DataSource had been started -->
    <attribute name="MapResources">mappings/Attribute.hbm.xml</attribute>
    <attribute name="JndiName">java:/hibernate/HibernateFactory</attribute>
    <attribute name="Datasource">java:/MySqlDS</attribute>
    <attribute
name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
    <attribute
name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
    <attribute
name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
    <attribute name="UseOuterJoin">false</attribute>
    <attribute name="ShowSql">false</attribute>
    <attribute name="UserTransactionName">UserTransaction</attribute>
</mbean>
</server>

This might save a couple of hours, for those who run into the same problem.
 
Using Hibernate with JBoss / initilization order 03 Nov 2003, 17:48 jschulz
Hmm. This approach worked relativly good for me, I just avoided 
copying the hibernate libs into the server's lib directories by 
packing them into the '.sar'. 

However, when I restart the JBoss server, the hibernate service will 
not initlialize, because the the datasource I've configured isn't 
loaded at the point the '.sar' is loaded.
After this happend, the only way to get the hibernate service running 
again, is to re-deploy it. :-/

Is there a way to configure my hibernate service in a way that it only 
initializes AFTER the datasource is ready?

thanks for any comment,

J
 
Re: Using Hibernate with JBoss / initilization order 18 Nov 2003, 17:24 csak
On 03 Nov 2003 17:48, jschulz wrote:

>Hmm. This approach worked relativly good for me, I just avoided
>copying the hibernate libs into the server's lib directories by
>packing them into the '.sar'.

>However, when I restart the JBoss server, the hibernate service will
>not initlialize, because the the datasource I've configured isn't
>loaded at the point the '.sar' is loaded.
>After this happend, the only way to get the hibernate service running
>again, is to re-deploy it. :-/

>Is there a way to configure my hibernate service in a way that it only
>initializes AFTER the datasource is ready?

This part:

"...
    <depends>jboss.jca:service=RARDeployer</depends>
    <depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
..."

of the service description ensures that the sar is loaded after the
datasource is ready. You've probably omitted this part from the
configuration.
It works for me this way.
 
XDoclet Merge Dir 09 Dec 2003, 19:43 rollatwork
I've seen this talked about on the XDoclet mailing list, however, 
there was no answer posted.  Since this article discusses it, I'll put 
my question here and hopefully someone can respond:

The jboss-service-custom.xdt when merged puts the new elements outside 
the mbean for which I would like for it to be child nodes of.  Is 
there anyway to accomplish this.

My xdt looks like this:

<depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>

I'm using XDoclet 1.2b4 with Maven RC1.

Regards,
Roll
 
Re: XDoclet Merge Dir 11 Dec 2003, 14:13 sgwood
On 09 Dec 2003 19:43, rollatwork wrote:

>I've seen this talked about on the XDoclet mailing list, however,
>there was no answer posted.  Since this article discusses it, I'll put
>my question here and hopefully someone can respond:

>The jboss-service-custom.xdt when merged puts the new elements outside
>the mbean for which I would like for it to be child nodes of.  Is
>there anyway to accomplish this.

>My xdt looks like this:

><depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>

>I'm using XDoclet 1.2b4 with Maven RC1.

>Regards,
>Roll

In XDoclet 1.2b4, there is a bug in the jboss-service.xdt (XDoclet
template) which does this. I'll do a fix, and post it here and in the
Hibernate and XDoclet forums.

Ask this sort of question in the Hibernate forums - I doubt people are
looking at this page to answer you.

Cheers,


Sherman
 
Re: XDoclet Merge Dir 11 Dec 2003, 15:23 sgwood
On 11 Dec 2003 14:13, sgwood wrote:

>On 09 Dec 2003 19:43, rollatwork wrote:

>>I've seen this talked about on the XDoclet mailing list, however,
>>there was no answer posted.  Since this article discusses it, I'll put
>>my question here and hopefully someone can respond:

>>The jboss-service-custom.xdt when merged puts the new elements outside
>>the mbean for which I would like for it to be child nodes of.  Is
>>there anyway to accomplish this.

>>My xdt looks like this:

>><depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>

>>I'm using XDoclet 1.2b4 with Maven RC1.

>>Regards,
>>Roll

>In XDoclet 1.2b4, there is a bug in the jboss-service.xdt (XDoclet
>template) which does this. I'll do a fix, and post it here and in the
>Hibernate and XDoclet forums.

>Ask this sort of question in the Hibernate forums - I doubt people are
>looking at this page to answer you.

>Cheers,


>Sherman

Check out issues on XDoclet JIRA:

For the fix to your problem:

http://opensource.atlassian.com/projects/xdoclet/secure/ViewIssue.jspa?key=XDT-556


Hibernate 2.1 JBoss XDoclet:

http://opensource.atlassian.com/projects/xdoclet/secure/ViewIssue.jspa?key=XDT-734
 
Alternative JBoss configuration 16 Dec 2003, 19:33 jarkko
Hello, 
 Is it possible to configure JBoss/Hibernate so that hibernate can
lookup the mapping files from another jar (e.g. myHibernateClasses.jar)

Example:
myEar.ear
 hibernateStartup.sar
   META-INF/
            jboss-service.xml

 myHibernateClasses.jar
   eg/
      package/
             MyClass.class
             MyClass.hbm.xml


This configuration would allow to deploy the EAR in exploded format.
 
jboss-service-custom.xml? 16 Dec 2003, 20:28 craigduncan
In the example hibernatedoclet task near the top of this post you are
copying some files to the ${build.resources}/sar/hibernate directory.

What are the hibernate-properties-*.xml files for?  It looks like most
of the hibernate properties are set in the jboss-service.xml, so I was
wondering what these files are for?

Also, your example copies a jboss-service-custom.xml file.  Should that
be  a jboss-service-custom.xdt file?  I read the other posts about the
problem with the xdt provided with the 1.2.b4 release of xdoclet, but I
am still a little confused.  

Thanks for this great post on JBoss and Hibernate.  I am currently
trying to switch our product over to java.  We already have an existing
database so I am going the route of middlegen, hbm2java,
hibernatedoclet, sar to try to get it all working.
 
Re: jboss-service-custom.xml? 16 Dec 2003, 20:59 sgwood
On 16 Dec 2003 20:28, craigduncan wrote:

>In the example hibernatedoclet task near the top of this post you are
>copying some files to the ${build.resources}/sar/hibernate directory.

>What are the hibernate-properties-*.xml files for?  It looks like most
>of the hibernate properties are set in the jboss-service.xml, so I was
>wondering what these files are for?

There are some parts of a Hibernate hbm.xml file that cannot be
generated from XDoclet hibernatedoclet @tags in your source with XDoclet
1.2.b4. In my case, I needed to include:

<!-- Included by Hibernate XDoclet task into the hbm.xml -->

	<any name="referredToObject" id-type="long">
    	<column name="objectClass" length="128" not-null="true"/>
	    <column name="objectId" not-null="true"/>
	</any>

in one of my class mappings. So in my source tree I have:

com/galenworks/hibernate/DocumentCrossReference.java
com/galenworks/hibernate/hibernate-properties-DocumentCrossReference.xml

The hibernate-properties-DocumentCrossReference.xml contains the needed
snippet. Doing the copy of this file into
${build.resources}/sar/hibernate/com/galenworks/hibernate and then
running hibernatedoclet includes the snippet at the end of the class
tag, ie.

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN" 
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="com.galenworks.procedurelink.hibernate.DocumentCrossReference"
        table="DocumentXref"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="documentXrefId"
            column="documentXrefId"
            type="long"
        >
            <generator class="sequence">
                <param name="sequence">documentXrefSeq</param>
            </generator>
        </id>

        <property
            name="documentXPath"
            type="string"
            update="true"
            insert="true"
            column="documentXPath"
            length="255"
            not-null="true"
        />


[snip]


<!-- Included by Hibernate XDoclet task into the hbm.xml -->

	<any name="referredToObject" id-type="long">
    	<column name="objectClass" length="128" not-null="true"/>
	    <column name="objectId" not-null="true"/>
	</any>

    </class>

</hibernate-mapping>


>Also, your example copies a jboss-service-custom.xml file.  Should that
>be  a jboss-service-custom.xdt file?  I read the other posts about the
>problem with the xdt provided with the 1.2.b4 release of xdoclet, but I
>am still a little confused.

You are right - it should be "jboss-service-custom.xdt". I'll update the
wiki page.
 
Re: Alternative JBoss configuration 16 Dec 2003, 21:08 sgwood
On 16 Dec 2003 19:33, jarkko wrote:

>Hello,
> Is it possible to configure JBoss/Hibernate so that hibernate can
>lookup the mapping files from another jar (e.g. myHibernateClasses.jar)

>Example:
>myEar.ear
> hibernateStartup.sar
>   META-INF/
>            jboss-service.xml

> myHibernateClasses.jar
>   eg/
>      package/
>             MyClass.class
>             MyClass.hbm.xml


>This configuration would allow to deploy the EAR in exploded format.

I think the closest you are going to get is:

myEar.ear
 hibernateStartup.sar
   META-INF/
            jboss-service.xml
   eg/
      package/
             MyClass.hbm.xml

 myHibernateClasses.jar
   eg/
      package/
             MyClass.class

The Jboss Hibernate MBean needs to be able to find the hbm.xml files
specified in the MapResources attribute in the MBean descriptor on the
classpath of the SAR.
 
Some help needed 18 Dec 2003, 00:12 craigduncan
I posted to the hibernate forum with a question I was hoping you could
take a look at.

http://forum.hibernate.org/viewtopic.php?p=2182874#2182874

Thanks

Craig
 
Container managed JTA Session Service 20 Dec 2003, 14:20 ivelin
As suggested in an earlier post, I would like to propose the following
convenience service for the JBoss integration:

http://cocoonhive.org/jboss/jtasession.zip 

The initial proposal can be found here:
http://forum.hibernate.org/viewtopic.php?t=925357

An independent but related thread:
http://forum.hibernate.org/viewtopic.php?t=926369

Here is the rationale behind this service:
	This service is applicable when the application uses JTA transactions.
	Either directly, via transaction servlet filter, or EJB.
	http://java.sun.com/products/jta/javadocs-1.0.1/javax/transaction/UserTransaction.html
	http://java.sun.com/blueprints/code/adventure/1.0/src/com/sun/j2ee/blueprints/waf/controller/web/TransactionFilter.java.html
	http://java.sun.com/products/ejb/2.0.html

	The JTAHibernateFactory maintains one HibernateSession per JTA
transaction. 
	It obtains a new session when requested for the first time and binds it
to the underlying
	UserTransaction. If there is no JTA transaction at the time that the
session is requested,
	the factory will throw an exception.
    
	Subsequent requests for a Hibernate session from this factory will
return the existing one.
	Once bound to the UserTransaction, the factory registers a Transaction
Synchronization,
	which ensures that the session is properly closed before the
transaction ends.

	The relationship between each HibernateSession obtain through this factory 
	and the underlying UserTransactions is one to one.
	There is at most one HibernateSession for each UserTransaction and 
	each HibernateSession is related to exactly one UserTransaction.
	
	This eliminates the thread safety problem and allows for a efficient
use of the session cache.
	
	Usage example:
  	public void saveAccount( Account account ) throws HibernateException
 	{
 		Session s = DBHelper.getSession();
 		s.saveOrUpdate(account);
 		// no need to close the session manually
 	}
 	
 	where DBHelper.getHibernateSession() is:
 	
	public static Session getHibernateSession()
	{
		try
		{
			InitialContext ctx = new InitialContext();
			JTASessionFactory jtaf =
(JTASessionFactory)ctx.lookup("java:/hibernate/JTASessionFactory");
			return jtaf.getSession();
		}
		catch(NamingException ne)
		{
			throw new RuntimeException("Failed obtaining hibernate JTA session,
because of: " + ne.getMessage(), ne);
		}
	}
 
Missing the excellent xdoclet tutorial 06 Jan 2004, 16:36 olve
The tutorial pointed too by 
http://www.hibernate.org/72.html

is missing. Does anyone know where it is now?

Thx...
Olve
 
Re: Missing the excellent xdoclet tutorial 08 Jan 2004, 06:42 sgwood
On 06 Jan 2004 16:36, olve wrote:

>The tutorial pointed too by
>http://www.hibernate.org/72.html

>is missing. Does anyone know where it is now?

>Thx...
>Olve

Someone deleted it. It is back now.

Sherman
 
hot deploy in jboss.... (HIBERNATE, JAAS) 10 Feb 2004, 21:44 nobodyhere
I work in an environment where we have many different applications 
deployed to jboss using hibernate as persistence engine. We add a new 
application every couple of weeks. 
It would be nice to be able to deploy the application without having 
to restart JBoss. 
(I am creating an EAR file per application with it's own loader in 
jboss... 
My config: j2sdk1.4.2_02, hibernate-2.1.1, jboss-3.2.2) 

But there is a problem with JAAS... every application must validate 
security throught JAAS using a Database validation 
(using custom login of jboss org.jboss.security.ClientLoginModule and 
org.jboss.security.auth.spi.DatabaseServerLoginModule) 

Is it possible to 'hot deploy' a JAAS login module or configuration 
for my new published apps? 
Do I have to create a SAR or something inside a specific path in the 
EAR file? 

I am not a JAAS guru and I would be curious to know if this is not 
possible or if it has just not been done yet. 

Please help 
thanks.
 
Re: Container managed JTA Session Service 16 Feb 2004, 00:06 Horst Dehmer
Hi, Ivelin!

First of all, thanx for your contribution. 

I downloaded/build/deployed/installed jtasession.zip. Everything's 
fine. I even get a JTA hibernate session from the factory which works 
well. 
Now the problem: Before the end of the transaction/SLSB call, JBoss 
[CachedConnectionManager] closes the session's connection before 
JTASessionSynchronization gets the chance to do so...

DEBUG [JTASessionFactory] implementing transaction class: 
org.jboss.tm.TransactionImpl
DEBUG [JTASessionFactory] opening a new Hibernate session for 
transaction: TransactionImpl:XidImpl [FormatId=257, 
GlobalId=MEDUSA//3, BranchQual=]
DEBUG [JTASessionSynchronization] ctor: tx (TransactionImpl:XidImpl 
[FormatId=257, GlobalId=MEDUSA//3, BranchQual=]), sessionMap 
({TransactionImpl:XidImpl [FormatId=257, G
lobalId=MEDUSA//3, BranchQual=]
=net.sf.hibernate.impl.SessionImpl@16721bd})
INFO  [CachedConnectionManager] Successfully closed a connection for 
you.  Please close them yourself: 
org.jboss.resource.adapter.jdbc.WrappedConnection@14fcd9a
java.lang.Exception: Stack Trace
        at 
org.jboss.resource.connectionmanager.CachedConnectionManager.closeAll
(CachedConnectionManager.java:376)
        at 
org.jboss.resource.connectionmanager.CachedConnectionManager.popMetaAwa
reObject(CachedConnectionManager.java:199)
        at 
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke
(CachedConnectionInterceptor.java:190)
        at 
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke
(StatelessSessionInstanceInterceptor.java:72)
        ....
DEBUG [JTASessionSynchronization] called: beforeCompletion()
DEBUG [JTASessionSynchronization] called: afterCompletion(txStatus (3))

I tried with JBoss 3.2.0/3.2.2RC1 and Hibernate 2.1.1/2.1.2.

Here my simple code:

String jndiName = "java:/hibernate/JTASessionFactory";
InitialContext ctx = new InitialContext();
JTASessionFactory jtaf = (JTASessionFactory)ctx.lookup(jndiName);
Session session = jtaf.getSession();
ProductData data = (ProductData)session.load(ProductData.class, new 
Integer(id));

Have I missed a point. Probably configuration problems. I deployed my 
hibernate mappings as a sar/mbean with the following service 
descriptor:

<mbean 
  code="net.sf.hibernate.jmx.HibernateService" 
  
name="jboss.jca:service=HibernateFactory,name=NorthwindHibernateFactory
">

  <!-- Make it deploy ONLY after DataSource had been started -->
  <depends>jboss.jca:service=RARDeployer</depends>
  <depends>jboss.jca:service=LocalTxCM,name=northwind</depends>
  
  <attribute name="MapResources">  
    de/hal9000/northwind/mapping/ProductData.hbm.xml
  </attribute>
  
  <attribute 
name="JndiName">java:/hibernate/NorthwindHibernateFactory</attribute>
  <attribute name="Datasource">java:/northwind</attribute>
  <attribute 
name="Dialect">net.sf.hibernate.dialect.PostgreSQLDialect</attribute>
  <attribute 
name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionF
actory</attribute>
  <attribute 
name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JB
ossTransactionManagerLookup</attribute>
  <attribute name="UseOuterJoin">true</attribute>
  <attribute name="ShowSql">false</attribute>
  <attribute 
name="UserTransactionName">java:/UserTransaction</attribute>
</mbean>

Any help is highly appreciated.

Thank you,
Horst
 
Re: Container managed JTA Session Service 17 Feb 2004, 10:02 hengels
Why isn't this the standard behaviour of the Hibernate JCA service
itself? Don't all datasources and other JCA services work like this?

Holger
 
Synchronization problem 17 Feb 2004, 23:29 jdragon
I'm using Hibernate 2.1x as an mbean with Jboss.  My configuration is 
exactly the same as described in the document (except the ds name and 
jndi name).    

My web app works fine for the first 8 or so hours and then I get the 
below exception whenever one of my business delegates tries to 
retrieve a dto/pojo from my dao: 

net.sf.hibernate.HibernateException: 
net.sf.hibernate.TransactionException: could not register 
synchronization with JTA TransactionManager 

Is hibernate leaking resource somewhere?
 
HibernateServiceMBean has classloader problems 26 Feb 2004, 15:22 tmaus
Im using the same example as above .. 
but as long as i keep my hbm.xml files in a structure like
com/foo/bar/aa.hbm.xml
the file is not find by the HibernateServiceMBean. 

once i put it into the root directory it is found and bound

any ideas about that ???
 
Re: HibernateServiceMBean has classloader problems 26 Feb 2004, 17:17 tmaus
On 26 Feb 2004 15:22, tmaus wrote:

>Im using the same example as above ..
>but as long as i keep my hbm.xml files in a structure like
>com/foo/bar/aa.hbm.xml
>the file is not find by the HibernateServiceMBean.

>once i put it into the root directory it is found and bound

>any ideas about that ???

it looks like this only occurs if the .hbm.xml files are in a packed jar .. 
the moment i deploy the application exploded ... things work ... 

here is my structure 

foo.sar
| -- META-INF
|       | -- jboss-service.xml
|
| - hibernate-2.1
| - myHibernateClassesAndMappingFiles
|
| - other things
 
Re: Using Hibernate with JBoss / initilization order 05 Mar 2004, 10:59 tmaus
nice .. 
can u provide me some code snipplets .. 

i was not able to force the sar file to take local packages .. 
i needed to put the files into the lib directory ...
 
JNDI doesnt work? 05 Mar 2004, 18:07 ipojman
I've followed directions, looks like everything is right. The sar is
getting delpoyed. the JNDI name is set in the sar. Yet the JDNI is never
being bound, and I have no errors coming from JBoss logs. How can I
ensure that the hibernate service is being bound to JNDI? frustrating...


using:hibernate 2.1, jboss 3.2.3

any tips would be appreciated - thanks,
ian
 
Re: Using Hibernate with JBoss / initilization order 05 Mar 2004, 19:07 mathis
On 05 Mar 2004 10:59, tmaus wrote:

>nice ..
>can u provide me some code snipplets ..

>i was not able to force the sar file to take local packages ..
>i needed to put the files into the lib directory ...

I guess the problem is with the manifest file. The format is a bit
tricky. Below is the configuration which wored for me. Beware: the first
jar name must be on the same line as "Class-Path:". And the effect is
limited: the classes are still in the global addreee space of the ear
(or JBoss, if outside a ear).

Manifest-Version: 1.0
Built-By: Gopas Software
Class-Path: lib/commons-logging.jar
  lib/hibernate2.jar
  lib/ognl.jar
  lib/odmg.jar
  lib/commons-lang.jar
  lib/commons-collections.jar
  lib/cglib2.jar
  lib/commons-beanutils.jar
  lib/commons-codec.jar
  lib/commons-digester.jar
  lib/commons-fileupload.jar
  lib/ehcache.jar
  lib/jakarta-oro.jar
  lib/javassist.jar
  (other jars...)
 
Re: HibernateServiceMBean has classloader problems 07 Mar 2004, 00:54 sgwood
On 26 Feb 2004 17:17, tmaus wrote:

>On 26 Feb 2004 15:22, tmaus wrote:

>>Im using the same example as above ..
>>but as long as i keep my hbm.xml files in a structure like
>>com/foo/bar/aa.hbm.xml
>>the file is not find by the HibernateServiceMBean.

>>once i put it into the root directory it is found and bound

>>any ideas about that ???

>it looks like this only occurs if the .hbm.xml files are in a packed
jar .. 
>the moment i deploy the application exploded ... things work ...

>here is my structure

>foo.sar
>| -- META-INF
>|       | -- jboss-service.xml
>|
>| - hibernate-2.1
>| - myHibernateClassesAndMappingFiles
>|
>| - other things

How are you specifying the mappings in the jboss-service.xml? From your
example, you should have something like:

<attribute name="MapResources">com/foo/bar/aa.hbm.xml</attribute>

In the SAR, the structure would be:

foo.sar
| -- META-INF
|       | -- jboss-service.xml
|
| -- com
|       | -- foo
|            | -- bar
|                 | -- aa.hbm.xml


Sherman
 
Re: JNDI doesnt work? 07 Mar 2004, 00:56 sgwood
On 05 Mar 2004 18:07, ipojman wrote:

>I've followed directions, looks like everything is right. The sar is
>getting delpoyed. the JNDI name is set in the sar. Yet the JDNI is never
>being bound, and I have no errors coming from JBoss logs. How can I
>ensure that the hibernate service is being bound to JNDI? frustrating...


>using:hibernate 2.1, jboss 3.2.3

>any tips would be appreciated - thanks,
>ian

Post a question about this on the forums.

Include your jboss-service.xml and the Hibernate startup log output .


Sherman
 
Memory Leak? 14 Mar 2004, 23:12 rchristy
Hello, 

I've posted this under the newbie formum and haven't gotten any 
replies, so I thought I would try here.

We just started using Hibernate 2.1.2 with JBoss 3.2.3RC1 and seem to 
be having a memory leak (also using Oracle 9.2). We have a client 
application that reads about 2000 objects (the object is read-only 
mapping) one at a time from the server. If I put this client 
application into a loop that runs every 30 seconds, we run out of heap 
memory within the server after a couple of hours (we have it max VM 
size at 1.5G, and the object isn't that large). We have tried both 
net.sf.hibernate.cache.TreeCacheProvider and ehcache with the same 
results. 

We have session bean that basically performs the following steps: 

1) Creates a Session. 
2) Performs the query. 
3) Closes the Session. 

We are assuming the JBoss container is controllering the transaction 
(but this is a reading operation of a read-only bean). Are we required 
to do anything other than openning/closing a Hibernate session within 
the JBoss container? We have to be missing something to have a memory 
leak this bad. 

We are using the Hibernate Service MBean as the documentation states, 
here is the declaration within our jboss-service.xml file. 

<mbean code="net.sf.hibernate.jmx.HibernateService" 
name="jboss.jca:service=Hibernate-ScorDS"> 
<depends>jboss.jca:service=RARDeployer</depends> 
<depends>jboss.jca:service=LocalTxCM,name=jdbc/ScorDS</depends> 

<attribute 
name="CacheProvider">net.sf.hibernate.cache.TreeCacheProvider</attribut
e> 

<!-- 
<attribute 
name="CacheProvider">net.sf.ehcache.hibernate.Provider</attribute> 
--> 

<attribute name="UseQueryCache">true</attribute> 
<attribute name="MapResources"> 
&referenceservice-resources;, 
&securitiesservice-resources; 
</attribute> 
<attribute name="JndiName">java:/hibernate/ScorDS</attribute> 
<attribute name="Datasource">java:/jdbc/ScorDS</attribute> 
<attribute 
name="Dialect">net.sf.hibernate.dialect.Oracle9Dialect</attribute> 
<attribute name="UseOuterJoin">true</attribute> 
<attribute name="ShowSql">false</attribute> 
<attribute name="UserTransactionName">UserTransaction</attribute> 
<attribute 
name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionF
actory</attribute> 
<attribute 
name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JB
ossTransactionManagerLookup</attribute> 
</mbean> 


Any help would be appreciated. Thanks in advance, 

Rich
 
Re: Container managed JTA Session Service 18 Mar 2004, 13:29 hengels
I'm using your jta session service and it was working most of the time. 
but now I'm seeing a strange exception: 
 
11:11:14,944 DEBUG [Enlistment#findBySubjectAndActivity] Executing SQL: 
SELECT DISTINCT t0_l.id, t0_l.created, t0_l.activity, t0_l.subject FROM 
engagement_enlistment t0_l, engagement_subject t1_l_subject WHERE 
(t1_l_subject.id = ? AND t0_l.activity = ? AND 
t0_l.subject=t1_l_subject.id) 
11:11:14,948 INFO  [STDOUT] Hibernate: select engagement0_.id as id0_, 
engagement0_.title as title0_, engagement0_.publisher as publisher0_, 
engagement0_.department as department0_, engagement0_.jobDescription as 
jobDescr5_0_, engagement0_.closed as closed0_, 
engagement0_.advertisedInternally as advertis7_0_, 
engagement0_.advertisedExternally as advertis8_0_ from engagement 
engagement0_ where engagement0_.id=? 
11:11:14,949 INFO  [STDOUT] Hibernate: select applicatio0_.id as id__, 
applicatio0_.engagement as engagement__, applicatio0_.pos as pos__, 
applicatio0_.id as id0_, applicatio0_.engagement as engagement0_, 
applicatio0_.applicant as applicant0_, applicatio0_.notes as notes0_, 
applicatio0_.invitation as invitation0_, applicatio0_.decision as 
decision0_, applicatio0_.notified as notified0_ from application 
applicatio0_ where applicatio0_.engagement=? 
11:11:15,105 ERROR [STDERR] net.sf.hibernate.HibernateException: 
Session is currently disconnected 
        at 
net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3143) 
        at 
net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:61) 
        at 
net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:703) 
        at net.sf.hibernate.loader.Loader.doQuery(Loader.java:184) 
        at 
net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132) 
        at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:830) 
        at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:850) 
        at 
net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57) 
        at 
net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49) 
        at 
net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:420) 
        at 
net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2044) 
        at 
net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1918) 
        at 
net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1847) 
        at 
org.concern.test.engagement.engagement.EngagementLoader.load(EngagementLoader.java:27) 
 
As you can see, some of the hibernate calls are working, but then 
hibernate claims: "Session is currently disconnected". The transaction 
is active. the session was obtained from the service just before the 
invocation of load. 
 
what exactly is happening? the thread goes through the following 
arrangement of transacted methods: 
 
NEVER process { 
  NEVER execute { 
    REQUIRED checkPrecondition { 
    } 
 
    REQUIRES NEW executeAsynchronously { 
      REQUIRED enlist { 
        REQUIRED checkPrecondition { 
        } 
 
        REQUIRED initiate { 
          REQUIRED load { 
            net.sf.hibernate.HibernateException: Session is currently 
disconnected 
          } 
        } 
      } 
    } 
  } 
}
 
Re: Container managed JTA Session Service 18 Mar 2004, 14:07 hengels
>As you can see, some of the hibernate calls are working, but then
>hibernate claims: "Session is currently disconnected". The transaction
>is active. the session was obtained from the service just before the
>invocation of load.
 
Hm, adding these two lines to the JTASessionFactory just before 
returning the session solves the problem: 
 
                if (!hsession.isConnected()) 
                    hsession.reconnect(); 
 
Holger
 
Using Hibernate 2 and Jboss 3.2.3 and having transaction error. 26 Mar 2004, 07:18 bc2002
I am using Hibernate 2, Jboss 3.2.3 and PostgreSql 7.3.  I got a 
transaction roll back and an error which I donot really know what it is.  
Any hint or help is appreciated.

Here is the error

7:04:05,015 ERROR [LogInterceptor] TransactionRolledbackException in 
method: public abstract com.ejb.interfaces.Tuser 
com.ejb.interfaces.TuserHome.create(com.ejb.dto.TuserData) throws 
javax.ejb.CreateException,java.rmi.RemoteException, causedBy: 
org.jboss.tm.JBossRollbackException: Unable to commit, 
tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=bc2002.local//25, 
BranchQual=] status=STATUS_NO_TRANSACTION; - nested throwable: 
(javax.ejb.EJBException: null; CausedByException is: 
null) 
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:413) 
at 
org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.j
ava:398) 
at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptor
CMT.java:277) 
at 
org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:
98) 
at 
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor
.java:92) 
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:
120) 
at 
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFact
oryFinderInterceptor.java:93) 
at 
org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:
483) 
at org.jboss.ejb.Container.invoke(Container.java:720) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39) 
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:324) 
at 
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDi
spatcher.java:284) 
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546) 
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
367) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39) 
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:324) 
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) 
at sun.rmi.transport.Transport$1.run(Transport.java:148) 
at java.security.AccessController.doPrivileged(Native Method) 
at sun.rmi.transport.Transport.serviceCall(Transport.java:144) 
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:
460) 
at 
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.ja
va:701) 
at java.lang.Thread.run(Thread.java:552) 
Caused by: javax.ejb.EJBException: null; CausedByException is: 
null 
at 
org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenceMa
nager.java:475) 
at 
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEn
tity(CachedConnectionInterceptor.java:387) 
at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:714) 
at 
org.jboss.ejb.GlobalTxEntityMap.synchronizeEntities(GlobalTxEntityMap.ja
va:149) 
at 
org.jboss.ejb.GlobalTxEntityMap$GlobalTxEntityMapSynchronize.beforeCompl
etion(GlobalTxEntityMap.java:215) 
at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:
1308) 
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:347) 
... 26 more 

thanks 

bc2002
 
Using hibernate with jboss 18 Jun 2004, 00:47 marcelitamo
I have my file hibernate.sar with the following structure:

META-INF/jboss-service.xml
mappings/Usuario.hbm.xml
co/edu/escuelaing/Usuario.class

Jboss-service.xml is:

<server> 
<mbean code="net.sf.hibernate.jmx.HibernateService" 
name="jboss.jca:service=HibernateFactory, 
name=HibernateFactory"> 
<depends>jboss.jca:service=RARDeployer</depends> 
<depends>jboss.jca:service=LocalTxCM,name=SigmaDS</depends> 
<!-- Make it deploy ONLY after DataSource had been started --> 
<attribute name="MapResources">/mappings/Usuario.hbm.xml</attribute> 
<attribute 
name="JndiName">java:/hibernate/HibernateFactory</attribute> 
<attribute name="Datasource">java:/SigmaDS</attribute> 
<attribute 
name="Dialect">net.sf.hibernate.dialect.PostgreSQLDialect</attribute> 
<attribute 
name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionF
actory</attribute> 
<attribute 
name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JB
ossTransactionManagerLookup</attribute> 
<attribute name="UseOuterJoin">false</attribute> 
<attribute name="ShowSql">false</attribute> 
<attribute name="UserTransactionName">UserTransaction</attribute> 
</mbean> 
</server>

but when I run Jboss server, appears to me this: 

17:43:13,576 INFO [Configuration] Mapping resource: 
mappings/Usuario.hbm.xml 
17:43:13,597INFO [HibernateServiceMBean] Could not build 
SessionFactory using 
the MBean classpath - will try again using client classpath: Resource: 
mappings/Usuario.hbm.xml not found 

I do not know, why?
 
Re: Alternative JBoss configuration 26 Aug 2004, 15:04 knuterik
On 16 Dec 2003 21:08, sgwood wrote:

>>Hello,
>> Is it possible to configure JBoss/Hibernate so that hibernate can
>>lookup the mapping files from another jar (e.g. myHibernateClasses.
jar)


>I think the closest you are going to get is:
>myEar.ear
> hibernateStartup.sar
>   META-INF/
>            jboss-service.xml
>   eg/
>      package/
>             MyClass.hbm.xml
> myHibernateClasses.jar
>   eg/
>      package/
>             MyClass.class
>
>The Jboss Hibernate MBean needs to be able to find the hbm.xml files
>specified in the MapResources attribute in the MBean descriptor on the
>classpath of the SAR.

I tried to make my .ear file have this structure and the web application 
starts OK, nut the .sar file is not deployed/initialised.

Do I have to specify something in the default or jboss deployment 
descriptors for this to work?
 
Re: Container managed JTA Session Service 19 Oct 2004, 10:58 alesj
Hi!

Did you manage to fix this exception?

>INFO  [CachedConnectionManager] Successfully closed a connection for
>you.  Please close them yourself:
>org.jboss.resource.adapter.jdbc.WrappedConnection@14fcd9a
>java.lang.Exception: Stack Trace

If so, what did you do?

Thanx for any help, Ales
 
Re: Container managed JTA Session Service 28 Oct 2004, 19:32 juice
>I downloaded/build/deployed/installed jtasession.zip. Everything's
>fine. I even get a JTA hibernate session from the factory which works
>well.
>Now the problem: Before the end of the transaction/SLSB call, JBoss
>[CachedConnectionManager] closes the session's connection before
>JTASessionSynchronization gets the chance to do so...
>INFO  [CachedConnectionManager] Successfully closed a connection for
>you.  Please close them yourself:

In your transaction-service.xml in the deploy directory,
make sure you have
<attribute name="Debug">false</attribute>

If debug is set to true, JBoss will close your connection before you are 
done with them. Very annoying.
 
Re: Container managed JTA Session Service 03 Aug 2006, 08:51 clcantrell
Is there a URL where the JTASession.jar can be found?  The one listed 
returns 404.
 
Facing problem with NotNull constraint with Jboss 28 Dec 2006, 07:40 Kirti
If org.Hibernate.PropertyValueException is coming in hibernate after 
that session is not working.I am displaying an error page.From that 
page i am trying to login its giving the same exception 
(org.Hibernate.PropertyValueException )in session.CreateQuery.But i am 
creating new session always.I have to stop the jboss server and 
restart it to again login.I am using mySql database.

In production its very difficult to deal with this situation.

Please help me to fix this problem.
Waiting for reply.

Thankns in advance.
 
Re: Synchronization problem 24 Apr 2007, 04:41 TransactionException
POST QUESTIONS ON THE FORUM! COMMENTS HERE SHOULD ADD VALUE TO THE 
PAGE!On 17 Feb 2004 23:29, jdragon wrote:

>I'm using Hibernate 2.1x as an mbean with Jboss.  My configuration is
>exactly the same as described in the document (except the ds name and
>jndi name).

>My web app works fine for the first 8 or so hours and then I get the
>below exception whenever one of my business delegates tries to
>retrieve a dto/pojo from my dao:

>net.sf.hibernate.HibernateException:
>net.sf.hibernate.TransactionException: could not register
>synchronization with JTA TransactionManager

>Is hibernate leaking resource somewhere?

Please let me know if you have resolved this issue. I am facing 
something similar. A quick help will be appreciated.
 
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]