available resources: [] at bitronix.tm.resource.ResourceObjectFactory.getObjectInstance(ResourceObjectFactory.java:57)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

available resources: [] at bitronix.tm.resource.ResourceObjectFactory.getObjectInstance(ResourceObjectFactory.java:57)

Szymon Tarnowski
Hi, first of all sorry for my english. I hope that every one will understand what i'm writting :). I try to integrate Spring  3.0.6 Hibernate 3.6.7, JPA 2 and Tomcat 6.0.35 and BTM 2.2.1. I try to integrate this base on http://docs.codehaus.org/display/BTM/Hibernate2x (verified against BTM 2.1.1),
http://docs.codehaus.org/display/BTM/Spring+Framework2x (verified against BTM 2.0.1.), http://docs.codehaus.org/display/BTM/Tomcat2x (verified against BTM 2.1.0.)
persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
        xmlns="http://java.sun.com/xml/ns/persistence">
        <persistence-unit name="myPU"
                transaction-type="JTA">
                <provider>org.hibernate.ejb.HibernatePersistence</provider>
                <jta-data-source>jdbc/db-resource</jta-data-source>
                <class>my.package.FileUploadToken</class>
                <class>my.package.FileDownloadToken</class>
                <class>my.package.UserToken</class>
                <properties>
                        <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" />
                        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
                        <property name="hibernate.show.sql" value="true" />
                        <property name="hibernate.hbm2ddl.auto" value="update" />
                        <property name="hibernate.connection.autocommit" value="false" />
                       
                        <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
                        <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
                        <property name="hibernate.jndi.class" value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
                </properties>
        </persistence-unit>
</persistence>

spring-context.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
        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-3.0.xsd
               http://www.springframework.org/schema/tx
               http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-3.0.xsd">

        <context:annotation-config />
        <context:component-scan base-package="my.package" />

        <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
                <property name="jndiName" value="java:comp/env/jdbc/db-resource" />
                <property name="resourceRef" value="true" />
        </bean>
        <bean id="entityManagerFactory"
                class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                <property name="persistenceUnitName" value="myPU" />
                <property name="dataSource" ref="dataSource" />
        </bean>

       
        <bean id="btmConfig" factory-method="getConfiguration"
                class="bitronix.tm.TransactionManagerServices">
                <property name="serverId" value="spring-btm" />
        </bean>

       
        <bean id="BitronixTransactionManager" factory-method="getTransactionManager"
                class="bitronix.tm.TransactionManagerServices" depends-on="btmConfig"
                destroy-method="shutdown" />

       
        <bean id="transactionManager"
                class="org.springframework.transaction.jta.JtaTransactionManager">
                <property name="autodetectTransactionManager" value="false" />
                <property name="transactionManager" ref="BitronixTransactionManager" />
                <property name="userTransaction" ref="BitronixTransactionManager" />
        </bean>

        <bean
                class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
        <bean
                class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />


        <tx:annotation-driven />
        <tx:jta-transaction-manager id="transactionManager" />

</beans>

webapp/META-INF/context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context >

       
</Context>

web.xml:

<web-app id="WebApp_ID" version="2.4"
        xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
        <display-name>Restful Web Application</display-name>

        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/spring-context.xml</param-value>
        </context-param>

        <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

        <persistence-unit-ref>
                <persistence-unit-ref-name>persistence/myPU</persistence-unit-ref-name>
                <persistence-unit-name>myPU</persistence-unit-name>
        </persistence-unit-ref>

        <resource-env-ref>
                <resource-env-ref-name>jdbc/db-resource</resource-env-ref-name>
                <resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
                <res-auth>Container</res-auth>
        </resource-env-ref>
</webapp>

resources.properties:

resource.ds1.className=bitronix.tm.resource.jdbc.lrc.LrcXADataSource
resource.ds1.uniqueName=jdbc/db-resource
resource.ds1.minPoolSize=0
resource.ds1.maxPoolSize=5
resource.ds1.allowLocalTransactions=true
resource.ds1.driverProperties.driverClassName=com.mysql.jdbc.Driver
resource.ds1.driverProperties.user=dbUser
resource.ds1.driverProperties.password=*****
resource.ds1.driverProperties.url=jdbc:mysql://localhost:3306/myDb

