JOTM 사무관리 타임즈 JNDI 오류 문제, 정말 어쩔 수 없습니다. JOTM에 익숙한 번거로움을 보십시오.
24702 단어 JNDI
주 함수 코드:
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
IUserServiceDS userService = (IUserServiceDS) ctx.getBean("userServiceDS");
User1 user1 = new User1();
user1.setName("user1");
User2 user2 = new User2();
user2.setName("user2");
userService.insertBothUser(user1, user2);
DS 관련 코드:
private User1DAO dao1;
private User2DAO dao2;
public void insertBothUser(User1 user1, User2 user2) throws Exception {
this.insertUser1(user1);
if(user2.getName().equalsIgnoreCase("user2")){
throw new Exception();
}
else {
this.insertUser2(user2);
}
}
public void insertUser1(User1 user1) {
dao1.save(user1);
}
public void insertUser2(User2 user2) {
dao2.save(user2);
}
applicationContext.xml 내용:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- JOTM -->
<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean" />
<bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransaction" ref="jotm" />
</bean>
<bean id="ds1" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource">
<property name="dataSource">
<bean class="org.enhydra.jdbc.standard.StandardXADataSource">
<property name="transactionManager" ref="jotm" />
<property name="driverName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://10.129.68.170:3306/jotm1" />
</bean>
</property>
<property name="user" value="root" />
<property name="password" value="root" />
</bean>
<bean id="sessFactory1" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="ds1" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/xa/model/User1.hbm.xml</value>
</list>
</property>
<property name="jtaTransactionManager">
<ref bean="jotm" />
</property>
</bean>
<bean id="ds2" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource">
<property name="dataSource">
<bean class="org.enhydra.jdbc.standard.StandardXADataSource">
<property name="transactionManager" ref="jotm" />
<property name="driverName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://10.129.68.170:3306/jotm2" />
</bean>
</property>
<property name="user" value="root" />
<property name="password" value="root" />
</bean>
<bean id="sessFactory2" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="ds2" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/xa/model/User2.hbm.xml</value>
</list>
</property>
<property name="jtaTransactionManager">
<ref bean="jotm" />
</property>
</bean>
<!-- JOTM -->
<bean id="User1DAO" class="com.xa.dao.User1DAO">
<property name="sessionFactory">
<ref bean="sessFactory1" />
</property>
</bean>
<bean id="User2DAO" class="com.xa.dao.User2DAO">
<property name="sessionFactory">
<ref bean="sessFactory2" />
</property>
</bean>
<bean id="userServiceDS" class="com.xa.service.UserServiceDS">
<property name="dao1" ref="User1DAO" />
<property name="dao2" ref="User2DAO" />
</bean>
<!-- -->
<bean id="beanNameProxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*DS</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="txManager" />
<property name="transactionAttributeSource" ref="txAttributeSource" />
</bean>
<bean id="txAttributeSource"
class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
</props>
</property>
</bean>
<!-- -->
</beans>
carol.properties 컨텐트:
# do not use CAROL JNDI wrapper
carol.start.jndi=false
# do not start a name server
carol.start.ns=false
# Naming Factory
carol.jndi.java.naming.factory.url.pkgs=org.apache.naming
런타임즈의 예외는 다음과 같습니다.
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,656 -- INFO -- RDBMS: MySQL, version: 5.1.34-community
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,656 -- INFO -- JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.7 ( Revision: ${svn.Revision} )
org.hibernate.dialect.Dialect 2009-11-24 11:24:27,656 -- INFO -- Using dialect: org.hibernate.dialect.MySQLDialect
org.hibernate.transaction.TransactionFactoryFactory 2009-11-24 11:24:27,656 -- INFO -- Transaction strategy: org.hibernate.transaction.JTATransactionFactory
org.hibernate.util.NamingHelper 2009-11-24 11:24:27,656 -- INFO -- JNDI InitialContext properties:{}
org.hibernate.transaction.TransactionManagerLookupFactory 2009-11-24 11:24:27,671 -- INFO -- instantiating TransactionManagerLookup: org.springframework.orm.hibernate3.LocalTransactionManagerLookup
org.hibernate.transaction.TransactionManagerLookupFactory 2009-11-24 11:24:27,671 -- INFO -- instantiated TransactionManagerLookup
org.hibernate.transaction.TransactionManagerLookupFactory 2009-11-24 11:24:27,671 -- INFO -- instantiating TransactionManagerLookup: org.springframework.orm.hibernate3.LocalTransactionManagerLookup
org.hibernate.transaction.TransactionManagerLookupFactory 2009-11-24 11:24:27,671 -- INFO -- instantiated TransactionManagerLookup
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Automatic flush during beforeCompletion(): disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Automatic session close at end of transaction: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- JDBC batch size: 15
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- JDBC batch updates for versioned data: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Scrollable result sets: enabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- JDBC3 getGeneratedKeys(): enabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Connection release mode: auto
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Maximum outer join fetch depth: 2
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Default batch fetch size: 1
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Generate SQL with comments: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Order SQL updates by primary key: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Order SQL inserts for batching: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
org.hibernate.hql.ast.ASTQueryTranslatorFactory 2009-11-24 11:24:27,671 -- INFO -- Using ASTQueryTranslatorFactory
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Query language substitutions: {}
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- JPA-QL strict compliance: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Second-level cache: enabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Query cache: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Cache provider: org.hibernate.cache.NoCacheProvider
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Optimize cache for minimal puts: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Structured second-level cache entries: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Echoing all SQL to stdout
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Statistics: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Deleted entity synthetic identifier rollback: disabled
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Default entity-mode: pojo
org.hibernate.cfg.SettingsFactory 2009-11-24 11:24:27,671 -- INFO -- Named query checking : enabled
org.hibernate.impl.SessionFactoryImpl 2009-11-24 11:24:27,671 -- INFO -- building session factory
org.hibernate.impl.SessionFactoryObjectFactory 2009-11-24 11:24:27,671 -- INFO -- Not binding factory to JNDI, no JNDI name configured
org.hibernate.transaction.JTATransaction 2009-11-24 11:24:27,859 -- ERROR -- Could not find UserTransaction in JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:60)
at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:57)
at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:172)
at org.hibernate.impl.SessionImpl.checkTransactionSynchStatus(SessionImpl.java:1867)
at org.hibernate.impl.SessionImpl.getFlushMode(SessionImpl.java:1295)
at org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1184)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:696)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:694)
at com.xa.dao.User1DAO.save(User1DAO.java:34)
at com.xa.service.UserServiceDS.insertUser1(UserServiceDS.java:24)
at com.xa.service.UserServiceDS.insertBothUser(UserServiceDS.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy0.insertBothUser(Unknown Source)
at app.AppMain.main(AppMain.java:27)
com.xa.dao.User1DAO 2009-11-24 11:24:27,875 -- ERROR -- save failed
org.springframework.orm.hibernate3.HibernateSystemException: Could not find UserTransaction in JNDI: ; nested exception is org.hibernate.TransactionException: Could not find UserTransaction in JNDI:
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:676)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:694)
at com.xa.dao.User1DAO.save(User1DAO.java:34)
at com.xa.service.UserServiceDS.insertUser1(UserServiceDS.java:24)
at com.xa.service.UserServiceDS.insertBothUser(UserServiceDS.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy0.insertBothUser(Unknown Source)
at app.AppMain.main(AppMain.java:27)
Caused by: org.hibernate.TransactionException: Could not find UserTransaction in JNDI:
at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:64)
at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:57)
at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:172)
at org.hibernate.impl.SessionImpl.checkTransactionSynchStatus(SessionImpl.java:1867)
at org.hibernate.impl.SessionImpl.getFlushMode(SessionImpl.java:1295)
at org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1184)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:696)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
... 17 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:60)
... 24 more
Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: Could not find UserTransaction in JNDI: ; nested exception is org.hibernate.TransactionException: Could not find UserTransaction in JNDI:
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:676)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:694)
at com.xa.dao.User1DAO.save(User1DAO.java:34)
at com.xa.service.UserServiceDS.insertUser1(UserServiceDS.java:24)
at com.xa.service.UserServiceDS.insertBothUser(UserServiceDS.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy0.insertBothUser(Unknown Source)
at app.AppMain.main(AppMain.java:27)
Caused by: org.hibernate.TransactionException: Could not find UserTransaction in JNDI:
at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:64)
at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:57)
at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:172)
at org.hibernate.impl.SessionImpl.checkTransactionSynchStatus(SessionImpl.java:1867)
at org.hibernate.impl.SessionImpl.getFlushMode(SessionImpl.java:1295)
at org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1184)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:696)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
... 17 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:60)
... 24 more
나는 참조:
http://blog.csdn.net/soleghost/archive/2006/10/13/1332443.aspx
업무 관리를 할 때 오류를 보고할 수 있도록 설정했습니다. 저는 JOTM을 사용하지만 JNDI를 사용하고 싶지 않습니다.
===================
오랫동안 업데이트를 하지 못해서 죄송합니다.
다음 구성은 성공할 수 있습니다. 여러분은 다음을 참조하십시오.
<bean id="jotm" class="com....transaction.jta.JotmFactoryBean" />
<bean id="jotmTXManager" class="com....transaction.jta.JtaTransactionManager">
<property name="userTransaction" ref="jotm" />
</bean>
<bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource">
<property name="dataSource">
<bean class="org.enhydra.jdbc.standard.StandardXADataSource">
<property name="transactionManager" ref="jotm" />
<property name="driverName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="..." />
</bean>
</property>
</bean>
<bean id="dataSource2" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource">
<property name="dataSource">
<bean class="org.enhydra.jdbc.standard.StandardXADataSource">
<property name="transactionManager" ref="jotm" />
<property name="driverName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@...:1521:..." />
</bean>
</property>
</bean>
<bean id="sessFactory1" class="com......LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingLocations">
<list>
<value>classpath:com/**/*.hbm.xml</value>
</list>
</property>
</bean>
<bean id="sessFactory2" class="com.....LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingLocations">
<list>
<value>classpath:com/**/*.hbm.xml</value>
</list>
</property>
</bean>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
JNDI 요약오늘은 그 줄이 움직인 줄도 모르고 JNDI를 씹기 시작했다.문구에 구애받지 않는다고 말하는 것은 사실 겉만 번지르하고 깊이가 없다.독서 노트로 삼다. 젠디 이거 뭐 하는 거예요?EJB, RMI-IIOP은 모두 그것...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.