possible issue with TransactionManagerServices configuration and spring 3.0.1

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

possible issue with TransactionManagerServices configuration and spring 3.0.1

Luke Alford
Hi folks,

I haven't done any significant investigation of this issue so I'm not sure it's a bug yet, but I thought I'd bring it to people's attention and see if anyone else has run into this.  It's quite possible that I've missed something in the configuration.

Dev Environment:
- ubuntu 10.04
- intellij idea 8.1.4 commercial
- tomcat 6.0.28 (hooked into intellij for dev deployment)
- spring 3.0.1
- bitronix 2.1.0

Problem:
Spring is starting the transaction manager before the configuration gets set in TransactionManagerServices, resulting in the IllegalStateException as explained in the javadoc.  I need to be able to set the location of the transaction journal files because we're deploying web services using Jetty as a stand alone container and could have multiple services running in separate processes on the same machine.  I have a workaround by just changing the directory in my start script (so the default location doesn't collide between jvm processes), but I'd like to be able to set the configuration explicitly.

References:
I read through this example for spring 2.5.x.  http://docs.codehaus.org/display/BTM/Spring+Framework#SpringFramework-Step3%3AConfigureBTMbeans

The important parts of my persistence bean configuration (log file config commented out so the problem would reproduce with the reference example):
    <!-- Bitronix Transaction Manager embedded configuration -->
    <bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <!--<property name="logPart1Filename" value="/path/to/service/journal-logs/btm1.tlog"/>-->
        <!--<property name="logPart2Filename" value="/path/to/service/journal-logs/btm2.tlog"/>-->
        <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="transactionManager" ref="bitronixTransactionManager" />
        <property name="userTransaction" ref="bitronixTransactionManager" />
    </bean>

The significant portion of the stack trace:
Caused by: org.springframework.beans.PropertyBatchUpdateException: Failed properties: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1341) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    ... 37 common frames omitted


Any ideas are greatly appreciated, I'm just not sure why spring is starting the transaction manager when it depends on the configuration.  Aside from possible user error in this case though, this framework is great!  Many thanks to all involved for making things easier.

Thanks,

Luke
Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

Ludovic Orban-2
Hi Luke,

Thanks for the appreciation, it's always nice to hear.

The most common cause of your problem is that there's some code somewhere which called TransactionManagerServices.getTransactionManager() before Spring could do it. The usual suspect being Hibernate via its lookup strategy. I think I should add something to help troubleshooting this kind of problem.

This kind of annoyance is caused by the singleton-oriented design of BTM which was coded that way for historical reasons. I take the blame for it.

Enjoy,
Ludovic



2011/1/28 Luke Alford <[hidden email]>
Hi folks,

I haven't done any significant investigation of this issue so I'm not sure it's a bug yet, but I thought I'd bring it to people's attention and see if anyone else has run into this.  It's quite possible that I've missed something in the configuration.

Dev Environment:
- ubuntu 10.04
- intellij idea 8.1.4 commercial
- tomcat 6.0.28 (hooked into intellij for dev deployment)
- spring 3.0.1
- bitronix 2.1.0

Problem:
Spring is starting the transaction manager before the configuration gets set in TransactionManagerServices, resulting in the IllegalStateException as explained in the javadoc.  I need to be able to set the location of the transaction journal files because we're deploying web services using Jetty as a stand alone container and could have multiple services running in separate processes on the same machine.  I have a workaround by just changing the directory in my start script (so the default location doesn't collide between jvm processes), but I'd like to be able to set the configuration explicitly.

References:
I read through this example for spring 2.5.x.  http://docs.codehaus.org/display/BTM/Spring+Framework#SpringFramework-Step3%3AConfigureBTMbeans

The important parts of my persistence bean configuration (log file config commented out so the problem would reproduce with the reference example):
    <!-- Bitronix Transaction Manager embedded configuration -->
    <bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <!--<property name="logPart1Filename" value="/path/to/service/journal-logs/btm1.tlog"/>-->
        <!--<property name="logPart2Filename" value="/path/to/service/journal-logs/btm2.tlog"/>-->
        <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="transactionManager" ref="bitronixTransactionManager" />
        <property name="userTransaction" ref="bitronixTransactionManager" />
    </bean>

The significant portion of the stack trace:
Caused by: org.springframework.beans.PropertyBatchUpdateException: Failed properties: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1341) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    ... 37 common frames omitted


Any ideas are greatly appreciated, I'm just not sure why spring is starting the transaction manager when it depends on the configuration.  Aside from possible user error in this case though, this framework is great!  Many thanks to all involved for making things easier.