btm-config.properties
bitronix.tm.serverId=spring-btm
bitronix.tm.journal.disk.logPart1Filename=${btm.root}/work/btm1.tlog
bitronix.tm.journal.disk.logPart2Filename=${btm.root}/work/btm2.tlog
bitronix.tm.resource.configuration=${btm.root}/conf/resources.properties

TOMCAT_BASE/conf/context.xml
<?xml version='1.0' encoding='utf-8'?>

<Context>



   

    <WatchedResource>WEB-INF/web.xml</WatchedResource>

       

        <Transaction factory="bitronix.tm.BitronixUserTransactionObjectFactory" />

        <Resource name="jdbc/db-resource" auth="Container" type="javax.sql.DataSource"

        factory="bitronix.tm.resource.ResourceObjectFactory" uniqueName="jdbc/db-resource"

        allowLocalTransactions="true" />

</Context>

I also have set properties in conf/server.xml and bin/setenv.sh

Now i get this stack:

ERROR [main] (ContextLoader.java227) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in class path resource [vidi-server-persistence-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [vidi-server-persistence-context.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' defined in class path resource [vidi-server-persistence-context.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: no resource registered with uniqueName 'jdbc/db-resource', available resources: []
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
        at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
        at org.apache.catalina.core.StandardService.start(StandardService.java:525)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
        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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [vidi-server-persistence-context.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' defined in class path resource [vidi-server-persistence-context.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: no resource registered with uniqueName 'jdbc/db-resource', available resources: []
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
        at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
        at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
        at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1439)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1408)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        ... 34 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [vidi-server-persistence-context.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: no resource registered with uniqueName 'jdbc/db-resource', available resources: []
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
        ... 52 more
Caused by: javax.naming.NamingException: no resource registered with uniqueName 'jdbc/db-resource', available resources: []
        at bitronix.tm.resource.ResourceObjectFactory.getObjectInstance(ResourceObjectFactory.java:57)
        at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
        at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
        at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
        at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
        at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
        at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
        ... 59 more

Now, i have no idea why no resource hasn't registered? If you have some idea's what am i doing wrong i will be glad :).


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: available resources: [] at bitronix.tm.resource.ResourceObjectFactory.getObjectInstance(ResourceObjectFactory.java:57)

Ludovic Orban-2
The "NamingException: no resource registered with uniqueName 'jdbc/db-resource', available resources: []" error clearly indicates that no resource was registered in BTM, apparently because your configuration was ignored one way or another.

Looking closer at the details you posted I have the feeling that you mixed a bit the application server and application config styles.

There are two ways to use BTM with Tomcat. The first one is to fully embed it in your web app and not make any reference to the app server at all, and the second is to integrate it in Tomcat and only reference the TM and pools from your web app via JNDI.

The former option is the most used one as it doesn't require you to change Tomcat's system config files. It is easier to setup using Spring as everything you need to do can be expressed in a Spring config. In that case, avoid using the properties config files and directly make calls to the API instead as described in http://docs.codehaus.org/display/BTM/Spring+Framework2x .

2012/2/16 Szymon Tarnowski <[hidden email]>

Hi, first of all sorry for my english. I hope that every one will understand
what i'm writting :). I try to integrate Spring  3.0.6 Hibernate 3.6.7, JPA
2 and Tomcat 6.0.35 and BTM 2.2.1. I try to integrate this base on
http://docs.codehaus.org/display/BTM/Hibernate2x (verified against BTM
2.1.1),
http://docs.codehaus.org/display/BTM/Spring+Framework2x (verified against
BTM 2.0.1.), http://docs.codehaus.org/display/BTM/Tomcat2x (verified against
BTM 2.1.0.)
persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
       xmlns="http://java.sun.com/xml/ns/persistence">
       <persistence-unit name="myPU"
               transaction-type="JTA">
               <provider>org.hibernate.ejb.HibernatePersistence</provider>
               <jta-data-source>jdbc/db-resource</jta-data-source>
               <class>my.package.FileUploadToken</class>
               <class>my.package.FileDownloadToken</class>
               <class>my.package.UserToken</class>
               <properties>
                       <property name="hibernate.cache.provider_class"
value="org.hibernate.cache.NoCacheProvider" />
                       <property name="hibernate.dialect"
