0

我的项目完全连接到数据库以加载所有数据,但 Spring Security 向我抛出以下异常

10:58:08 WARN [JDBCExceptionReporter] SQL 错误:0,SQLState:null 10:58:08 错误 [JDBCExceptionReporter] com.mchange.v2.c3p0.ComboPooledDataSource [java.beans.IntrospectionException: java.lang.reflect.InvocationTargetException [ numThreadsAwaitingCheckoutDefaultUser] ] 已关闭()

这是我的spring安全配置类

<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" />

-->

这是我的 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>

这是我的持久性配置文件

<!-- ********************************************* -->
<!-- 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>

4

1 回答 1

1

我通过删除数据源 bean 上的 distroy 会话关闭解决了这个问题

<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>
于 2013-01-23T20:33:42.450 回答