SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye

Welcome, Guest
Guest Settings
Help

Compass Support Forums » Compass » Compass Users

Thread: Binding to spring transaction problem

This question is answered.


Permlink Replies: 12 - Pages: 1 - Last Post: Nov 28, 2011 2:44 AM Last Post By: clothworld
Seth Call

Posts: 2
Registered: 5/17/09
Binding to spring transaction problem
Posted: May 17, 2009 5:51 PM
 
  Click to reply to this thread Reply
Hi all,

I can't seem to configure Compass 2.2.0 to reuse my existing transactionManager. I'm using Hibernate successfully already in this project, but to be clear, I'm not trying to use the Hibernate + Compass integration (HibernateGPS etc). I just want 'plain' Compass to reuse my existing Spring transaction config.

What happens is this... when I try to invoke Compass.openSession(), I get this exception:
Could not open Hibernate Session for transaction; nested exception is java.lang.IllegalStateException: Already value [\org.springframework.jdbc.datasource.ConnectionHolder@1b001088] for key [org.apache.commons.dbcp.BasicDataSource@2da8ca45] bound to thread [2106664795@qtp-1981402139-7]

I tried debugging a little, and all I found was this:

In SpringSyncTransactionFactory.lookupTransactionSynchronization(), there is a loop which tries to find any 'syncs' that are an instanceof SpringSyncTransaction.SpringTransactionSynchronization. I only have one sync in the list of syncs, which is of type:

org.springframework.orm.hibernate3.SpringSessionSynchronization