Thanks,

Luke

Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

Luke Alford
Hi Ludovic,

Thanks for the quick reply.  I am using hibernate for my persistence layer, all of my various persistence units have the following properties configured.  Is there a way I can configure this to wait on spring to initialize the singleton?  I'll search around online for any examples as well.

<properties>
            <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
            <property name="hibernate.current_session_context_class" value="jta"/>
            <property name="hibernate.connection.release_mode" value="after_statement"/>
        </properties>

Thanks again for the help,

Luke


On Fri, Jan 28, 2011 at 3:05 PM, Ludovic Orban <[hidden email]> wrote:
Hi Luke,

Thanks for the appreciation, it's always nice to hear.

The most common cause of your problem is that there's some code somewhere which called TransactionManagerServices.getTransactionManager() before Spring could do it. The usual suspect being Hibernate via its lookup strategy. I think I should add something to help troubleshooting this kind of problem.

This kind of annoyance is caused by the singleton-oriented design of BTM which was coded that way for historical reasons. I take the blame for it.

Enjoy,
Ludovic



2011/1/28 Luke Alford <[hidden email]>

Hi folks,

I haven't done any significant investigation of this issue so I'm not sure it's a bug yet, but I thought I'd bring it to people's attention and see if anyone else has run into this.  It's quite possible that I've missed something in the configuration.

Dev Environment:
- ubuntu 10.04
- intellij idea 8.1.4 commercial
- tomcat 6.0.28 (hooked into intellij for dev deployment)
- spring 3.0.1
- bitronix 2.1.0

Problem:
Spring is starting the transaction manager before the configuration gets set in TransactionManagerServices, resulting in the IllegalStateException as explained in the javadoc.  I need to be able to set the location of the transaction journal files because we're deploying web services using Jetty as a stand alone container and could have multiple services running in separate processes on the same machine.  I have a workaround by just changing the directory in my start script (so the default location doesn't collide between jvm processes), but I'd like to be able to set the configuration explicitly.

References:
I read through this example for spring 2.5.x.  http://docs.codehaus.org/display/BTM/Spring+Framework#SpringFramework-Step3%3AConfigureBTMbeans

The important parts of my persistence bean configuration (log file config commented out so the problem would reproduce with the reference example):
    <!-- Bitronix Transaction Manager embedded configuration -->
    <bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <!--<property name="logPart1Filename" value="/path/to/service/journal-logs/btm1.tlog"/>-->
        <!--<property name="logPart2Filename" value="/path/to/service/journal-logs/btm2.tlog"/>-->
        <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="transactionManager" ref="bitronixTransactionManager" />
        <property name="userTransaction" ref="bitronixTransactionManager" />
    </bean>

The significant portion of the stack trace:
Caused by: org.springframework.beans.PropertyBatchUpdateException: Failed properties: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1341) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    ... 37 common frames omitted


Any ideas are greatly appreciated, I'm just not sure why spring is starting the transaction manager when it depends on the configuration.  Aside from possible user error in this case though, this framework is great!  Many thanks to all involved for making things easier.

Thanks,

Luke


Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

Luke Alford
Sweet, I got it working correctly!  Your explanation about the hibernate lookup was just the hint I needed, I made all of my entity manager factories that load the persistence unit depend on my btmConfig bean and that got spring to handle the initialization before hibernate.  Problem solved!

Hopefully this info can help someone else out as well.  Here is an example of some of my spring beans now that they're working.

    <bean id="pcsmsEntityManagerFactory"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
          p:dataSource-ref="pcsmsDataSource"
          p:persistenceXmlLocation="classpath:pcsms-persistence.xml"
          p:persistenceUnitName="pcsms-pu"
            depends-on="btmConfig">
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
                    p:databasePlatform="org.hibernate.dialect.DB2Dialect" p:showSql="${jpa.showSql}"
                    p:generateDdl="false"/>
        </property>
    </bean>

    <!-- Bitronix Transaction Manager embedded configuration -->
    <bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <property name="logPart1Filename" value="/path/to/journal-logs/btm1.tlog"/>
        <property name="logPart2Filename" value="/path/to/journal-logs/btm2.tlog"/>
    </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="transactionManager" ref="bitronixTransactionManager" />
        <property name="userTransaction" ref="bitronixTransactionManager" />
    </bean>


Thanks,

Luke

On Fri, Jan 28, 2011 at 3:49 PM, Luke Alford <[hidden email]> wrote:
Hi Ludovic,

