2013-05-02 42 views
0

停止Tomcat上我的春節,基於應用程序時,我有以下問題......我怎麼關機春季安全LDAP優雅

SEVERE: The web application [/Toolbox] appears to have started a thread named [Thread-8] but has failed to stop it. This is very likely to create a memory leak. 

我追溯這個線程是什麼...

thread: 43 :: Thread-8 :: RUNNABLE 
Trace: 
java.net.SocketInputStream.socketRead0(Native Method) 
java.net.SocketInputStream.read(SocketInputStream.java:129) 
java.io.BufferedInputStream.fill(BufferedInputStream.java:218) 
java.io.BufferedInputStream.read1(BufferedInputStream.java:258) 
java.io.BufferedInputStream.read(BufferedInputStream.java:317) 
com.sun.jndi.ldap.Connection.run(Connection.java:834) 
java.lang.Thread.run(Thread.java:662) 

(有真2個線程,線程7和螺紋8,既LDAP)

顯然ldap未退出正常。我使用Spring Security從活動目錄服務器進行身份驗證(並獲取其他數據)。我的安全XML文件如下...

<?xml version="1.0" encoding="UTF-8"?> 
    <beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:sec="http://www.springframework.org/schema/security" 
    xmlns:security="http://www.springframework.org/schema/security" 
    xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> 

<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource"> 
    <property name="url" value="ldap://ldap.example.example.com:389" /> 
    <property name="base" value="dc=corp,dc=global,dc=example,dc=com" /> 
    <property name="userDn" value="CN=lna.authquery,OU=LDAPGroups,OU=NorthAmerica,DC=corp,DC=global,DC=example,DC=com" /> 
    <property name="password" value="${example.password}" /> 
    <property name="pooled" value="true" /> 
    <!-- AD Specific Setting for avoiding the partial exception error --> 
    <property name="referral" value="follow" /> 
</bean> 

<bean id="ldapAuthenticationProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider" > 
    <constructor-arg> 
     <bean class="org.springframework.security.ldap.authentication.BindAuthenticator"> 
      <constructor-arg ref="contextSource" /> 
      <property name="userSearch"> 
       <bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch"> 
        <constructor-arg index="0" value="" /> 
        <constructor-arg index="1" value="(sAMAccountName={0})" /> 
        <constructor-arg index="2" ref="contextSource" /> 
       </bean> 
      </property> 
     </bean> 
    </constructor-arg> 
    <constructor-arg> 
     <bean class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator"> 
      <constructor-arg ref="contextSource" /> 
      <constructor-arg value="" /> 
      <property name="groupSearchFilter" value="(member={0})" /> 
      <property name="searchSubtree" value="true" /> 
      <!-- Settings below convert the adds the prefix ROLE_ to roles returned from AD --> 
     </bean> 
    </constructor-arg> 
    <property name="userDetailsContextMapper"> 
     <bean class="com.example.ncc.utilities.CustomUserDetailsContextMapper" /> 
    </property> 
</bean> 

<bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager"> 
    <constructor-arg> 
     <list> 
      <ref local="ldapAuthenticationProvider" /> 
     </list> 
    </constructor-arg> 
</bean> 

<sec:http pattern="/css/**" security="none"/> 
<sec:http pattern="/images/**" security="none"/> 
<sec:http auto-config="true" authentication-manager-ref="authenticationManager" > 
    <sec:intercept-url pattern="/login.jsp*" requires-channel="https" access="IS_AUTHENTICATED_ANONYMOUSLY"/> 
    <sec:intercept-url pattern="/j_spring_security_check*" requires-channel="https" access="IS_AUTHENTICATED_ANONYMOUSLY"/> 
    <sec:intercept-url pattern="/**" requires-channel="https" access="IS_AUTHENTICATED_FULLY"/> 
    <sec:form-login login-page='/login.jsp' 
        default-target-url="/home.html" 
        authentication-failure-url="/login.jsp?error=true" /> 
</sec:http> 

我已經看到了一個shutdownTlsGracefully參數引用 spring documentation site但說實話,我不知道如何相關,這是在這種情況下, ,或者如何在spring security ldap下注入參數。

如何優雅地關閉ldap並避免潛在的內存泄漏?

回答

0

那麼我發現了錯誤線程的來源。關閉池<property name="pooled" value="false" />消除了這個問題。顯然,並不能很好地關閉優雅的關機。

我會接受這個答案,因爲它工作,沒有人迴應。如果其他人有更好/更優雅的回答,請隨時回覆,我會不接受我的。