spring ldap outofmemory无法创建新的本机线程

时间:2010-08-17 09:04:26

标签: java spring ldap spring-security

HTTP Status 500 - 

--------------------------------------------------------------------------------

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: Filter execution threw an exception


root cause 

java.lang.OutOfMemoryError: unable to create new native thread
    java.lang.Thread.start0(Native Method)
    java.lang.Thread.start(Thread.java:597)
    com.sun.jndi.ldap.Connection.<init>(Connection.java:215)
    com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:118)
    com.sun.jndi.ldap.LdapClientFactory.createPooledConnection(LdapClientFactory.java:46)
    com.sun.jndi.ldap.pool.Connections.<init>(Connections.java:97)
    com.sun.jndi.ldap.pool.Pool.getPooledConnection(Pool.java:114)
    com.sun.jndi.ldap.LdapPoolManager.getLdapClient(LdapPoolManager.java:310)
    com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1572)
    com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2625)
    com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:288)
    com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
    com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
    com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
    com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
    javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
    javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    javax.naming.InitialContext.init(InitialContext.java:223)
    javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:134)
    org.springframework.ldap.core.support.LdapContextSource.getDirContextInstance(LdapContextSource.java:43)
    org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:254)
    org.springframework.ldap.core.support.AbstractContextSource.getContext(AbstractContextSource.java:106)
    org.springframework.ldap.core.LdapTemplate.authenticate(LdapTemplate.java:1434)
    org.springframework.ldap.core.LdapTemplate.authenticate(LdapTemplate.java:1386)
    com.company.iss.services.ISSServiceImpl.login(ISSServiceImpl.java:98)
    sun.reflect.GeneratedMethodAccessor358.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    $Proxy55.login(Unknown Source)
    sun.reflect.GeneratedMethodAccessor358.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    $Proxy56.login(Unknown Source)
    com.company.iss.services.UserDetailsAuthenticationProvider.retrieveUser(UserDetailsAuthenticationProvider.java:51)
    org.springframework.security.providers.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:121)
    org.springframework.security.providers.ProviderManager.doAuthentication(ProviderManager.java:188)
    org.springframework.security.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:46)
    org.springframework.security.ui.webapp.AuthenticationProcessingFilter.attemptAuthentication(AuthenticationProcessingFilter.java:82)
    org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:258)
    org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
    org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.

这是我的春天ldap设置

<property name="baseEnvironmentProperties">
    <props>
        <prop key="com.sun.jndi.ldap.connect.pool">true</prop>
        <prop key="com.sun.jndi.ldap.connect.pool.initsize">1</prop>
        <prop key="com.sun.jndi.ldap.connect.pool.maxsize">1</prop>
        <prop key="com.sun.jndi.ldap.connect.pool.prefsize">1</prop>
    <prop key="com.sun.jndi.ldap.connect.pool.timeout">300000</prop>
    </props>
</property>

任何评论为什么这会导致outofmemory?我的泳池大小只有1?

1 个答案:

答案 0 :(得分:1)

我怀疑它与LDAP或您的池大小有关。彼尔姆很可能会被填满。当你的应用程序启动时,我会打开visualvm并观察内存发生的情况,看看是不是这样。

我还会检查Tomcat日志,看看是否有比此堆栈跟踪更多,更好的信息。