Thanks for the quick reply.  I am using hibernate for my persistence layer, all of my various persistence units have the following properties configured.  Is there a way I can configure this to wait on spring to initialize the singleton?  I'll search around online for any examples as well.

<properties>
            <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
            <property name="hibernate.current_session_context_class" value="jta"/>
            <property name="hibernate.connection.release_mode" value="after_statement"/>
        </properties>

Thanks again for the help,

Luke



On Fri, Jan 28, 2011 at 3:05 PM, Ludovic Orban <[hidden email]> wrote:
Hi Luke,

Thanks for the appreciation, it's always nice to hear.

The most common cause of your problem is that there's some code somewhere which called TransactionManagerServices.getTransactionManager() before Spring could do it. The usual suspect being Hibernate via its lookup strategy. I think I should add something to help troubleshooting this kind of problem.

This kind of annoyance is caused by the singleton-oriented design of BTM which was coded that way for historical reasons. I take the blame for it.

Enjoy,
Ludovic



2011/1/28 Luke Alford <[hidden email]>

Hi folks,

I haven't done any significant investigation of this issue so I'm not sure it's a bug yet, but I thought I'd bring it to people's attention and see if anyone else has run into this.  It's quite possible that I've missed something in the configuration.

Dev Environment:
- ubuntu 10.04
- intellij idea 8.1.4 commercial
- tomcat 6.0.28 (hooked into intellij for dev deployment)
- spring 3.0.1
- bitronix 2.1.0

Problem:
Spring is starting the transaction manager before the configuration gets set in TransactionManagerServices, resulting in the IllegalStateException as explained in the javadoc.  I need to be able to set the location of the transaction journal files because we're deploying web services using Jetty as a stand alone container and could have multiple services running in separate processes on the same machine.  I have a workaround by just changing the directory in my start script (so the default location doesn't collide between jvm processes), but I'd like to be able to set the configuration explicitly.

References:
I read through this example for spring 2.5.x.  http://docs.codehaus.org/display/BTM/Spring+Framework#SpringFramework-Step3%3AConfigureBTMbeans

The important parts of my persistence bean configuration (log file config commented out so the problem would reproduce with the reference example):
    <!-- Bitronix Transaction Manager embedded configuration -->
    <bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <!--<property name="logPart1Filename" value="/path/to/service/journal-logs/btm1.tlog"/>-->
        <!--<property name="logPart2Filename" value="/path/to/service/journal-logs/btm2.tlog"/>-->
        <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="transactionManager" ref="bitronixTransactionManager" />
        <property name="userTransaction" ref="bitronixTransactionManager" />
    </bean>

