eclipse java.lang.ClassNotFoundException: fr.bordeaux.contactapp.Exceptions.AuthenticationException 重命名包后
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29519169/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.ClassNotFoundException: fr.bordeaux.contactapp.Exceptions.AuthenticationException after renaming package
提问by NIF
I move/rename the package where my servlet are and I get this error :
我移动/重命名我的 servlet 所在的包,但出现此错误:
java.lang.ClassNotFoundException: fr.bordeaux.contactapp.Exceptions.AuthenticationException
java.lang.ClassNotFoundException: fr.bordeaux.contactapp.Exceptions.AuthenticationException
I'm new to Eclipse and Java. I undo the rename but errors persist. Everybody have an idea that I have to do ?
我是 Eclipse 和 Java 的新手。我撤消了重命名,但错误仍然存在。每个人都有一个想法,我必须做什么?
Thanks for your help.
谢谢你的帮助。
There are the trace here :
这里有痕迹:
Caused by: java.lang.NoClassDefFoundError: fr/bordeaux/contactapp/Exceptions/AuthenticationException
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2499)
at java.lang.Class.getDeclaredFields(Class.java:1811)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:256)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:132)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:334)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:774)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5053)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
Caused by: java.lang.ClassNotFoundException: fr.bordeaux.contactapp.Exceptions.AuthenticationException
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
... 20 more
回答by Phil Hayward
I'm using an older version of Tomcat, so this may or may not help.
我使用的是旧版本的 Tomcat,所以这可能有帮助,也可能没有帮助。
Check for a file named web.xml within the WEB-INF folder. I'm using Netbeans, so for me it's under src/main/webapp/WEB-INF - Eclipse may place it elsewhere.
在 WEB-INF 文件夹中检查名为 web.xml 的文件。我正在使用 Netbeans,所以对我来说它在 src/main/webapp/WEB-INF 下 - Eclipse 可能会将它放在其他地方。
Within that file, you specify the classes used to run your servlet or filter. It's possible that your refactor did not modify the contents of the web.xml file.
在该文件中,您指定用于运行 servlet 或过滤器的类。您的重构可能没有修改 web.xml 文件的内容。
Good luck!
祝你好运!
回答by YosefY
What you need to focus on in your error stacktrace is : Caused by: java.lang.NoClassDefFoundError: fr/bordeaux/contactapp/Exceptions/AuthenticationException
您需要在错误堆栈跟踪中关注的是: 引起: java.lang.NoClassDefFoundError: fr/bordeaux/contactapp/Exceptions/AuthenticationException
Is seems that you are still referencing the class AuthenticationException In the package fr.bordeaux.contactapp.Exceptions And this class doesn't exist there...
似乎你仍然在引用类 AuthenticationException 在包 fr.bordeaux.contactapp.Exceptions 并且这个类不存在那里......
PS1: java is case sensitive Ps2: by convention, packages in Java are lowercase
PS1:java 区分大小写 Ps2:按照惯例,Java 中的包是小写的
回答by Abhishek Mani
in my case the error was fixed by adding "/" in url-pattern ,which i forgot to use.After adding "/" the server started successfully. eg
在我的情况下,错误是通过在 url-pattern 中添加“/”来修复的,我忘记使用它。添加“/”后,服务器成功启动。例如
<servlet-mapping>
<servlet-name>imp_servlet</servlet-name>
<url-pattern>/implement_servlet</url-pattern>
</servlet-mapping>