java.lang.NullPointerException

Spring JIRA | Gert Buys | 7 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    If have the following intercept-url defined in my security config (with expressions): <security:intercept-url pattern="/.*/${webapp.context}/flow/welcome" access="hasRole('ROLE_USER')" /> I also use role hierarchies. After authentication the user arrives at the welcome page. When the user hasn't got any authorities, I receive a NPE because in RoleHierarchyImpl, which is called by SecurityExpressionRoot, the empty authorities Set is set to null: public Collection<GrantedAuthority> getReachableGrantedAuthorities(Collection<GrantedAuthority> authorities) { if (authorities == null || authorities.isEmpty()) { return null; } In AuthorityUtils, the size() method is called on the null collection: public static Set<String> authorityListToSet(Collection<GrantedAuthority> userAuthorities) { Set<String> set = new HashSet<String>(userAuthorities.size()); java.lang.NullPointerException at org.springframework.security.core.authority.AuthorityUtils.authorityListToSet(AuthorityUtils.java:39) at org.springframework.security.access.expression.SecurityExpressionRoot.getAuthoritySet(SecurityExpressionRoot.java:104) at org.springframework.security.access.expression.SecurityExpressionRoot.hasAnyRole(SecurityExpressionRoot.java:44) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:58) at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:76) at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)<security:intercept-url pattern="/.*

    Spring JIRA | 7 years ago | Gert Buys
    java.lang.NullPointerException
  2. 0

    If have the following intercept-url defined in my security config (with expressions): <security:intercept-url pattern="/.*/${webapp.context}/flow/welcome" access="hasRole('ROLE_USER')" /> I also use role hierarchies. After authentication the user arrives at the welcome page. When the user hasn't got any authorities, I receive a NPE because in RoleHierarchyImpl, which is called by SecurityExpressionRoot, the empty authorities Set is set to null: public Collection<GrantedAuthority> getReachableGrantedAuthorities(Collection<GrantedAuthority> authorities) { if (authorities == null || authorities.isEmpty()) { return null; } In AuthorityUtils, the size() method is called on the null collection: public static Set<String> authorityListToSet(Collection<GrantedAuthority> userAuthorities) { Set<String> set = new HashSet<String>(userAuthorities.size()); java.lang.NullPointerException at org.springframework.security.core.authority.AuthorityUtils.authorityListToSet(AuthorityUtils.java:39) at org.springframework.security.access.expression.SecurityExpressionRoot.getAuthoritySet(SecurityExpressionRoot.java:104) at org.springframework.security.access.expression.SecurityExpressionRoot.hasAnyRole(SecurityExpressionRoot.java:44) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:58) at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:76) at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)<security:intercept-url pattern="/.*

    Spring JIRA | 7 years ago | Gert Buys
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.springframework.security.core.authority.AuthorityUtils.authorityListToSet()
    2. spring-security-core
      SecurityExpressionRoot.hasAnyRole
      1. org.springframework.security.core.authority.AuthorityUtils.authorityListToSet(AuthorityUtils.java:39)
      2. org.springframework.security.access.expression.SecurityExpressionRoot.getAuthoritySet(SecurityExpressionRoot.java:104)
      3. org.springframework.security.access.expression.SecurityExpressionRoot.hasAnyRole(SecurityExpressionRoot.java:44)
      3 frames
    3. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    4. Spring Expression Language (SpEL)
      MethodReference.getValueInternal
      1. org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:58)
      2. org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:76)
      2 frames