The significant portion of the stack trace:
Caused by: org.springframework.beans.PropertyBatchUpdateException: Failed properties: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1341) [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
    ... 37 common frames omitted


Any ideas are greatly appreciated, I'm just not sure why spring is starting the transaction manager when it depends on the configuration.  Aside from possible user error in this case though, this framework is great!  Many thanks to all involved for making things easier.

Thanks,

Luke



Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

snicoll
One way to deal with that as well is to make sure that your entity
manager factory depends on the "transactionManager" bean. That's a
fairly common use case if you use the JpaTransactionManager.

S.

On Fri, Jan 28, 2011 at 10:12 PM, Luke Alford <[hidden email]> wrote:

> Sweet, I got it working correctly!  Your explanation about the hibernate
> lookup was just the hint I needed, I made all of my entity manager factories
> that load the persistence unit depend on my btmConfig bean and that got
> spring to handle the initialization before hibernate.  Problem solved!
>
> Hopefully this info can help someone else out as well.  Here is an example
> of some of my spring beans now that they're working.
>
>     <bean id="pcsmsEntityManagerFactory"
>
> class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
>           p:dataSource-ref="pcsmsDataSource"
>           p:persistenceXmlLocation="classpath:pcsms-persistence.xml"
>           p:persistenceUnitName="pcsms-pu"
>             depends-on="btmConfig">
>         <property name="jpaVendorAdapter">
>             <bean
> class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
>                     p:databasePlatform="org.hibernate.dialect.DB2Dialect"
> p:showSql="${jpa.showSql}"
>                     p:generateDdl="false"/>
>         </property>
>     </bean>
>
>     <!-- Bitronix Transaction Manager embedded configuration -->
>     <bean id="btmConfig" factory-method="getConfiguration"
> class="bitronix.tm.TransactionManagerServices">
>         <property name="logPart1Filename"
> value="/path/to/journal-logs/btm1.tlog"/>
>         <property name="logPart2Filename"
> value="/path/to/journal-logs/btm2.tlog"/>
>     </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="transactionManager" ref="bitronixTransactionManager"
> />
>         <property name="userTransaction" ref="bitronixTransactionManager" />
>     </bean>
>
>
> Thanks,
>
> Luke
>
> On Fri, Jan 28, 2011 at 3:49 PM, Luke Alford <[hidden email]> wrote:
>>
>> Hi Ludovic,
>>
>> Thanks for the quick reply.  I am using hibernate for my persistence
>> layer, all of my various persistence units have the following properties
>> configured.  Is there a way I can configure this to wait on spring to
>> initialize the singleton?  I'll search around online for any examples as
>> well.
>>
>> <properties>
>>             <property name="hibernate.transaction.manager_lookup_class"
>> value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
>>             <property name="hibernate.cache.provider_class"
>> value="org.hibernate.cache.NoCacheProvider"/>
>>             <property name="hibernate.current_session_context_class"
>> value="jta"/>
>>             <property name="hibernate.connection.release_mode"
>> value="after_statement"/>
>>         </properties>
>>
>> Thanks again for the help,
>>
>> Luke
>>
>>
>> On Fri, Jan 28, 2011 at 3:05 PM, Ludovic Orban <[hidden email]> wrote:
>>>
>>> Hi Luke,
>>>
>>> Thanks for the appreciation, it's always nice to hear.
>>>
>>> The most common cause of your problem is that there's some code somewhere
>>> which called TransactionManagerServices.getTransactionManager() before
>>> Spring could do it. The usual suspect being Hibernate via its lookup
>>> strategy. I think I should add something to help troubleshooting this kind
>>> of problem.
>>>
>>> This kind of annoyance is caused by the singleton-oriented design of BTM
>>> which was coded that way for historical reasons. I take the blame for it.
>>>
>>> Enjoy,
>>> Ludovic
>>>
>>>
>>>
>>> 2011/1/28 Luke Alford <[hidden email]>
>>>>
>>>> Hi folks,
>>>>
>>>> I haven't done any significant investigation of this issue so I'm not
>>>> sure it's a bug yet, but I thought I'd bring it to people's attention and
>>>> see if anyone else has run into this.  It's quite possible that I've missed
>>>> something in the configuration.
>>>>
>>>> Dev Environment:
>>>> - ubuntu 10.04
>>>> - intellij idea 8.1.4 commercial
>>>> - tomcat 6.0.28 (hooked into intellij for dev deployment)
>>>> - spring 3.0.1
>>>> - bitronix 2.1.0
>>>>
>>>> Problem:
>>>> Spring is starting the transaction manager before the configuration gets
>>>> set in TransactionManagerServices, resulting in the IllegalStateException as
>>>> explained in the javadoc.  I need to be able to set the location of the
>>>> transaction journal files because we're deploying web services using Jetty
>>>> as a stand alone container and could have multiple services running in
>>>> separate processes on the same machine.  I have a workaround by just
>>>> changing the directory in my start script (so the default location doesn't
>>>> collide between jvm processes), but I'd like to be able to set the
>>>> configuration explicitly.
>>>>
>>>> References:
>>>> I read through this example for spring 2.5.x.
>>>> http://docs.codehaus.org/display/BTM/Spring+Framework#SpringFramework-Step3%3AConfigureBTMbeans
>>>>
>>>> The important parts of my persistence bean configuration (log file
>>>> config commented out so the problem would reproduce with the reference
>>>> example):
>>>>     <!-- Bitronix Transaction Manager embedded configuration -->
>>>>     <bean id="btmConfig" factory-method="getConfiguration"
>>>> class="bitronix.tm.TransactionManagerServices">
>>>>         <!--<property name="logPart1Filename"
>>>> value="/path/to/service/journal-logs/btm1.tlog"/>-->
>>>>         <!--<property name="logPart2Filename"
>>>> value="/path/to/service/journal-logs/btm2.tlog"/>-->
>>>>         <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="transactionManager"
>>>> ref="bitronixTransactionManager" />
>>>>         <property name="userTransaction"
>>>> ref="bitronixTransactionManager" />
>>>>     </bean>
>>>>
>>>> The significant portion of the stack trace:
>>>> Caused by: org.springframework.beans.PropertyBatchUpdateException:
>>>> Failed properties: Property 'serverId' threw exception; nested exception is
>>>> java.lang.IllegalStateException: cannot change the configuration while the
>>>> transaction manager is running
>>>>     at
>>>> org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
>>>> [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
>>>>     at
>>>> org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
>>>> [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
>>>>     at
>>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1341)
>>>> [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
>>>>     ... 37 common frames omitted
>>>>
>>>>
>>>> Any ideas are greatly appreciated, I'm just not sure why spring is
>>>> starting the transaction manager when it depends on the configuration.
>>>> Aside from possible user error in this case though, this framework is
>>>> great!  Many thanks to all involved for making things easier.
>>>>
>>>> Thanks,
>>>>
>>>> Luke
>>>
>>
>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

Franklin Antony
In reply to this post by Luke Alford
Thanks a lot guys.
 
I too had the same problem and fixed it by putting the "depends on" on the entityManagerFactory!!

Regards,
Franklin


Luke Alford wrote
Sweet, I got it working correctly!  Your explanation about the hibernate
lookup was just the hint I needed, I made all of my entity manager factories
that load the persistence unit depend on my btmConfig bean and that got
spring to handle the initialization before hibernate.  Problem solved!

Hopefully this info can help someone else out as well.  Here is an example
of some of my spring beans now that they're working.

    <bean id="pcsmsEntityManagerFactory"

class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
          p:dataSource-ref="pcsmsDataSource"
          p:persistenceXmlLocation="classpath:pcsms-persistence.xml"
          p:persistenceUnitName="pcsms-pu"
            depends-on="btmConfig">
        <property name="jpaVendorAdapter">
            <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
                    p:databasePlatform="org.hibernate.dialect.DB2Dialect"
p:showSql="${jpa.showSql}"
                    p:generateDdl="false"/>
        </property>
    </bean>

   
    <bean id="btmConfig" factory-method="getConfiguration"
class="bitronix.tm.TransactionManagerServices">
        <property name="logPart1Filename"
value="/path/to/journal-logs/btm1.tlog"/>
        <property name="logPart2Filename"
value="/path/to/journal-logs/btm2.tlog"/>
    </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="transactionManager" ref="bitronixTransactionManager"
/>
        <property name="userTransaction" ref="bitronixTransactionManager" />
    </bean>


Thanks,

Luke

On Fri, Jan 28, 2011 at 3:49 PM, Luke Alford <laa1010@gmail.com> wrote:

> Hi Ludovic,
>
> Thanks for the quick reply.  I am using hibernate for my persistence layer,
> all of my various persistence units have the following properties
> configured.  Is there a way I can configure this to wait on spring to
> initialize the singleton?  I'll search around online for any examples as
> well.
>
> <properties>
>             <property name="hibernate.transaction.manager_lookup_class"
> value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
>             <property name="hibernate.cache.provider_class"
> value="org.hibernate.cache.NoCacheProvider"/>
>             <property name="hibernate.current_session_context_class"
> value="jta"/>
>             <property name="hibernate.connection.release_mode"
> value="after_statement"/>
>         </properties>
>
> Thanks again for the help,
>
> Luke
>
>
>
> On Fri, Jan 28, 2011 at 3:05 PM, Ludovic Orban <lorban@bitronix.be> wrote:
>
>> Hi Luke,
>>
>> Thanks for the appreciation, it's always nice to hear.
>>
>> The most common cause of your problem is that there's some code somewhere
>> which called TransactionManagerServices.getTransactionManager() before
>> Spring could do it. The usual suspect being Hibernate via its lookup
>> strategy. I think I should add something to help troubleshooting this kind
>> of problem.
>>
>> This kind of annoyance is caused by the singleton-oriented design of BTM
>> which was coded that way for historical reasons. I take the blame for it.
>>
>> Enjoy,
>> Ludovic
>>
>>
>>
>> 2011/1/28 Luke Alford <laa1010@gmail.com>
>>
>> Hi folks,
>>>
>>> I haven't done any significant investigation of this issue so I'm not
>>> sure it's a bug yet, but I thought I'd bring it to people's attention and
>>> see if anyone else has run into this.  It's quite possible that I've missed
>>> something in the configuration.
>>>
>>> Dev Environment:
>>> - ubuntu 10.04
>>> - intellij idea 8.1.4 commercial
>>> - tomcat 6.0.28 (hooked into intellij for dev deployment)
>>> - spring 3.0.1
>>> - bitronix 2.1.0
>>>
>>> Problem:
>>> Spring is starting the transaction manager before the configuration gets
>>> set in TransactionManagerServices, resulting in the IllegalStateException as
>>> explained in the javadoc.  I need to be able to set the location of the
>>> transaction journal files because we're deploying web services using Jetty
>>> as a stand alone container and could have multiple services running in
>>> separate processes on the same machine.  I have a workaround by just
>>> changing the directory in my start script (so the default location doesn't
>>> collide between jvm processes), but I'd like to be able to set the
>>> configuration explicitly.
>>>
>>> References:
>>> I read through this example for spring 2.5.x.
>>> http://docs.codehaus.org/display/BTM/Spring+Framework#SpringFramework-Step3%3AConfigureBTMbeans
>>>
>>> The important parts of my persistence bean configuration (log file config
>>> commented out so the problem would reproduce with the reference example):
>>>    
>>>     <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="transactionManager"
>>> ref="bitronixTransactionManager" />
>>>         <property name="userTransaction" ref="bitronixTransactionManager"
>>> />
>>>     </bean>
>>>
>>> The significant portion of the stack trace:
>>> Caused by: org.springframework.beans.PropertyBatchUpdateException: Failed
>>> properties: Property 'serverId' threw exception; nested exception is
>>> java.lang.IllegalStateException: cannot change the configuration while the
>>> transaction manager is running
>>>     at
>>> org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
>>> [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
>>>     at
>>> org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
>>> [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
>>>     at
>>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1341)
>>> [org.springframework.beans-3.0.1.RELEASE.jar:3.0.1.RELEASE]
>>>     ... 37 common frames omitted
>>>
>>>
>>> Any ideas are greatly appreciated, I'm just not sure why spring is
>>> starting the transaction manager when it depends on the configuration.
>>> Aside from possible user error in this case though, this framework is
>>> great!  Many thanks to all involved for making things easier.
>>>
>>> Thanks,
>>>
>>> Luke
>>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

Sebaso
In reply to this post by Luke Alford
Hi Guys, I have the same problem... but the depends-on trick is not working... Any other ideas ? thanks
Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

Mathrusse, Chris (SFO-CAD)
I think you need to provide us with more information that what you've given.please provide us with your spring configuration as well as the stack trace so we can understand the problem.

Sent from my iPhone

On Sep 4, 2012, at 7:23 AM, "Sebaso" <[hidden email]> wrote:

>
> Hi Guys,
>
> I have the same problem... but the depends-on trick is not working...
>
> Any other ideas ?
>
> thanks
> --
> View this message in context: http://old.nabble.com/possible-issue-with-TransactionManagerServices-configuration-and-spring-3.0.1-tp30790038p34387382.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
>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

Sebaso
you are right. Here it is: bitronix.xml
and the error is:


-------------------------------------------------------------------------------
Test set: com.xxx.geotagdata.common.dateparse.DateParseTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.228 sec <<< FAILURE!
testMultipleDateFormats(com.xxx.geotagdata.common.dateparse.DateParseTest)  Time elapsed: 0.111 sec  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
        at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
        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.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'btmConfig' defined in class path resource [spring-base-config-test.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
        at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
        at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
        ... 32 more
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
        ... 47 more
testDateFormatError(com.xxx.geotagdata.common.dateparse.DateParseTest)  Time elapsed: 0.106 sec  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
        at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
        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.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'btmConfig' defined in class path resource [spring-base-config-test.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
        at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
        at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
        ... 32 more
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
        ... 47 more


Mathrusse, Chris (SFO-CAD) wrote
I think you need to provide us with more information that what you've given.please provide us with your spring configuration as well as the stack trace so we can understand the problem.

Sent from my iPhone

On Sep 4, 2012, at 7:23 AM, "Sebaso" <sebastian.ovide@gmail.com> wrote:

>
> Hi Guys,
>
> I have the same problem... but the depends-on trick is not working...
>
> Any other ideas ?
>
> thanks
> --
> View this message in context: http://old.nabble.com/possible-issue-with-TransactionManagerServices-configuration-and-spring-3.0.1-tp30790038p34387382.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
>
>

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

cmathrusse
I think you are very close to having things working correctly. Looking at your spring configuration (bitronix.xml) I think the only thing that you are missing is a depends-on attribute on your entity manager factory. I've uploaded a sample spring configuration file that outlines everything in detail.

Other than that, based upon your provided stack trace, it appears that there is an issue with the way that the application context is getting loaded from your unit tests. The trace states that the spring container is attempting to load the configurations while the transaction manager is currently running.  This can be seen in the following message:

MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
 


What I've done for our test cases is created a base class that all others extend from:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"/test-context.xml"})
@Transactional(propagation = Propagation.REQUIRED)
public abstract class BaseTestCase extends TestCase {
    protected Logger logger = Logger.getLogger(getClass().getName());

}


Your concrete Test cases then only need to extend the BaseTestCase and do not require any additional annotations. If you have multiple Test Cases that you are implementing, then you should define a TestSuite class similar to this:

@RunWith(Suite.class)
@SuiteClasses( { TestCase1.class,TestCase2.class, TestCase3.class, TestCase4.class })
@Transactional(propagation = Propagation.REQUIRED)
public class TestSuite {

}


And ensure that only the TestSuite is called rather than the Test Cases. That will ensure that the spring container loads correctly.

I hope this helps....bitronix-context.xml


Sebaso wrote
you are right. Here it is: bitronix.xml
and the error is:


-------------------------------------------------------------------------------
Test set: com.xxx.geotagdata.common.dateparse.DateParseTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.228 sec <<< FAILURE!
testMultipleDateFormats(com.xxx.geotagdata.common.dateparse.DateParseTest)  Time elapsed: 0.111 sec  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
        at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
        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.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'btmConfig' defined in class path resource [spring-base-config-test.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
        at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
        at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
        ... 32 more
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
        ... 47 more
testDateFormatError(com.xxx.geotagdata.common.dateparse.DateParseTest)  Time elapsed: 0.106 sec  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
        at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
        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.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'btmConfig' defined in class path resource [spring-base-config-test.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
        at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
        at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
        ... 32 more
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
        ... 47 more


Mathrusse, Chris (SFO-CAD) wrote
I think you need to provide us with more information that what you've given.please provide us with your spring configuration as well as the stack trace so we can understand the problem.

Sent from my iPhone

On Sep 4, 2012, at 7:23 AM, "Sebaso" <sebastian.ovide@gmail.com> wrote:

>
> Hi Guys,
>
> I have the same problem... but the depends-on trick is not working...
>
> Any other ideas ?
>
> thanks
> --
> View this message in context: http://old.nabble.com/possible-issue-with-TransactionManagerServices-configuration-and-spring-3.0.1-tp30790038p34387382.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
>
>

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

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

Sebaso
thanks for that... but I've tried to use your bitronix-context.xml but now I'm getting another error... Do you know if is there any place where I can find a working archetype (or skeleton) maven+spring+bitronix+JPA (with tests) that I can use as reference ?


-------------------------------------------------------------------------------
Test set: com.xxx.geotagdata.common.dateparse.DateParseTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.241 sec <<< FAILURE!
test(com.xxx.geotagdata.common.dateparse.DateParseTest)  Time elapsed: 1.069 sec  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
        at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
        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.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RiskTaggerBeanDummy': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.xxx.geotagdata.config.ConfigHelper com.xxx.geotagdata.common.processing.risktag.RiskTaggerBean.config; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ConfigHelper': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-base-config-test.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/myDataSource'; nested exception is 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 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
        at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
        at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
        ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.xxx.geotagdata.config.ConfigHelper com.xxx.geotagdata.common.processing.risktag.RiskTaggerBean.config; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ConfigHelper': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-base-config-test.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/myDataSource'; nested exception is 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 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
        ... 45 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ConfigHelper': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-base-config-test.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/myDataSource'; nested exception is 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 org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:342)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
        ... 47 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-base-config-test.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/myDataSource'; nested exception is 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 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:530)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:496)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:657)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:630)
        at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:339)
        ... 58 more
Caused by: org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/myDataSource'; nested exception is 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 org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource(JndiDataSourceLookup.java:47)
        at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.parsePersistenceUnitInfo(PersistenceUnitReader.java:248)
        at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.parseDocument(PersistenceUnitReader.java:179)
        at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.readPersistenceUnitInfos(PersistenceUnitReader.java:132)
        at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.readPersistenceUnitInfos(DefaultPersistenceUnitManager.java:380)
        at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:341)
        at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:326)
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:235)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
        ... 71 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.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:104)
        at org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource(JndiDataSourceLookup.java:44)
        ... 81 more




Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

cmathrusse
I'm uncertain as to the archetype. I usually just knit my projects together from a base archetype and then add in the dependencies that I need. I've attached to pom files that I am using for my project. The basic structure is as follows:

project
--- pom.xml
--- web
------ pom.xml
------ src
--------- main
------------ java
------------ webapp
------------ resources

The parent pom includes the child projects underneath it.


Pertaining to your new error, I think that this is due to a typo on your part. The root of the exception is that the Spring context is unable to locate the datasource.

org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException:
Failed to look up JNDI DataSource with name 'jdbc/myDataSource';



My guess is that your datasource is named something other than myDataSource and that is why the spring context is failing to load.

I hope this helps...
Chris

parent-pom.xml
web-pom.xml


Sebaso wrote
thanks for that... but I've tried to use your bitronix-context.xml but now I'm getting another error... Do you know if is there any place where I can find a working archetype (or skeleton) maven+spring+bitronix+JPA (with tests) that I can use as reference ?


-------------------------------------------------------------------------------
Test set: com.xxx.geotagdata.common.dateparse.DateParseTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.241 sec <<< FAILURE!
test(com.xxx.geotagdata.common.dateparse.DateParseTest)  Time elapsed: 1.069 sec  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
        at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
        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.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RiskTaggerBeanDummy': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.xxx.geotagdata.config.ConfigHelper com.xxx.geotagdata.common.processing.risktag.RiskTaggerBean.config; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ConfigHelper': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-base-config-test.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/myDataSource'; nested exception is 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 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
        at org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
        at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
        ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.xxx.geotagdata.config.ConfigHelper com.xxx.geotagdata.common.processing.risktag.RiskTaggerBean.config; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ConfigHelper': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-base-config-test.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/myDataSource'; nested exception is 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 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
        ... 45 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ConfigHelper': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-base-config-test.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/myDataSource'; nested exception is 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 org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:342)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
        ... 47 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring-base-config-test.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/myDataSource'; nested exception is 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 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:530)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:496)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:657)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:630)
        at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
        at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:339)
        ... 58 more
