-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: strange things happen to me!!!
PostPosted: Thu May 27, 2004 9:43 pm 
Regular
Regular

Joined: Tue Dec 30, 2003 2:35 am
Posts: 85
i use the hibernate in mbean of jboss,it work fine
but.....today it tell me the error(after objSession.flush();):
org.apache.jasper.JasperException: could not register synchronization with JTA TransactionManager

did anybody meet this problem????

here is my jboss-service.xml
Code:
<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=OracleDS</depends>
    <!-- Make it deploy ONLY after DataSource had been started -->
    <attribute name="MapResources">com/SFHC/RepairSFHC/DB/SFHCNO.hbm.xml,
    com/SFHC/RepairSFHC/DB/SFHCPhoto.hbm.xml,
    com/SFHC/RepairSFHC/DB/SFHCText.hbm.xml,
    com/SFHC/RepairSFHC/DB/SFHCTextHistory.hbm.xml,
    com/SFHC/RepairSFHC/DB/SFHCTextLog.hbm.xml
    </attribute>
    <attribute name="JndiName">java:/hibernate/HibernateFactory</attribute>
    <attribute name="Datasource">java:/OracleDS</attribute>
    <attribute name="Dialect">net.sf.hibernate.dialect.OracleDialect</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>


here is my jsp test code:
Code:
<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="net.sf.hibernate.SessionFactory" %>
<%@ page import="net.sf.hibernate.Session" %>
<%@ page import="net.sf.hibernate.Transaction" %>
<%!
  javax.sql.DataSource ds;
  SessionFactory sf;
  Session objSession;
  Transaction tx;
%>

<%
  try {
      Context ctx = new InitialContext();
      out.println("start use the hibernate<br>");
      sf = (SessionFactory)ctx.lookup("java:/hibernate/HibernateFactory");
      objSession = sf.openSession();
      //if (!objSession.isConnected())
      //    objSession.reconnect();
      tx = objSession.beginTransaction();
      com.SFHC.RepairSFHC.DB.SFHCNO objNo = new com.SFHC.RepairSFHC.DB.SFHCNO();
      objNo.setv_JMZH("77777777");
      objSession.save(objNo);
      objSession.flush();
      out.println("flush<br>");
      /*
      tx.commit();
     
      objSession.close();
      objSession.connection().close();
      out.println("end use the hibernate<br>");
      */
    } catch (Exception e) {
      if(tx!=null)
      {
         tx.rollback();
      }
      if(objSession!=null)
      {
         objSession.close();
         objSession.connection().close();
      }
      out.println("error!!!!!!!!!!!!!!" + e.toString());
    }
%>


the datasource of jboss work fine(java:/OracleDS),here is my test jsp code:
Code:
<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="net.sf.hibernate.SessionFactory" %>
<%@ page import="net.sf.hibernate.Session" %>
<%@ page import="net.sf.hibernate.Transaction" %>
<%!
  javax.sql.DataSource ds;
  SessionFactory sf;
  Session objSession;
  Transaction tx;
%>

<%
  try {
      Context ctx = new InitialContext();
      ds = (javax.sql.DataSource)ctx.lookup("java:/OracleDS");
      Connection conn = ds.getConnection();
      Statement st = conn.createStatement();
      String sqlStr = "select * from rkxx where rownum<=100";
      ResultSet rs = st.executeQuery(sqlStr);
      while(rs.next()){
        out.println(rs.getString("PERSONID")+"<br>");
      }
      rs.close();
      st.close();
      conn.close();
    } catch (Exception e) {
      out.println("error!!!!!!!!!!!!!!" + e.toString());
    }
%>


thanks a lot!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.