Atomikos Forum |
|
i get the below error message :
c.atomikos.jdbc.AtomikosSQLException - Cannot initialize AtomikosDataSourceBean javax.naming.NamingException: Another resource already exists with name oracle - pick a different name at com.atomikos.util.IntraVmObjectFactory.createReference(IntraVmObjectFactory.java:94) ~[atomikos-util-3.9.0.jar:na] at com.atomikos.jdbc.AbstractDataSourceBean.getReference(AbstractDataSourceBean.java:388) ~[transactions-jdbc-3.9.0.jar:na] at com.atomikos.jdbc.AbstractDataSourceBean.init(AbstractDataSourceBean.java:295) ~[transactions-jdbc-3.9.0.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_05] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_05] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_05] at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_05] my configuration are below <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:camel="http://camel.apache.org/schema/spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <!-- Scans the classpath for annotated components --> <context:component-scan base-package="com.qcsd.service" /> <context:annotation-config></context:annotation-config> <!-- Create proxy instances of Repository interfaces --> <jpa:repositories base-package="com.qcsd.repositery" repository-impl-postfix="Impl" /> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> <!-- Annotation driven transactions --> <tx:annotation-driven transaction-manager="transactionManager" /> <tx:jta-transaction-manager /> <!-- camel --> <camel:camelContext> <!-- let Camel use those @Component scanned route builders --> <camel:contextScan /> </camel:camelContext> <!-- Atomikos JTA transaction manager --> <bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp" init-method="init" destroy-method="shutdownForce"> <constructor-arg> <!-- IMPORTANT: specify all Atomikos properties here --> <props> <prop key="com.atomikos.icatch.service"> com.atomikos.icatch.standalone.UserTransactionServiceFactory </prop> </props> </constructor-arg> </bean> <bean class="com.atomikos.icatch.jta.UserTransactionManager" id="atomikosTransactionManager" init-method="init" destroy-method="close"> <property name="forceShutdown" value="false" /> </bean> <bean class="com.atomikos.icatch.jta.J2eeUserTransaction" id="atomikosUserTransaction"> <property name="transactionTimeout" value="300" /> </bean> <!-- Construct Atomikos UserTransactionManager, needed to configure Spring --> <bean id="AtomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close" depends-on="userTransactionService"> <!-- IMPORTANT: disable startup because the userTransactionService above does this --> <property name="startupTransactionService" value="false" /> <!-- when close is called, should we force transactions to terminate or not? --> <property name="forceShutdown" value="false" /> </bean> <!-- Also use Atomikos UserTransactionImp, needed to configure Spring --> <bean id="AtomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp" depends-on="userTransactionService"> <property name="transactionTimeout" value="300" /> </bean> <!-- Configure the Spring framework to use JTA transactions from Atomikos --> <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" depends-on="userTransactionService"> <property name="transactionManager" ref="AtomikosTransactionManager" /> <property name="userTransaction" ref="AtomikosUserTransaction" /> </bean> <!-- JPA --> <bean id="dataSource2" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close"> <property name="uniqueResourceName"> <value>oracle</value> </property> <property name="xaDataSourceClassName" value="oracle.jdbc.xa.client.OracleXADataSource" /> <property name="xaProperties"> <props> <prop key="URL">jdbc:oracle:thin:@localhost:1521:orcl</prop> <prop key="user">user</prop> <prop key="password">pass</prop> </props> </property> <property name="poolSize"> <value>10</value> </property> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <!-- Entity annotation scan --> <property name="packagesToScan" value="com.qcsd.model" /> <!-- Data source (H2) --> <property name="jtaDataSource" ref="dataSource2"> </property> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /> </property> <property name="jpaProperties"> <props> <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory </prop> <prop key="hibernate.current_session_context_class">jta</prop> <!-- Setup Hibernate to participate in the Atomikos transaction --> <prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup </prop> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop> </props> </property> </bean> <!-- ActiveMQ connection factory --> <!-- JTA/XA-enabled JMS --> <bean id="atomikosJmsConnectionFactory2" class="com.atomikos.jms.AtomikosConnectionFactoryBean"> <property name="uniqueResourceName"> <value>ACtivemQXA</value> </property> <property name="poolSize"> <value>5</value> </property> <property name="maxPoolSize"> <value>12</value> </property> <property name="xaConnectionFactory"> <bean class="org.apache.activemq.ActiveMQXAConnectionFactory"> <property name="brokerURL" value="tcp://localhost:61616" /> </bean> </property> </bean> <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory" ref="atomikosJmsConnectionFactory2" /> <property name="receiveTimeout" value="2000" /> <!-- "sessionTransacted" has to be set to "true" to start an transaction for every incoming JMS message --> <property name="sessionTransacted" value="true" /> <!-- sessionAcknowledgeMode has to be set to javax.jms.Session.SESSION_TRANSACTED --> <property name="sessionAcknowledgeMode" value="0" /> </bean> <bean id="jms" class="org.apache.camel.component.jms.JmsComponent"> <property name="configuration" ref="jmsConfig" /> </bean> <bean id="activeMq" class="org.apache.activemq.camel.component.ActiveMQComponent"> <property name="configuration" ref="jmsConfig"></property> </bean> <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration"> <property name="connectionFactory" ref="atomikosJmsConnectionFactory2" /> <property name="transactionManager" ref="transactionManager" /> <!-- 'transacted' must be set to false for XA transactions. The name of this property is misleading. What it really indicates is whether or not the Camel JMS component supports local transactions --> <property name="transacted" value="true" /> <property name="cacheLevelName" value="CACHE_NONE" /> </bean> </beans> |