Caused by: org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/myDataSource'; nested exception is 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 org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource(JndiDataSourceLookup.java:47)
        at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.parsePersistenceUnitInfo(PersistenceUnitReader.java:248)
        at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.parseDocument(PersistenceUnitReader.java:179)
        at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.readPersistenceUnitInfos(PersistenceUnitReader.java:132)
        at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.readPersistenceUnitInfos(DefaultPersistenceUnitManager.java:380)
        at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:341)
        at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:326)
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:235)
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
        ... 71 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.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:104)
        at org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource(JndiDataSourceLookup.java:44)
        ... 81 more



Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

Sebaso
I feel like Im in a loop...

1) I've started with a

PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running

2) then I've used your bitronix-context.xml and that created a new error:

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

3) I've modified the bitronix-context.xml adding

        <property name="dataSource" ref="myDataSource" />
        <property name="persistenceUnitName" value="testPU" />

to the

    <bean id="emf"
          depends-on="myDataSource"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

        <property name="loadTimeWeaver">
            <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
        </property>
        <property name="dataSource" ref="myDataSource" />
        <property name="persistenceUnitName" value="testPU" />
        <property name="persistenceXmlLocation" value="META-INF/persistence.xml"/>
    </bean>

and that causes a problem similar to the original error !!!  grrr.......

Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (3) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
PropertyAccessException 2: org.springframework.beans.MethodInvocationException: Property 'logPart1Filename' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
PropertyAccessException 3: org.springframework.beans.MethodInvocationException: Property 'logPart2Filename' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330)
        ... 45 more

