우리는 websphere 7에서 최대 절전 모드, 스프링 및 DB2를 사용하는 응용 프로그램을 가지고 있습니다. 우리는 감사 트리거를 가지고 있으며 트리거가 로그인 한 사용자를 알 수 있도록 설정해야합니다 데이터베이스). 우리는 새로운 애플 리케이션에 이것을 설정하기위한 새로운 계획을 제안하여 새로운 트랜잭션에 자동으로 참여할 수있게했습니다. 우리는 트랜잭션 관리자를 무효화하고 doBegin에서 작업을 수행했습니다.사전 바인딩 된 JDBC 연결이 발견되었습니다
이러한 구성표는 한 앱에서 훌륭하게 작동했으며 두 번째 앱에서는 훌륭하게 작동했지만 지금은 몇 주 후로 일관되게 (동작이 간헐적이며 현지 개발에서 발생하지 않음) 바인드 된 JDBC Connection에서 오류가 발생했습니다. 온라인에서 보면 대부분의 게시물은 하나의 데이터 소스에 대해 두 개의 트랜잭션 관리자를 사용한다고 말합니다. 그것은 지금 우리가하고있는 것입니다.
나는 그가 주석과 AOP 기반 트랜잭션을 혼합했기 때문에 그것이 궁금한 게시물 하나를 읽었습니다. 이 응용 프로그램 중 일부는 않습니다. 나는 그 이론을 정말로 구입하지는 않지만 그것을 언급 할 것이라고 생각했다.
예외 :
Caused by:
org.springframework.transaction.IllegalTransactionStateException: Pre-bound JDBC Connection found! HibernateTransactionManager does not support running within DataSourceTransactionManager if told to manage the DataSource itself. It is recommended to use a single HibernateTransactionManager for all transactions on a single DataSource, no matter whether Hibernate or JDBC access.
at java.lang.Throwable.<init>(Throwable.java:67)
at org.springframework.core.NestedRuntimeException.<init>(NestedRuntimeException.java:54)
at org.springframework.transaction.TransactionException.<init>(TransactionException.java:34)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:475)
at gov.usdoj.afms.umc.utils.hibernate.AfmsHibernateTransactionManager.doBegin(AfmsHibernateTransactionManager.java:28)
코드 (예외가 super.doBegin에서 온다) (주) :
protected void doBegin(Object arg0, TransactionDefinition arg1) {
super.doBegin(arg0, arg1);
if (!Db2ClientInfo.exists()) {
clearDBProperty();
} else {
setDBProperty(Db2ClientInfo.getClientUserId(), Db2ClientInfo.getClientApplicationId());
}
}
private void setDBProperty(String uId, String appName) {
Session session = getSessionFactory().getCurrentSession();
Properties props = new Properties();
props.setProperty(WSConnection.CLIENT_ID, uId);
props.setProperty(WSConnection.CLIENT_APPLICATION_NAME, appName);
try {
Connection nativeConn = new SimpleNativeJdbcExtractor().getNativeConnection(session.connection());
if (nativeConn instanceof WSConnection) {
WSConnection wconn = (WSConnection) nativeConn;
wconn.setClientInformation(props);
} else {
logger.error("Connection was NOT an instance of WSConnection so client ID and app could not be set");
}
} catch (Exception e) {
throw new RuntimeException("Cannot set DB parameters!", e);
}
}
http://stackoverflow.com/questions/12606257/spring-multiple-transaction-manager-issue – Gray