2 Replies Latest reply on Jun 1, 2009 4:36 AM by pinar soyisim

    JBoss 4.2.2.GA Hibernate configuration through JTA throws no

    Madhuranjan Sinha Newbie

      I am trying to configure JTA based Transaction for Hibernate on JBoss-4.2.2.GA. When I call persist nothing happens. When i put a flush after persist it throws javax.persistence.TransactionRequiredException: no transaction is in progress.

      Below are the configurations and others:

      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
      <persistence-unit name="Manager1" transaction-type="JTA">



      Content of Account.java class

      public class Account implements java.io.Serializable {

      private int ID;
      private BigDecimal amt;
      private String name;

      public Account() {

      public Account(int ID) {
      this.ID = ID;
      public Account(int ID, BigDecimal amt, String name) {
      this.ID = ID;
      this.amt = amt;
      this.name = name;

      @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
      @Column(name="ID", unique=true, nullable=false)
      public int getID() {
      return this.ID;

      public void setID(int ID) {
      this.ID = ID;

      @Column(name="amt", precision=12, scale=4)
      public BigDecimal getAmt() {
      return this.amt;

      public void setAmt(BigDecimal amt) {
      this.amt = amt;

      public String getName() {
      return this.name;

      public void setName(String name) {
      this.name = name;

      Code Where I am trying to execute and I am getting error:

      EntityManagerFactory emf = Persistence.createEntityManagerFactory("Manager1");
      EntityManager em = emf.createEntityManager();
      ac = new Account();
      ac.setName("Madhu" + new Date());
      ac.setAmt(new BigDecimal("50.45"));
      em = emf.createEntityManager();

      I tried all possible things but did not able to start the transaction. What step i am missing. Please help me resolve. My database is SQL Server 2005.

        • 1. Re: JBoss 4.2.2.GA Hibernate configuration through JTA throw
          Madhuranjan Sinha Newbie

          It seems that part of persistence.xml is not visiable. Here it is:

          >persistence-unit name="Manager1" transaction-type="JTA"<
          >property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/<
          >property name="jboss.entity.manager.jndi.name" value="java:/Manager1"/<
          >property name="jboss.entity.manager.factory.jndi.name" value="java:/Manager1Factory"/<
          >property name="hibernate.show_sql" value="true"/<
          >property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/<
          >property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/<

          • 2. Re: JBoss 4.2.2.GA Hibernate configuration through JTA throw
            pinar soyisim Newbie

            I have the same problem, no data is written to DB although there's no exception. I had even debugged Hibernate source code, it turns out Hibernate thinks my class is Transient even i annaotated it with @Entity. I think this is the problem but haven't find a solution yet, have you?