Atomikos Forum

Error creating bean with name 'dataSource'

We have implemented atomikos essential with spring,jpa project in tomcat. We tried the same with atomikos extreme self-support build but it gives exception as javax.naming.NameNotFoundException: Name [jdbc/testDS] is not bound in this Context. Unable to find [jdbc]

Stack trace
---------

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\Testapp\WEB-INF\classes\META-INF\spring\applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name [jdbc/testDS] is not bound in this Context. Unable to find [jdbc].
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1045)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:824)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4793)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5236)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Manas De Send private email
Thursday, March 03, 2016
 
 
Hi,

If it works in TransactionsEssentials open source then it should work even better in ExtremeTransactions because it contains the same classes + bug fixes + power integrations like Tomcat.

In other words: there is nothing built into ExtremeTransactions that would prevent it from working with TransactionsEssentials configurations.

Best
Guy Pardon Send private email
Thursday, March 03, 2016
 
 
Did you make sure this JNDI reference is bound in server.xml or context.xml of Tomcat with the correct name? Can you provide the definition here to have a look?
Torsten Krah Send private email
Friday, March 04, 2016
 
 
Below are the changes we did for atomikos implementation
-----------

1) In web.xml
<resource-ref>
        <description>Test Datasource </description>
        <res-ref-name>jdbc/testDS</res-ref-name>
        <res-type>javax.sql.XADataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>


2) In spring application context we gave following entry for atomikos
<!-- jndi lookup -->
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/testDS" />

<!-- Other atomikos changes --->

<bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp"
      init-method="init" destroy-method="shutdownForce">
        <constructor-arg>
            <props>
                <prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop>
                <prop key="com.atomikos.icatch.tm_unique_name">testapp</prop>
                <prop key="com.atomikos.icatch.log_base_name">tmlog1</prop>
                <prop key="com.atomikos.icatch.log_base_dir">c:/log/testapp</prop>
                <prop key="com.atomikos.icatch.max_timeout">10800000</prop>
                <prop key="com.atomikos.icatch.default_jta_timeout">10800000</prop>
                <prop key="com.atomikos.icatch.max_actives">-1</prop>
                <!-- DEBUGGING PROPERTIES -->
                <prop key="com.atomikos.icatch.output_dir">c:/log/testapp</prop>
                <prop key="com.atomikos.icatch.console_file_name">atomikos1.log</prop>
                <prop key="com.atomikos.icatch.console_log_level">WARN</prop>
                <prop key="com.atomikos.icatch.threaded_2pc">true</prop>
            </props>
        </constructor-arg>
     
    </bean>
    <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
        depends-on="userTransactionService" />

    <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"
        depends-on="userTransactionService">
        <property name="transactionTimeout" value="10800000" />
    </bean>
    
     <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"
          depends-on="atomikosTransactionManager,atomikosUserTransaction">
            <property name="transactionManager" ref="atomikosTransactionManager" />
            <property name="userTransaction" ref="atomikosUserTransaction" />
            <property name="allowCustomIsolationLevels" value="true" />
     </bean>

3) In tomcat context.xml file
<Transaction factory="com.atomikos.icatch.jta.UserTransactionFactory" />
 
      <Resource name="TransactionManager"
            auth="Container"
            type="com.atomikos.icatch.jta.UserTransactionManager"
            factory="org.apache.naming.factory.BeanFactory" />
           
      <Loader  loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"
          useSystemClassLoaderAsParent="false"/>

 <Resource name="jdbc/testDS"
            auth="Container"
            type="com.atomikos.jdbc.AtomikosDataSourceBean"
            factory="com.atomikos.tomcat.EnhancedTomcatAtomikosBeanFactory"
            uniqueResourceName="jdbc/testDS"
              defaultIsolationLevel="1"
            minPoolSize = "1"
            maxPoolSize = "20"
            xaDataSourceClassName="com.sybase.jdbc4.jdbc.SybXADataSource"
            xaProperties.databaseName="test"         
            xaProperties.serverName = "xx.xx.xx.xx"
            xaProperties.portNumber = "xxxx"
            xaProperties.user = "test"
            xaProperties.password = "test"
            poolSize="20"
            />

4) In server.xml of tomcat
<Listener className="com.atomikos.tomcat.AtomikosLifecycleListener"/>


1) In web.xml
<resource-ref>
        <description>Test Datasource </description>
        <res-ref-name>jdbc/testDS</res-ref-name>
        <res-type>javax.sql.XADataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>


