java.lang.NullPointerException

Spring JIRA | Jan Heuer | 7 years ago
  1. 0

    I'm using spring security to secure my service. Here is a sample secured method: public interface Foo<T extends MyModel> { @PreAuthorize("hasPermission(#item, 'create')") public T create(T item); } In my junit test I get a NullPointerException when spring parses the EL: java.lang.NullPointerException at org.springframework.security.access.expression.method.MethodSecurityEvaluationContext.addArgumentsAsVariables(MethodSecurityEvaluationContext.java:66) at org.springframework.security.access.expression.method.MethodSecurityEvaluationContext.lookupVariable(MethodSecurityEvaluationContext.java:48) at org.springframework.expression.spel.ExpressionState.lookupVariable(ExpressionState.java:122) at org.springframework.expression.spel.ast.VariableReference.getValueInternal(VariableReference.java:52) at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:59) at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:98) at org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:11) at org.springframework.security.access.expression.method.ExpressionBasedPreInvocationAdvice.before(ExpressionBasedPreInvocationAdvice.java:42) at org.springframework.security.access.prepost.PreInvocationAuthorizationAdviceVoter.vote(PreInvocationAuthorizationAdviceVoter.java:55) at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:50) at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:204) at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:65) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy25.create(Unknown Source) [snip here comes the junit invocation part] Debugging the offending code, I noticed that: org.springframework.core.LocalVariableTableParameterNameDiscoverer#getParameterNames(Method method) returns null. I guess it is because the method's parameter type is Generic. Can I fix it? Do you have any idea where in the class it's going "wrong" ? I'd be happy to fix it and submitt a patch but I', not sure where I have to change the code. Cheers, Jan

    Spring JIRA | 7 years ago | Jan Heuer
    java.lang.NullPointerException
  2. 0

    I'm using spring security to secure my service. Here is a sample secured method: public interface Foo<T extends MyModel> { @PreAuthorize("hasPermission(#item, 'create')") public T create(T item); } In my junit test I get a NullPointerException when spring parses the EL: java.lang.NullPointerException at org.springframework.security.access.expression.method.MethodSecurityEvaluationContext.addArgumentsAsVariables(MethodSecurityEvaluationContext.java:66) at org.springframework.security.access.expression.method.MethodSecurityEvaluationContext.lookupVariable(MethodSecurityEvaluationContext.java:48) at org.springframework.expression.spel.ExpressionState.lookupVariable(ExpressionState.java:122) at org.springframework.expression.spel.ast.VariableReference.getValueInternal(VariableReference.java:52) at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:59) at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:98) at org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:11) at org.springframework.security.access.expression.method.ExpressionBasedPreInvocationAdvice.before(ExpressionBasedPreInvocationAdvice.java:42) at org.springframework.security.access.prepost.PreInvocationAuthorizationAdviceVoter.vote(PreInvocationAuthorizationAdviceVoter.java:55) at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:50) at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:204) at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:65) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy25.create(Unknown Source) [snip here comes the junit invocation part] Debugging the offending code, I noticed that: org.springframework.core.LocalVariableTableParameterNameDiscoverer#getParameterNames(Method method) returns null. I guess it is because the method's parameter type is Generic. Can I fix it? Do you have any idea where in the class it's going "wrong" ? I'd be happy to fix it and submitt a patch but I', not sure where I have to change the code. Cheers, Jan

    Spring JIRA | 7 years ago | Jan Heuer
    java.lang.NullPointerException
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.springframework.security.access.expression.method.MethodSecurityEvaluationContext.addArgumentsAsVariables()
    2. spring-security-core
      MethodSecurityEvaluationContext.lookupVariable
      1. org.springframework.security.access.expression.method.MethodSecurityEvaluationContext.addArgumentsAsVariables(MethodSecurityEvaluationContext.java:66)
      2. org.springframework.security.access.expression.method.MethodSecurityEvaluationContext.lookupVariable(MethodSecurityEvaluationContext.java:48)
      2 frames
    3. Spring Expression Language (SpEL)
      SpelExpression.getValue
      1. org.springframework.expression.spel.ExpressionState.lookupVariable(ExpressionState.java:122)
      2. org.springframework.expression.spel.ast.VariableReference.getValueInternal(VariableReference.java:52)
      3. org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:59)
      4. org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
      5. org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:98)
      5 frames
    4. spring-security-core
      MethodSecurityInterceptor.invoke
      1. org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:11)
      2. org.springframework.security.access.expression.method.ExpressionBasedPreInvocationAdvice.before(ExpressionBasedPreInvocationAdvice.java:42)
      3. org.springframework.security.access.prepost.PreInvocationAuthorizationAdviceVoter.vote(PreInvocationAuthorizationAdviceVoter.java:55)
      4. org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:50)
      5. org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:204)
      6. org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:65)
      6 frames
    5. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      2 frames
    6. Unknown
      $Proxy25.create
      1. $Proxy25.create(Unknown Source)
      1 frame