nydiarra / springboot-jwt

Example Springboot Application for Securing a REST API with JSON Web Token (JWT). For an example Integration with Angular (version 2+) go to https://github.com/ipassynk/angular-springboot-jwt
547 stars 328 forks source link

java.lang.ClassNotFoundException: org.springframework.security.web.access.WebInvocationPrivilegeEvaluator #9

Open Verdoso opened 6 years ago

Verdoso commented 6 years ago

Hi there, I've tried applying what it's explained in the blog to my simple project and that's the error I got when I tried to start the application. I then tried with this project and I just download and run "mvn clean install" and I get the same error. Inside eclipse and using the console, the same error:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.63 sec <<< FAILURE! - in com.nouhoun.springboot.jwt.integration.SpringbootJwtApplicationTests contextLoads(com.nouhoun.springboot.jwt.integration.SpringbootJwtApplicationTests) Time elapsed: 0.002 sec <<< ERROR! java.lang.NoClassDefFoundError: org/springframework/security/web/access/WebInvocationPrivilegeEvaluator at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.getDeclaredMethods(Class.java:1975) at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510) at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:697) at ... Caused by: java.lang.ClassNotFoundException: org.springframework.security.web.access.WebInvocationPrivilegeEvaluator at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.getDeclaredMethods(Class.java:1975) at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510) at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:697) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:640) at ...

I checked and the class is indeed there, inside the dependencies....

Could this be related to Maven or JDK version? Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T15:51:42+02:00) Java version: 1.8.0_74, vendor: Oracle Corporation

So weird...

Thanks!

Verdoso commented 6 years ago

Just so you know, updating spring-boot-starter-parent to 1.5.9, made the issue go away. Even though then it fails with another error:

Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'corsFilter' is expected to be of type 'org.springframework.web.filter.CorsFilter' but was actually of type 'org.springframework.boot.web.servlet.FilterRegistrationBean'

At least I can move a bit further with my app.

O_o

ShanGor commented 6 years ago

Did you named the filter name as corsFilter? if so, you can tried to change the function name from corsFilter to simpleCorsFilter. It worths a shot..

Verdoso commented 6 years ago

I was not using the cors filter, so it was not an issue for me and I did not try to fix it in springboot-jwt. In the end I'm not using JWT at all so, I had to deal with other issues.