??????????????


Reply | Threaded
Open this post in threaded view
|

Re: possible issue with TransactionManagerServices configuration and spring 3.0.1

cmathrusse
I'm sorry you are having so many challenges with your project. I do know from experience that getting things wired together "just so" is always the most time consuming and challenging. But once correct, everything else seems to fall into place rather quickly.

To help you out a bit, I've created a sample maven project which consists of the parent project and contains a web project as its child. It is completely configured with all dependencies as well as the spring context files, Bitronix completely wired up and functional, EclipseLink configured to be the JPA implementation, as well as some unit test code that exercises the PersistenceManager and TransactionManager utilizing a Derby database. You should be able to simply extract the project, cd into the root of it and run mvn clean package. This will cause all the classes to build and unit tests to run.

I hope this helps you.
Chris

sample.tar.z

Sebaso wrote
I feel like Im in a loop...

1) I've started with a

PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running

2) then I've used your bitronix-context.xml and that created a new error:

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

3) I've modified the bitronix-context.xml adding

        <property name="dataSource" ref="myDataSource" />
        <property name="persistenceUnitName" value="testPU" />

to the

    <bean id="emf"
          depends-on="myDataSource"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

        <property name="loadTimeWeaver">
            <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
        </property>
        <property name="dataSource" ref="myDataSource" />
        <property name="persistenceUnitName" value="testPU" />
        <property name="persistenceXmlLocation" value="META-INF/persistence.xml"/>
    </bean>

and that causes a problem similar to the original error !!!  grrr.......

Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (3) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
PropertyAccessException 2: org.springframework.beans.MethodInvocationException: Property 'logPart1Filename' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
PropertyAccessException 3: org.springframework.beans.MethodInvocationException: Property 'logPart2Filename' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330)
        ... 45 more

??????????????