2) In spring application context we gave following entry for atomikos
<!-- jndi lookup -->
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/testDS" />

<!-- Other atomikos changes --->

<bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp"
      init-method="init" destroy-method="shutdownForce">
        <constructor-arg>
            <props>
                <prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop>
                <prop key="com.atomikos.icatch.tm_unique_name">testapp</prop>
                <prop key="com.atomikos.icatch.log_base_name">tmlog1</prop>
                <prop key="com.atomikos.icatch.log_base_dir">c:/log/testapp</prop>
                <prop key="com.atomikos.icatch.max_timeout">10800000</prop>
                <prop key="com.atomikos.icatch.default_jta_timeout">10800000</prop>
                <prop key="com.atomikos.icatch.max_actives">-1</prop>
                <!-- DEBUGGING PROPERTIES -->
                <prop key="com.atomikos.icatch.output_dir">c:/log/testapp</prop>
                <prop key="com.atomikos.icatch.console_file_name">atomikos1.log</prop>
                <prop key="com.atomikos.icatch.console_log_level">WARN</prop>
                <prop key="com.atomikos.icatch.threaded_2pc">true</prop>
            </props>
        </constructor-arg>
     
    </bean>
    <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
        depends-on="userTransactionService" />

    <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp"
        depends-on="userTransactionService">
        <property name="transactionTimeout" value="10800000" />
    </bean>
    
     <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"
          depends-on="atomikosTransactionManager,atomikosUserTransaction">
            <property name="transactionManager" ref="atomikosTransactionManager" />
            <property name="userTransaction" ref="atomikosUserTransaction" />
            <property name="allowCustomIsolationLevels" value="true" />
     </bean>

3) In tomcat context.xml file
<Transaction factory="com.atomikos.icatch.jta.UserTransactionFactory" />
 
      <Resource name="TransactionManager"
            auth="Container"
            type="com.atomikos.icatch.jta.UserTransactionManager"
            factory="org.apache.naming.factory.BeanFactory" />
           
      <Loader  loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"
          useSystemClassLoaderAsParent="false"/>

 <Resource name="jdbc/testDS"
            auth="Container"
            type="com.atomikos.jdbc.AtomikosDataSourceBean"
            factory="com.atomikos.tomcat.EnhancedTomcatAtomikosBeanFactory"
            uniqueResourceName="jdbc/testDS"
              defaultIsolationLevel="1"
            minPoolSize = "1"
            maxPoolSize = "20"
            xaDataSourceClassName="com.sybase.jdbc4.jdbc.SybXADataSource"
            xaProperties.databaseName="test"         
            xaProperties.serverName = "xx.xx.xx.xx"
            xaProperties.portNumber = "xxxx"
            xaProperties.user = "test"
            xaProperties.password = "test"
            poolSize="20"
            />

4) In server.xml of tomcat
<Listener className="com.atomikos.tomcat.AtomikosLifecycleListener"/>


=====================================
Instead of jndi call if we direcly configure datasource
<bean id="dataSource"
        class="com.atomikos.jdbc.AtomikosDataSourceBean">
        <property name="minPoolSize" value="1" />
        <property name="maxPoolSize" value="20"/>
        <property name="poolSize" value="20"/>
        <property name="defaultIsolationLevel" value="1"/>
        <property name="xaDataSourceClassName" value="com.sybase.jdbc4.jdbc.SybXADataSource" />
        <property name="uniqueResourceName" value="jdbc/testDS"/>
        <property name="xaProperties">
            <props>
                <prop key="databaseName">test</prop>
                <prop key="serverName">xx.xx.xx.xx.</prop>
                <prop key="portNumber">xxxx</prop>
                <prop key="user">test</prop>
                <prop key="password">test</prop>
            </props>
        </property>
    </bean>


then connection got established but it gives below error
===========================
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.atomikos.icatch.jta.UserTransactionManager' to required type 'javax.transaction.TransactionManager' for property 'transactionManager'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.atomikos.icatch.jta.UserTransactionManager] to required type [javax.transaction.TransactionManager] for property 'transactionManager': no matching editors or conversion strategy found
    at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:591)
    at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:603)
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:204)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1486)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    ... 20 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [com.atomikos.icatch.jta.UserTransactionManager] to required type [javax.transaction.TransactionManager] for property 'transactionManager': no matching editors or conversion strategy found
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:302)
    at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:576)
    ... 26 more
============

kindly guide us to solve this problem
Manas De Send private email
Saturday, March 05, 2016
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics