java.lang.IllegalArgumentException

tip

If you're unit testing, you should instantiate only the service and mock the dependencies. If you're testing integration, you should add all the mocking to the configurations file.

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • Folks , I'm not sure if this is a bug or an improvement , I initially make it as a Bug , please excuse me if this is against the Spring work as designed context. the issue is like the following : 1-I had developped an AspectJ Aspect which is suppose to match methods annotated with @RolesAllowed annotation. 2-after compiling the classes with Maven aspectJ plugin, and configuring the spring security to run in aspectj mode , the classes are weawed (compile time ). 3-the aim of enabling aspectj mode is ,to avoid going throw the proxy that the default Spring aop alliance uses , so then , internal method calls could be intercepted and not gone throw the proxy . 4-let's take a simple test case : @RolesAllowed("NON_PREMIUM_USER") public void SecMethA() { SecMethB(); } @RolesAllowed("PREMIUM_USER") public void SecMethB() { System.out.println("I'm safe, I do not need to worry "); } => if a user having the Role NON_PREMIUM_USER , and calls SecMethA(),every thing works as expected ,and the aspect is matched, than Spring security throws an accessDenied exception . but when I switch the type of SecMethB() to private , I have the below exception : java.lang.IllegalArgumentException: Could not obtain target method from JoinPoint: 'execution(void test.SecMethB())' at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.security.access.intercept.aspectj.MethodInvocationAdapter.<init>(MethodInvocationAdapter.java:38) at org.springframework.security.access.intercept.aspectj.AspectJMethodSecurityInterceptor.invoke(AspectJMethodSecurityInterceptor.java:27) I suppose the
    via by Anis Moussa,
  • Folks , I'm not sure if this is a bug or an improvement , I initially make it as a Bug , please excuse me if this is against the Spring work as designed context. the issue is like the following : 1-I had developped an AspectJ Aspect which is suppose to match methods annotated with @RolesAllowed annotation. 2-after compiling the classes with Maven aspectJ plugin, and configuring the spring security to run in aspectj mode , the classes are weawed (compile time ). 3-the aim of enabling aspectj mode is ,to avoid going throw the proxy that the default Spring aop alliance uses , so then , internal method calls could be intercepted and not gone throw the proxy . 4-let's take a simple test case : @RolesAllowed("NON_PREMIUM_USER") public void SecMethA() { SecMethB(); } @RolesAllowed("PREMIUM_USER") public void SecMethB() { System.out.println("I'm safe, I do not need to worry "); } => if a user having the Role NON_PREMIUM_USER , and calls SecMethA(),every thing works as expected ,and the aspect is matched, than Spring security throws an accessDenied exception . but when I switch the type of SecMethB() to private , I have the below exception : java.lang.IllegalArgumentException: Could not obtain target method from JoinPoint: 'execution(void test.SecMethB())' at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.security.access.intercept.aspectj.MethodInvocationAdapter.<init>(MethodInvocationAdapter.java:38) at org.springframework.security.access.intercept.aspectj.AspectJMethodSecurityInterceptor.invoke(AspectJMethodSecurityInterceptor.java:27) I suppose the
    via by Anis Moussa,
  • Spring Boot test class wont inject beans
    via Stack Overflow by rayman
    ,
  • Spring file upload by ajax
    via Stack Overflow by kris14an
    ,
  • mybatis + spring failed to start
    via by Hain Bach,
    • java.lang.IllegalArgumentException: Could not obtain target method from JoinPoint: 'execution(void test.SecMethB())' at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.security.access.intercept.aspectj.MethodInvocationAdapter.<init>(MethodInvocationAdapter.java:38) at org.springframework.security.access.intercept.aspectj.AspectJMethodSecurityInterceptor.invoke(AspectJMethodSecurityInterceptor.java:27)

    Users with the same issue

    osvzsosvzs
    2 times, last one,
    oddodd
    2 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    mauritiusmauritius
    1 times, last one,
    189 more bugmates