value="org.hibernate.dialect.MySQL5InnoDBDialect" />
                       <property name="hibernate.show.sql" value="true" />
                       <property name="hibernate.hbm2ddl.auto" value="update" />
                       <property name="hibernate.connection.autocommit" value="false" />
                       <!-- Bitronix configuration -->
                       <property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
                       <property name="hibernate.transaction.factory_class"
value="org.hibernate.transaction.JTATransactionFactory"/>
                       <property name="hibernate.jndi.class"
value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
               </properties>
       </persistence-unit>
</persistence>

spring-context.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
       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-3.0.xsd
              http://www.springframework.org/schema/tx
              http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
              http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd">

       <context:annotation-config />
       <context:component-scan base-package="my.package" />

       <bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
               <property name="jndiName" value="java:comp/env/jdbc/db-resource" />
               <property name="resourceRef" value="true" />
       </bean>
       <bean id="entityManagerFactory"

class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
               <property name="persistenceUnitName" value="myPU" />
               <property name="dataSource" ref="dataSource" />
       </bean>

       <!--  Bitronix Transaction Manager embedded configuration -->
       <bean id="btmConfig" factory-method="getConfiguration"
               class="bitronix.tm.TransactionManagerServices">
               <property name="serverId" value="spring-btm" />
       </bean>

       <!-- create BTM transaction manager -->
       <bean id="BitronixTransactionManager"
factory-method="getTransactionManager"
               class="bitronix.tm.TransactionManagerServices" depends-on="btmConfig"
               destroy-method="shutdown" />

       <!-- Spring JtaTransactionManager -->
       <bean id="transactionManager"
               class="org.springframework.transaction.jta.JtaTransactionManager">
               <property name="autodetectTransactionManager" value="false" />
               <property name="transactionManager" ref="BitronixTransactionManager" />
               <property name="userTransaction" ref="BitronixTransactionManager" />
       </bean>

       <bean

class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"
/>
       <bean

class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"
/>


       <tx:annotation-driven />
       <tx:jta-transaction-manager id="transactionManager" />

</beans>

webapp/META-INF/context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context >

       <!-- Empty -->
</Context>

web.xml:

<web-app id="WebApp_ID" version="2.4"
       xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
       http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
       <display-name>Restful Web Application</display-name>

       <context-param>
               <param-name>contextConfigLocation</param-name>
               <param-value>/WEB-INF/spring-context.xml</param-value>
       </context-param>

       <listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
       </listener>

       <persistence-unit-ref>
               <persistence-unit-ref-name>persistence/myPU</persistence-unit-ref-name>
               <persistence-unit-name>myPU</persistence-unit-name>
       </persistence-unit-ref>

       <resource-env-ref>
               <resource-env-ref-name>jdbc/db-resource</resource-env-ref-name>
               <resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
               <res-auth>Container</res-auth>
       </resource-env-ref>
</webapp>

resources.properties:

resource.ds1.className=bitronix.tm.resource.jdbc.lrc.LrcXADataSource
resource.ds1.uniqueName=jdbc/db-resource
resource.ds1.minPoolSize=0
resource.ds1.maxPoolSize=5
resource.ds1.allowLocalTransactions=true
resource.ds1.driverProperties.driverClassName=com.mysql.jdbc.Driver
resource.ds1.driverProperties.user=dbUser
resource.ds1.driverProperties.password=*****
resource.ds1.driverProperties.url=jdbc:mysql://localhost:3306/myDb

btm-config.properties
bitronix.tm.serverId=spring-btm
bitronix.tm.journal.disk.logPart1Filename=${btm.root}/work/btm1.tlog
bitronix.tm.journal.disk.logPart2Filename=${btm.root}/work/btm2.tlog
bitronix.tm.resource.configuration=${btm.root}/conf/resources.properties

TOMCAT_BASE/conf/context.xml
<?xml version='1.0' encoding='utf-8'?>

<Context>



   <!-- Default set of monitored resources -->

   <WatchedResource>WEB-INF/web.xml</WatchedResource>

       <!-- Bitronix configuration -->

       <Transaction factory="bitronix.tm.BitronixUserTransactionObjectFactory" />

       <Resource name="jdbc/db-resource" auth="Container"
