0
votes

My project fully conects to the database to load all data but Spring Security throws me the following exception

10:58:08 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null 10:58:08 ERROR [JDBCExceptionReporter] com.mchange.v2.c3p0.ComboPooledDataSource [ java.beans.IntrospectionException: java.lang.reflect.InvocationTargetException [numThreadsAwaitingCheckoutDefaultUser] ] has been closed()

here are is my spring security configuration class

<http auto-config="true" use-expressions="false" authentication-manager-ref="authManager" access-decision-manager-ref="accessDecisionManager"
    access-denied-page="/unauthorized">
    <intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />

    <form-login 
        login-processing-url="/j_login" 
        authentication-failure-url="/login?erro=usuarioIncorreto"
        always-use-default-target="false"
        login-page="/login" 
        default-target-url="/" />

    <logout invalidate-session="true" 
        logout-success-url="/login"
        logout-url="/j_logout"
        delete-cookies="JSESSIONID" />

    <session-management invalid-session-url="/login?erro=novaSessao" 
        session-fixation-protection="newSession">
        <concurrency-control max-sessions="1" error-if-maximum-exceeded="false" />
    </session-management>
</http>

<authentication-manager >
    <authentication-provider user-service-ref="securityServiceTrack">
        <password-encoder hash="md5" />
    </authentication-provider>
</authentication-manager>

<beans:bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased">
    <beans:property name="decisionVoters">
        <beans:list>
            <beans:bean class="org.springframework.security.access.vote.AuthenticatedVoter" />

-->

And here is my web.xml:

<display-name>Track Go Web</display-name>

<!-- ******************************************************* -->
<!-- Configuração do Spring -->
<!-- ******************************************************* -->

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/config/spring/applicationContext.xml
        /WEB-INF/config/spring/applicationContext-persistence.xml
        /WEB-INF/config/spring/applicationContext-security.xml
    </param-value>
</context-param>

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

<!-- Spring Security -->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
    <listener-class>
        org.springframework.security.web.session.HttpSessionEventPublisher
    </listener-class>
</listener> 

<!-- OpenEntityManagerInViewFilter -->
<filter>
    <filter-name>OpenEntityManagerInViewFilter</filter-name>
    <filter-class>
        org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
    </filter-class>
</filter>
<filter-mapping>
    <filter-name>OpenEntityManagerInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- ******************************************************* -->
<!-- Configuração do SiteMesh -->
<!-- ******************************************************* -->
 <filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


<!-- ******************************************************* -->
<!-- Configuração do VRaptor3 -->
<!-- ******************************************************* -->

<context-param>
    <param-name>br.com.caelum.vraptor.encoding</param-name>
    <param-value>UTF-8</param-value>
</context-param>
<!-- Define Messages Bundle -->

--> javax.servlet.jsp.jstl.fmt.localizationContext</param-name>--> messages</param-value>--> --> javax.servlet.jsp.jstl.fmt.locale pt_BR --> vraptor.jasperMaker</param-name>--> /WEB-INF/reports</param-value>--> -->

<filter>
    <filter-name>vraptor</filter-name>
    <filter-class>br.com.caelum.vraptor.VRaptor</filter-class>
</filter>

<filter-mapping>
    <filter-name>vraptor</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
</filter-mapping>

Here is my persintence configuration file

<!-- ********************************************* -->
<!-- DataSource condfig-->
<!-- ********************************************* -->



<context:property-placeholder location="classpath:configuracoes.properties" />

 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="${trackgoweb.jdbc.driverclass}" />
    <property name="jdbcUrl" value="${trackgoweb.jdbc.url}" />
    <property name="user" value="${trackgoweb.jdbc.username}" />
    <property name="password" value="${trackgoweb.jdbc.password}" />
    <property name="maxPoolSize" value="10" />
    <property name="maxStatements" value="0" />
    <property name="minPoolSize" value="3" />
    <property name="checkoutTimeout" value="30000" />
</bean>

<!-- Configuraçãoes relativas a acesso a dados -->
<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

    <property name="dataSource" ref="dataSource"/>

    <property name="jpaDialect">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"></bean>
    </property>
    <property name="jpaVendorAdapter">
        <bean
            class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="showSql" value="true" />
            <property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect" />
        </bean>
    </property>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.format_sql">true</prop>
            <prop key="hibernate.query.substitutions">true 'S',false 'N',yes 'S',no 'N'</prop>
            <prop key="hibernate.query.jpaql_strict_compliance">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
        </props>
    </property>
</bean>

<!-- Transaction Manager exclusivo para JPA -->
<bean id="transactionManager"
    class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
    <property name="jpaDialect">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"></bean>
    </property>
</bean>

1
Looks like you have some error in your C3po config. Can you show it? - Maksym Demidas
Can you please post your C3p0 configuration. - Manoj Kathiriya
Ok Im edditing the post and adding my persistence configuration file - B. TIger
Thanks for the suport guys @MaksymDemidas I solved it on my own it really was on the C3P0 config i was closing the session on my aplication context I removed it and it worked - B. TIger

1 Answers

1
votes

I solved the issue by removing the session closure on distroy on the datasource bean

<context:property-placeholder location="classpath:configuracoes.properties" />

 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="${trackgoweb.jdbc.driverclass}" />
    <property name="jdbcUrl" value="${trackgoweb.jdbc.url}" />
    <property name="user" value="${trackgoweb.jdbc.username}" />
    <property name="password" value="${trackgoweb.jdbc.password}" />
    <property name="maxPoolSize" value="10" />
    <property name="maxStatements" value="0" />
    <property name="minPoolSize" value="3" />
    <property name="checkoutTimeout" value="30000" />
</bean>