Fix error when the connections in the pool has been closed.

This commit is contained in:
Paulo Gustavo Veiga 2012-11-01 23:29:18 -03:00
parent e5e2e86fce
commit 9067a6cff2
3 changed files with 84 additions and 82 deletions

View File

@ -52,9 +52,6 @@ public class UsersController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Value("${registration.email.enabled}")
boolean emailConfirmEnabled;
@Autowired @Autowired
private ReCaptcha captchaService; private ReCaptcha captchaService;
@ -111,11 +108,13 @@ public class UsersController {
user.setFirstname(userBean.getFirstname()); user.setFirstname(userBean.getFirstname());
user.setLastname(userBean.getLastname()); user.setLastname(userBean.getLastname());
user.setPassword(userBean.getPassword()); user.setPassword(userBean.getPassword());
userService.createUser(user, emailConfirmEnabled);
boolean confirmRegistrationByEmail = false;
userService.createUser(user, confirmRegistrationByEmail);
// Forward to the success view ... // Forward to the success view ...
result = new ModelAndView("userRegistrationSuccess"); result = new ModelAndView("userRegistrationSuccess");
result.addObject("confirmByEmail", emailConfirmEnabled); result.addObject("confirmByEmail", confirmRegistrationByEmail);
} }
return result; return result;
} }

View File

@ -9,6 +9,8 @@
#database.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect #database.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
#database.username=wisemapping #database.username=wisemapping
#database.password=password #database.password=password
#database.validation.enabled=true
#database.validation.query=SELECT 1
# HSQL Configuration properties # HSQL Configuration properties
database.url=jdbc:hsqldb:file:target/db/wisemapping database.url=jdbc:hsqldb:file:target/db/wisemapping
@ -16,6 +18,8 @@ database.driver=org.hsqldb.jdbc.JDBCDriver
database.hibernate.dialect=org.hibernate.dialect.HSQLDialect database.hibernate.dialect=org.hibernate.dialect.HSQLDialect
database.username=sa database.username=sa
database.password= database.password=
database.validation.enabled=false
database.validation.query=
################################################################################## ##################################################################################
# Mail configuration. Must be configured to enable user registration confirmation. # Mail configuration. Must be configured to enable user registration confirmation.
@ -60,9 +64,6 @@ mail.errorReporterEmail=
# Users Registration Configuration # Users Registration Configuration
################################################################################## ##################################################################################
# Enable/Disable user registration confirmation by e-mail. If it's enabled, mail must be configured.
registration.email.enabled = false
# Enable captcha confirmation # Enable captcha confirmation
google.recaptcha.enabled = true google.recaptcha.enabled = true

View File

@ -1,74 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans> <beans>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" /> <property name="location" value="/WEB-INF/app.properties" />
</bean> </bean>
<bean id="wiseDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <bean id="wiseDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${database.driver}"/> <property name="driverClassName" value="${database.driver}"/>
<property name="url" value="${database.url}"/> <property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/> <property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/> <property name="password" value="${database.password}"/>
</bean> <property name="testOnBorrow" value="${database.validation.enabled}"/>
<property name="validationQuery" value="${database.validation.query}"/>
<!--Descoment this lines for production environments --> </bean>
<!--<bean id="wiseDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">-->
<!--<property name="jndiName">--> <!--Descoment this lines for production environments -->
<!--<value>java:comp/env/jdbc/wisemapping</value>--> <!--<bean id="wiseDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">-->
<!--</property>--> <!--<property name="jndiName">-->
<!--</bean>--> <!--<value>java:comp/env/jdbc/wisemapping</value>-->
<!--</property>-->
<bean id="mindmapSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!--</bean>-->
<property name="dataSource" ref="wiseDataSource"/>
<property name="mappingResources"> <bean id="mindmapSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<list> <property name="dataSource" ref="wiseDataSource"/>
<value>com/wisemapping/model/Collaborator.hbm.xml</value> <property name="mappingResources">
<value>com/wisemapping/model/Mindmap.hbm.xml</value> <list>
<value>com/wisemapping/model/Collaboration.hbm.xml</value> <value>com/wisemapping/model/Collaborator.hbm.xml</value>
<value>com/wisemapping/model/CollaborationProperties.hbm.xml</value> <value>com/wisemapping/model/Mindmap.hbm.xml</value>
<value>com/wisemapping/model/AccessAuditory.hbm.xml</value> <value>com/wisemapping/model/Collaboration.hbm.xml</value>
<value>com/wisemapping/model/MindMapHistory.hbm.xml</value> <value>com/wisemapping/model/CollaborationProperties.hbm.xml</value>
</list> <value>com/wisemapping/model/AccessAuditory.hbm.xml</value>
</property> <value>com/wisemapping/model/MindMapHistory.hbm.xml</value>
<property name="hibernateProperties"> </list>
<props> </property>
<prop key="hibernate.dialect">${database.hibernate.dialect}</prop> <property name="hibernateProperties">
</props> <props>
</property> <prop key="hibernate.dialect">${database.hibernate.dialect}</prop>
</bean> </props>
</property>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> </bean>
<property name="sessionFactory">
<ref local="mindmapSessionFactory"/> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
</property> <property name="sessionFactory">
</bean> <ref local="mindmapSessionFactory"/>
</property>
<!-- Spring Data Access Exception Translator Defintion --> </bean>
<bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource" ref="wiseDataSource"/> <!-- Spring Data Access Exception Translator Defintion -->
</bean> <bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource" ref="wiseDataSource"/>
<!-- Hibernate Template Defintion --> </bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="mindmapSessionFactory"/> <!-- Hibernate Template Defintion -->
<property name="jdbcExceptionTranslator" ref="jdbcExceptionTranslator"/> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
</bean> <property name="sessionFactory" ref="mindmapSessionFactory"/>
<property name="jdbcExceptionTranslator" ref="jdbcExceptionTranslator"/>
<bean id="txAttributes" </bean>
class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties"> <bean id="txAttributes"
<props> class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<prop key="*">PROPAGATION_REQUIRED</prop> <property name="properties">
</props> <props>
</property> <prop key="*">PROPAGATION_REQUIRED</prop>
</bean> </props>
</property>
<bean id="txInterceptor" </bean>
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager"/> <bean id="txInterceptor"
<property name="transactionAttributeSource" ref="txAttributes"/> class="org.springframework.transaction.interceptor.TransactionInterceptor">
</bean> <property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributeSource" ref="txAttributes"/>
</beans> </bean>
</beans>