type="javax.sql.DataSource"

       factory="bitronix.tm.resource.ResourceObjectFactory"
uniqueName="jdbc/db-resource"

       allowLocalTransactions="true" />

</Context>

I also have set properties in conf/server.xml and bin/setenv.sh

Now i get this stack:

ERROR [main] (ContextLoader.java227) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name
'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0'
defined in class path resource [vidi-server-persistence-context.xml]:
Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'entityManagerFactory' defined in class path resource
[vidi-server-persistence-context.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' defined in class path resource
[vidi-server-persistence-context.xml]: Invocation of init method failed;
nested exception is javax.naming.NamingException: no resource registered
with uniqueName 'jdbc/db-resource', available resources: []
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
       at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
       at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
       at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
       at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
       at
org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
       at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
       at
org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
       at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
       at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
       at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
       at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
       at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
       at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
       at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
       at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
       at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
       at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
       at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
       at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
       at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
       at org.apache.catalina.core.StandardService.start(StandardService.java:525)
       at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
       at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
       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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'entityManagerFactory' defined in class path
resource [vidi-server-persistence-context.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' defined in class path resource
[vidi-server-persistence-context.xml]: Invocation of init method failed;
nested exception is javax.naming.NamingException: no resource registered
with uniqueName 'jdbc/db-resource', available resources: []
       at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
       at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
       at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
       at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
       at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
       at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
       at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
       at
org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
       at
org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
       at
org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
       at
org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
       at
org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1439)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1408)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
       ... 34 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dataSource' defined in class path resource
[vidi-server-persistence-context.xml]: Invocation of init method failed;
nested exception is javax.naming.NamingException: no resource registered
with uniqueName 'jdbc/db-resource', available resources: []
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
       at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
       at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
       at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
       at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
       at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
       ... 52 more
Caused by: javax.naming.NamingException: no resource registered with
uniqueName 'jdbc/db-resource', available resources: []
       at
bitronix.tm.resource.ResourceObjectFactory.getObjectInstance(ResourceObjectFactory.java:57)
       at
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
       at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
       at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
       at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
       at javax.naming.InitialContext.lookup(InitialContext.java:392)
       at
org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
       at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
       at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
       at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
       at
org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
       at
org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
       at
org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
       at
org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
       ... 59 more

Now, i have no idea why no resource hasn't registered? If you have some
idea's what am i doing wrong i will be glad :).



--
View this message in context: http://old.nabble.com/available-resources%3A----%09at-bitronix.tm.resource.ResourceObjectFactory.getObjectInstance%28ResourceObjectFactory.java%3A57%29-tp33337287p33337287.html
Sent from the Bitronix Transaction Manager mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: available resources: [] at bitronix.tm.resource.ResourceObjectFactory.getObjectInstance(ResourceObjectFactory.java:57)

Szymon Tarnowski
Thanks for replay, you are prabobly right and i mixed too much with configuration. Unfortunetly i didn't have much and i tried my luck with atomiks (but still you're doing great job with bitronix).

Ludovic Orban-2 wrote
The "NamingException: no resource registered with uniqueName
'jdbc/db-resource', available resources: []" error clearly indicates that
no resource was registered in BTM, apparently because your configuration
was ignored one way or another.

Looking closer at the details you posted I have the feeling that you mixed
a bit the application server and application config styles.

There are two ways to use BTM with Tomcat. The first one is to fully embed
it in your web app and not make any reference to the app server at all, and
the second is to integrate it in Tomcat and only reference the TM and pools
from your web app via JNDI.

The former option is the most used one as it doesn't require you to change
Tomcat's system config files. It is easier to setup using Spring as
everything you need to do can be expressed in a Spring config. In that
case, avoid using the properties config files and directly make calls to
the API instead as described in
http://docs.codehaus.org/display/BTM/Spring+Framework2x .

2012/2/16 Szymon Tarnowski <szymon272@gmail.com>

>
> Hi, first of all sorry for my english. I hope that every one will
> understand
> what i'm writting :). I try to integrate Spring  3.0.6 Hibernate 3.6.7, JPA
> 2 and Tomcat 6.0.35 and BTM 2.2.1. I try to integrate this base on
> http://docs.codehaus.org/display/BTM/Hibernate2x (verified against BTM
> 2.1.1),
> http://docs.codehaus.org/display/BTM/Spring+Framework2x (verified against
> BTM 2.0.1.), http://docs.codehaus.org/display/BTM/Tomcat2x (verified
> against
> BTM 2.1.0.)
> persistence.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="1.0"
>        xmlns="http://java.sun.com/xml/ns/persistence">
>        <persistence-unit name="myPU"
>                transaction-type="JTA">
>                <provider>org.hibernate.ejb.HibernatePersistence</provider>
>                <jta-data-source>jdbc/db-resource</jta-data-source>
>                <class>my.package.FileUploadToken</class>
>                <class>my.package.FileDownloadToken</class>
>                <class>my.package.UserToken</class>
>                <properties>
>                        <property name="hibernate.cache.provider_class"
> value="org.hibernate.cache.NoCacheProvider" />
>                        <property name="hibernate.dialect"
> value="org.hibernate.dialect.MySQL5InnoDBDialect" />
>                        <property name="hibernate.show.sql" value="true" />
>                        <property name="hibernate.hbm2ddl.auto"
> value="update" />
>                        <property name="hibernate.connection.autocommit"
> value="false" />
>                        
>                        <property
> name="hibernate.transaction.manager_lookup_class"
> value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
>                        <property name="hibernate.transaction.factory_class"
> value="org.hibernate.transaction.JTATransactionFactory"/>
>                        <property name="hibernate.jndi.class"
> value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
>                </properties>
>        </persistence-unit>
> </persistence>
>
> spring-context.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:context="http://www.springframework.org/schema/context"
> xmlns:tx="http://www.springframework.org/schema/tx"
>        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-3.0.xsd
>               http://www.springframework.org/schema/tx
>               http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
>               http://www.springframework.org/schema/context
>
> http://www.springframework.org/schema/context/spring-context-3.0.xsd">
>
>        <context:annotation-config />
>        <context:component-scan base-package="my.package" />
>
>        <bean id="dataSource"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>                <property name="jndiName"
> value="java:comp/env/jdbc/db-resource" />
>                <property name="resourceRef" value="true" />
>        </bean>
>        <bean id="entityManagerFactory"
>
> class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
>                <property name="persistenceUnitName" value="myPU" />
>                <property name="dataSource" ref="dataSource" />
>        </bean>
>
>        
>        <bean id="btmConfig" factory-method="getConfiguration"
>                class="bitronix.tm.TransactionManagerServices">
>                <property name="serverId" value="spring-btm" />
>        </bean>
>
>        
>        <bean id="BitronixTransactionManager"
> factory-method="getTransactionManager"
>                class="bitronix.tm.TransactionManagerServices"
> depends-on="btmConfig"
>                destroy-method="shutdown" />
>
>        
>        <bean id="transactionManager"
>
>  class="org.springframework.transaction.jta.JtaTransactionManager">
>                <property name="autodetectTransactionManager" value="false"
> />
>                <property name="transactionManager"
> ref="BitronixTransactionManager" />
>                <property name="userTransaction"
> ref="BitronixTransactionManager" />
>        </bean>
>
>        <bean
>
>
> class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"
> />
>        <bean
>
>
> class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"
> />
>
>
>        <tx:annotation-driven />
>        <tx:jta-transaction-manager id="transactionManager" />
>
> </beans>
>
> webapp/META-INF/context.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Context >
>
>        
> </Context>
>
> web.xml:
>
> <web-app id="WebApp_ID" version="2.4"
>        xmlns="http://java.sun.com/xml/ns/j2ee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>        <display-name>Restful Web Application</display-name>
>
>        <context-param>
>                <param-name>contextConfigLocation</param-name>
>                <param-value>/WEB-INF/spring-context.xml</param-value>
>        </context-param>
>
>        <listener>
>
>
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>        </listener>
>
>        <persistence-unit-ref>
>
>  <persistence-unit-ref-name>persistence/myPU</persistence-unit-ref-name>
>                <persistence-unit-name>myPU</persistence-unit-name>
>        </persistence-unit-ref>
>
>        <resource-env-ref>
>
>  <resource-env-ref-name>jdbc/db-resource</resource-env-ref-name>
>
>  <resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
>                <res-auth>Container</res-auth>
>        </resource-env-ref>
> </webapp>
>
> resources.properties:
>
> resource.ds1.className=bitronix.tm.resource.jdbc.lrc.LrcXADataSource
> resource.ds1.uniqueName=jdbc/db-resource
> resource.ds1.minPoolSize=0
> resource.ds1.maxPoolSize=5
> resource.ds1.allowLocalTransactions=true
> resource.ds1.driverProperties.driverClassName=com.mysql.jdbc.Driver
> resource.ds1.driverProperties.user=dbUser
> resource.ds1.driverProperties.password=*****
> resource.ds1.driverProperties.url=jdbc:mysql://localhost:3306/myDb
>
> btm-config.properties
> bitronix.tm.serverId=spring-btm
> bitronix.tm.journal.disk.logPart1Filename=${btm.root}/work/btm1.tlog
> bitronix.tm.journal.disk.logPart2Filename=${btm.root}/work/btm2.tlog
> bitronix.tm.resource.configuration=${btm.root}/conf/resources.properties
>
> TOMCAT_BASE/conf/context.xml
> <?xml version='1.0' encoding='utf-8'?>
>
> <Context>
>
>
>
>    
>
>    <WatchedResource>WEB-INF/web.xml</WatchedResource>
>
>        
>
>        <Transaction
> factory="bitronix.tm.BitronixUserTransactionObjectFactory" />
>
>        <Resource name="jdbc/db-resource" auth="Container"
> type="javax.sql.DataSource"
>
>        factory="bitronix.tm.resource.ResourceObjectFactory"
> uniqueName="jdbc/db-resource"
>
>        allowLocalTransactions="true" />
>
> </Context>
>
> I also have set properties in conf/server.xml and bin/setenv.sh
>
> Now i get this stack:
>
> ERROR [main] (ContextLoader.java227) - Context initialization failed
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean
> with name
>
> 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0'
> defined in class path resource [vidi-server-persistence-context.xml]:
> Initialization of bean failed; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean
> with name 'entityManagerFactory' defined in class path resource
> [vidi-server-persistence-context.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' defined in class path resource
> [vidi-server-persistence-context.xml]: Invocation of init method failed;
> nested exception is javax.naming.NamingException: no resource registered
> with uniqueName 'jdbc/db-resource', available resources: []
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
>        at
>
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
>        at
>
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
>        at
>
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
>        at
>
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
>        at
>
> org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
>        at
>
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
>        at
>
> org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282)
>        at
>
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204)
>        at
>
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
>        at
>
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
>        at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
>        at
>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
>        at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
>        at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
>        at
> org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
>        at
> org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
>        at
> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
>        at
> org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
>        at
> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
>        at
>
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
>        at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
>        at
> org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
>        at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
>        at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
>        at
> org.apache.catalina.core.StandardService.start(StandardService.java:525)
>        at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
>        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
>        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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
>        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'entityManagerFactory' defined in class path
> resource [vidi-server-persistence-context.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' defined in class path resource
> [vidi-server-persistence-context.xml]: Invocation of init method failed;
> nested exception is javax.naming.NamingException: no resource registered
> with uniqueName 'jdbc/db-resource', available resources: []
>        at
>
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
>        at
>
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
>        at
>
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
>        at
>
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
>        at
>
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
>        at
>
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
>        at
>
> org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:400)
>        at
>
> org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
>        at
>
> org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
>        at
>
> org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
>        at
>
> org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
>        at
>
> org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1439)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1408)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
>        ... 34 more
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'dataSource' defined in class path resource
> [vidi-server-persistence-context.xml]: Invocation of init method failed;
> nested exception is javax.naming.NamingException: no resource registered
> with uniqueName 'jdbc/db-resource', available resources: []
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
>        at
>
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
>        at
>
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
>        at
>
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
>        at
>
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
>        at
>
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
>        ... 52 more
> Caused by: javax.naming.NamingException: no resource registered with
> uniqueName 'jdbc/db-resource', available resources: []
>        at
>
> bitronix.tm.resource.ResourceObjectFactory.getObjectInstance(ResourceObjectFactory.java:57)
>        at
>
> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
>        at
> javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
>        at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
>        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>        at
> org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
>        at javax.naming.InitialContext.lookup(InitialContext.java:392)
>        at
> org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
>        at
> org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
>        at
> org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
>        at
> org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
>        at
>
> org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
>        at
>
> org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
>        at
>
> org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
>        at
>
> org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
>        at
>
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
>        ... 59 more
>
> Now, i have no idea why no resource hasn't registered? If you have some
> idea's what am i doing wrong i will be glad :).
>
>
>
> --
> View this message in context:
> http://old.nabble.com/available-resources%3A----%09at-bitronix.tm.resource.ResourceObjectFactory.getObjectInstance%28ResourceObjectFactory.java%3A57%29-tp33337287p33337287.html
> Sent from the Bitronix Transaction Manager mailing list archive at
> Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: available resources: [] at bitronix.tm.resource.ResourceObjectFactory.getObjectInstance(ResourceObjectFactory.java:57)

amol
This post has NOT been accepted by the mailing list yet.
This post was updated on .
 I am also facing similar issue and as per Ludovic i followed the link and tried
 <a href="http:// http://docs.codehaus.org/display/BTM/Spring+Framework2x">http://docs.codehaus.org/display/BTM/Spring+Framework2x

Here is my configuration

<bean id="btmdataSource" class="bitronix.tm.resource.jdbc.PoolingDataSource" init-method="init" destroy-method="close"> 
            <property name="uniqueName" value="jdbc/jbpm-ds" />
        <property name="className" value="bitronix.tm.resource.jdbc.lrc.LrcXADataSource" />
        <property name="minPoolSize" value="1" /> 
        <property name="maxPoolSize" value="5" />       
       <property name="driverProperties">
        <props> 
                <prop key="url">XXX</prop> 
                <prop key="user">XXX</prop> 
                <prop key="password">XXX</prop>
                <prop key="driverClassName">oracle.jdbc.driver.OracleDriver</prop> 
            </props>                     
        </property>
    </bean>

                <bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
                        <property name="serverId" value="spring-btm" />
                </bean>
                 
               
                <bean id="bitronixTransactionManager" factory-method="getTransactionManager"
                        class="bitronix.tm.TransactionManagerServices" depends-on="btmConfig" destroy-method="shutdown" />

 <bean id="jbpmTxManager" class="org.springframework.transaction.jta.JtaTransactionManager"> 
        <property name="transactionManager" ref="bitronixTransactionManager" /> 
        <property name="userTransaction" ref="bitronixTransactionManager" /> 
    </bean> 


    <bean id="jbpmEMF" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="btmdataSource" /> 
        <property name="persistenceUnitName" value="org.jbpm.persistence.jpa" />
        <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
        <property name="jpaVendorAdapter"> 
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
                <property name="showSql" value="true" /> 
                <property name="generateDdl" value="false" />
            </bean> 
        </property> 
        <property name="jpaPropertyMap">
                     <map>
                           <entry key="transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
                           <entry key="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />
                           <entry key="hibernate.id.new_generator_mappings" value="false" />
                           <entry key="hibernate.connection.autocommit" value="false" />
                           <entry key="hibernate.connection.release_mode" value="on_close" />
                           <entry key="hibernate.current_session_context_class" value="jta" />
                           <entry key="hibernate.jndi.class" value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
                     </map>
              </property>
    </bean>

Getting an error as below

Caused by: java.lang.IllegalStateException: Unable to find transaction: Cannot create resource instance
        at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:124)
        at org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:69)
        at org.jbpm.task.service.persistence.TaskJTATransactionManager.<init>(TaskJTATransactionManager.java:37)
        at org.jbpm.task.service.persistence.TaskSessionFactoryImpl.createTaskPersistenceManager(TaskSessionFactoryImpl.java:85)
        at org.jbpm.task.service.persistence.TaskSessionFactoryImpl.createTaskServiceSession(TaskSessionFactoryImpl.java:75)
        at org.jbpm.task.service.TaskService.createSession(TaskService.java:203)
        at org.jbpm.task.service.TaskService.initialize(TaskService.java:133)
        at org.jbpm.task.service.TaskService.initialize(TaskService.java:119)
        at org.jbpm.task.service.TaskService.<init>(TaskService.java:97)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
        ... 85 more
Caused by: javax.naming.NamingException: Cannot create resource instance
        at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:113)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:119)

Can someone help?
Loading...