(which isn't of the desired type). So, since no valid SpringTransactionSynchronization's are found, I think the SpringSyncTransactionFactory tries to then make one, causing the exception since a hibernate transaction already is in place.

I'm feeling like I've just missed some sort of basic spring config. Does anyone have any clues as to what I might be doing wrong?

My spring config (truncated to relevant):

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

<bean id="transactionManager" name="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${driverClassName}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
</bean>

<!-- Hibernate -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="datasource"/>

<property name="mappingResources">
<list>
...
</list>
</property>

<property name="schemaUpdate" value="true"/>

<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy"/>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${hdl2ddlmode}</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
</props>
</property>
</bean>

<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="datasource"/>
</bean>

<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="is*" read-only="true"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>

<aop:config>
<aop:pointcut id="managerOperations"
expression="execution(* foo.bar.*Manager.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="managerOperations"/>
</aop:config>

<!-- Compass -->
<bean id="compass" class="org.compass.spring.LocalCompassBean">

<property name="resourceLocations">
<list>
<value>classpath:my.cmd.xml</value>
<value>classpath:Article.cpm.xml</value>
</list>
</property>
<property name="compassSettings">
<props>
<prop key="compass.engine.connection">
ram://target/testindex
</prop>
<prop key="compass.transaction.factory">
org.compass.spring.transaction.SpringSyncTransactionFactory
</prop>
</props>
</property>
<property name="transactionManager" ref="transactionManager"/>
</bean>

<bean id="siteSearchManager" class="foor.bar.SiteSearchManagerImpl">
<constructor-arg type="org.compass.core.Compass" ref="compass"/>
</bean>

<bean id="userManager" class="foo.bar.UserManagerImpl">
<constructor-arg type="foo.bar.SiteSearchManager" ref="siteSearchManager" />
</bean>
</beans>

Thanks for any help,
Seth

removed accidental strikethroughs
Edited by: Seth Call on May 17, 2009 5:51 PM

pangea

Posts: 368
Registered: 9/25/07
Re: Binding to spring transaction problem
Posted: May 17, 2009 11:39 PM   in response to: Seth Call in response to: Seth Call
Correct
  Click to reply to this thread Reply
why are u creating 2 trans managers

<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="datasource"/>
</bean>

whats the need for this...u already have hibernate TM!
Seth Call

Posts: 2
Registered: 5/17/09
Re: Binding to spring transaction problem
Posted: May 18, 2009 8:47 AM   in response to: pangea in response to: pangea
 
  Click to reply to this thread Reply
slaps head

/drops and gives pangea 20 more XML pushups

Thanks much, that did it.

Seth
louisvuittonbox

Posts: 411
Registered: 8/23/11
Re: Binding to spring transaction problem
Posted: Aug 23, 2011 9:48 PM   in response to: Seth Call in response to: Seth Call
 
  Click to reply to this thread Reply
Producing fabulous high end fashion year after year and season after season, gucci outlet is arguably the world's most prestigious designer of clothes. As you would expect from a gucci outlet online that started out solely making leather goods, they are best known for their classic range of gucci bags and gucci handbags which usually feature the trademark company logo or pattern and come either in leather or canvas finishes which look perfect when coupled with matching gucci shoes. Ladies Gucci Shoes are simply the perfect footwear for any occasion and here at Profile we stock a large selection including Gucci Boots, Flats and High Heels. They are designer shoes of the highest quality.
azsxa

Posts: 158
Registered: 9/27/11
Re: Binding to spring transaction problem
Posted: Nov 2, 2011 2:50 AM   in response to: Seth Call in response to: Seth Call
 
  Click to reply to this thread Reply
Dear customers, welcome to our ugg bailey button boots Sale online store!Here you can find different kinds of ugg boots clearance in various styles and colors. All our shoes ugg clearance are in high quality at reasonable prices compared with other online stores. As a professional sale outlet, we have established good reputation in this business line. In addition, fine workmanship and exquisite material is guaranteed in our store. therefore,uggs clearance as the most common fall and winter fashion accessories, not only warmth fills the air, but can also dress up your charm plus.We will also bear the loss of goods in the free shipping. Our aim is to offer the best service and convenience for our customers. we have various payment methods.There is no denying that ugg kensington on sale will bring you unique modern style.
good

Posts: 73
Registered: 11/4/11
Re: Binding to spring transaction problem
Posted: Nov 23, 2011 8:14 PM   in response to: Seth Call in response to: Seth Call
 
  Click to reply to this thread Reply
yezhia2012

Posts: 28
Registered: 11/24/11
moncler outlet
Posted: Nov 24, 2011 7:29 AM   in response to: Seth Call in response to: Seth Call
 
  Click to reply to this thread Reply
moncler will be the big merchandise of feather affordable industry, moncler outletmoncler jackets is produced up of affordable and feather. affordable typically employed in high-grade light goose affordable 90% or 90% of light duck down, 90% in the true powerful cozy affordable jacket, bulkiness and high, putting on moncler coats, light, and comfortable.New 2011 Moncler
Womens Moncler Vest
Mens Moncler Vest
Womens Moncler Boots
Mens Moncler Boots
Moncler Polo Shirts
Moncler Pants Man
Moncler Hoodies
Womens Moncler Jackets
Womens Moncler Down Coats
Mens Moncler Jackets
Mens Moncler Down Coats
Mens Moncler Sweater
Womens Moncler Sweater
Kids Moncler Jackets
Kids Moncler Vest
Moncler Handbags
Moncler Caps
Moncler Hats & Scarves
Moncler Shoes
Moncler T Shirts affordable typically making use of 90% cashmere, cashmere filling 230g ~ 320g (according to merchandise size) and affordable to adjust to minus twenty degrees inside the north about 30 degrees under zero environment.coach factory outlet
coach factory
coach outlet
coach outlet online
coach handbags
coach handbags outlet
Wallets Coach
2011 New Arrival
HoBo Coach
Luggage Coach
small bags coach
Business Bags Coach
Leather Coach
Satchel Coach
Shoulder Coach
Backpacks Coach
Totes Coach
sunglass coach
boots coach
casual shoes coachCoach purses
coach outlet online
2011 New Arrival
Coach Claire Bags
Coach Classic Handbags
Coach Leather Bags
Coach Poppy Collection
Coach Satchel Bags
Coach Shoulder Bags
coach fabric Bags
Coach Swingpack Bags
Coach Totes Bagscoach outlet
coach factory outlet
coach handbags
clothworld

Posts: 1,130
Registered: 11/16/11
Re:Columbia Sportswear
Posted: Nov 28, 2011 2:44 AM   in response to: Seth Call in response to: Seth Call
 
  Click to reply to this thread Reply
Lu Huadong indicated that Columbia Sportswear this school bus accident previous three Columbia Jackets days, the Qingyang Bureau of Education, the Columbia Outlet Zhengning County Bureau of Education discovered Mens Columbia 3 in 1 Jackets in the inspection, this kindergarten existence school bus Lovers Columbia Trousers overload situation, once ordered the kindergarten to carry on reorganizes. The Ministry Supra Shoes of Education requests the Supra Shoes UK regional Educational department and the elementary and middle schools Supra TK Society kindergarten; first, develops immediately to the elementary and middle school students and the baby leaves Womens Supra TK Society Shoes class rides in a carriage the security situation investigation. Must chase the school by to live by the garden leaves class the riding Womens Supra Skytop Shoes situation Supra Vaider to the student on to carry on the overall check understanding, rents the vehicles to the Supra Skytop III Shoes school and the kindergarten to carry on the New Supra Skytop Shoes security check, the existence safe hidden danger must stop using the service immediately; The Supra Strapped NS discovery has the guardian to rent the society the illegal operation vehicles to give to advise Supra TK Society Shoes against.
Legend
Guru: 2001 + pts
Expert: 501 - 2000 pts
Super-star: 101 - 500 pts
Assistant: 51 - 100 pts
Participant: 0 - 50 pts
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums