File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JBoss/WildFly and the fly likes JBoss AS5 with Hibernate 3 annotations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "JBoss AS5 with Hibernate 3 annotations" Watch "JBoss AS5 with Hibernate 3 annotations" New topic

JBoss AS5 with Hibernate 3 annotations

Ashish Shinde
Ranch Hand

Joined: Dec 08, 2002
Posts: 34
I am trying to integrate JBoss AS5 with Hibernate 3 using annotations.
My requirement is to get SessionFactory through a JNDI lookup.
I tried the following link:

I have completed following steps:
1. Created the *-ds.xml for creating the datasource and binding to JNDI.
2. Created annotated entity class (just one class for one table as start).
3. Created the *-hibernate.xml as follows:

This file has similar structure as hibernate.cfg.xml and placed in the <jboss-as>/default/deploy folder.

The above file throws an error during startup as:
org.jboss.xb.binding.JBossXBException: Failed to parse source: {urn:jboss:hibernate-deployer:1.0}mapping cannot appear in this position.
Expected content of {urn:jboss:hibernate-deployer:1.0}session-factory is unordered_sequence: {urn:jboss:hibernate-deployer:1.0}depends* {urn:jboss:hibernate-deployer:1.0}property*

It seems the <mapping> tag is not accepted under session-factory> and it works if I remove the <mapping> elements.
But the standard hibernate.cfg.xml does accept <mapping> under <session-factory>.

I do not have any *.hbm.xml as I want to use annotations.

Is there anything else I need to take care of or what is the correct way of doing it?
Any pointers or links would be helpful.

Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

I would recommend that you use the normal JPA spec specified jar deployment containing the persistence.xml. You can then additionally add the to the persistence.xml as explained here, to bind the entity manager factory in JNDI.

[My Blog] [JavaRanch Journal]
Ashish Shinde
Ranch Hand

Joined: Dec 08, 2002
Posts: 34

I am not using EJB3 but JBoss with SOA.
Will this setting still work. My assumption is it will work as there is no relation to EJB3 here.
Please confirm.
Any good tutorial which will help me understand it would be helpful.
I agree. Here's the link:
subject: JBoss AS5 with Hibernate 3 annotations
It's not a secret anymore!