ClassNotFoundException with Guice 2.0

我是研究僧i 提交于 2019-11-30 13:50:13

You have missed to include a dependency jar with the class org.aopalliance.intercept.MethodInterceptor in the classpath.

Brad Cupit

as Boris Pavlović mentions in his answer, you're missing a jar. Specifically the aopalliance.jar file, which comes in the guice zip file

Alternatively, you might try using guice-2.0-no_aop.jar, but I'm not sure if that will work.

Adding this file to the classpath depends on which tool you use to run your java code.

  • If you are running java from the command line:
windows: java -cp aopalliance.jar;guice-2.0.jar;other_jars.jar YourMainClass
*nix:    java -cp aopalliance.jar:guice-2.0.jar:other_jars.jar YourMainClass
  • If you are running java from Eclipse, typically you'll have some type of lib/ directory. Put your jar there, then right-click on the jar -> Build Path -> Add to Build Path

I run into this problem yesterday, the dependency is managed by Maven, so the aopalliance.jar is in classpath with no doubt.

Update jetty from version 6.1.10 to 6.1.26 fixed the problem.

The real problem here is the container does not support aopalliance.jar. I hope that will help someone there desperately looking for a solution.

Leo Zhao

I run into this problem today. Actually the tomcat can not find the class in its lib. So just copy the aopalliance.jar into the lib folder in tomcat ,that's enough.

Adding the below jars works fine for me.
javax.inject.jar
guice-3.0-no_aop.jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!