java - Spring Social & JPA - Having two datasources pointing to the same database -


i working on java application uses spring social communicate twitter. application uses spring data (jpa) manage users locally.

when authorize access on twitter , twitter makes request oauth1 callback url, application chokes , see following in log file (i've shortened stacktrace):

error 2013-08-18 16:05:09,511 http-bio-8080-exec-44]  org.springframework.transaction.interceptor.transactioninterceptor  [transactionaspectsupport.completetransactionafterthrowing (): "application exception overridden rollback exception"] org.springframework.jdbc.uncategorizedsqlexception: preparedstatementcallback; uncategorized sqlexception sql [insert userconnection (userid, providerid, provideruserid, ra nk, displayname, profileurl, imageurl, accesstoken, secret, refreshtoken, expiretime) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; sql state [null]; error code [0]; can't operate  on closed connection!!!; nested exception java.sql.sqlexception: can't operate on closed connection!!!         @ org.springframework.jdbc.support.abstractfallbacksqlexceptiontranslator.translate(abstractfallbacksqlexceptiontranslator.java:83)         @ org.springframework.jdbc.support.abstractfallbacksqlexceptiontranslator.translate(abstractfallbacksqlexceptiontranslator.java:80)         @ org.springframework.jdbc.support.abstractfallbacksqlexceptiontranslator.translate(abstractfallbacksqlexceptiontranslator.java:80)         @ org.springframework.jdbc.core.jdbctemplate.execute(jdbctemplate.java:603) ... caused by: java.sql.sqlexception: can't operate on closed connection!!!         @ com.mchange.v2.sql.sqlutils.tosqlexception(sqlutils.java:118)         @ com.mchange.v2.sql.sqlutils.tosqlexception(sqlutils.java:77)         @ com.mchange.v2.c3p0.impl.newproxyconnection.preparestatement(newproxyconnection.java:171)         @ org.springframework.jdbc.core.jdbctemplate$simplepreparedstatementcreator.createpreparedstatement(jdbctemplate.java:1438)         @ org.springframework.jdbc.core.jdbctemplate.execute(jdbctemplate.java:581)         ... 94 more caused by: java.lang.nullpointerexception         @ com.mchange.v2.c3p0.impl.newproxyconnection.preparestatement(newproxyconnection.java:135)         ... 96 more [warn 2013-08-18 16:05:09,513 http-bio-8080-exec-44]  org.springframework.social.connect.web.connectcontroller  [connectcontroller.oauth1callback(): "exception while handling oauth1 callback (could not roll jpa transaction; nested exception javax.persistence.persistenceexception: unexpected error when rollbacking). redirecting twitter connection status page."] 

after research believe seeing issue described here: https://jira.springsource.org/browse/social-384

for reason fact spring social core uses jdbcusersconnectionrepository not play nice jpa set up. understand plugin available; decided experiment datasource configurations , created 2 identical datasource bean configurations (with different names) , tied 1 spring social , other entity manager configuration.

with setup above error goes away , able see twitter user connection persisted database. question is: doing valid solution? other scenarios require duplicate datasources? on flip side - possible repercussions using such configuration?

downside of solution need reduce maximum capacity of connection pool.

example: imagine have connection pool max 30 connections in it. want add datasource spring social. suppose each user use 2 datasources simultaneously. need 2 connection pools max 15 connections in each. easier hit limit.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -