更改Java类名并将文件从“class”重命名为“Class A”会导致java.lang.NoClassDefFoundError

时间:2013-08-20 15:03:57

标签: java eclipse jsf maven jsf-2

我有一个应用程序工作正常,但我正在重构和清理一些东西,我注意到一个类以小写字母开头,其余的以大写字母开头,所以我试图改变我的类名“classA”到“ClassA”,当我启动tomcat时,我得到下面的堆栈跟踪。

是什么给出了?

java.lang.NoClassDefFoundError: Lbackers/classA;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
    at java.lang.Class.getDeclaredFields(Class.java:1743)
    at com.sun.faces.application.annotation.ManagedBeanConfigHandler.collectAnnotatedFields(ManagedBeanConfigHandler.java:242)
    at com.sun.faces.application.annotation.ManagedBeanConfigHandler.getBeanInfo(ManagedBeanConfigHandler.java:151)
    at com.sun.faces.application.annotation.ManagedBeanConfigHandler.process(ManagedBeanConfigHandler.java:137)
    at com.sun.faces.application.annotation.ManagedBeanConfigHandler.push(ManagedBeanConfigHandler.java:123)
    at com.sun.faces.application.annotation.AnnotationManager.applyConfigAnnotations(AnnotationManager.java:200)
    at com.sun.faces.config.processor.AbstractConfigProcessor.processAnnotations(AbstractConfigProcessor.java:326)
    at com.sun.faces.config.processor.ManagedBeanConfigProcessor.process(ManagedBeanConfigProcessor.java:244)
    at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
    at com.sun.faces.config.processor.ValidatorConfigProcessor.process(ValidatorConfigProcessor.java:120)
    at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
    at com.sun.faces.config.processor.ConverterConfigProcessor.process(ConverterConfigProcessor.java:126)
    at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
    at com.sun.faces.config.processor.ComponentConfigProcessor.process(ComponentConfigProcessor.java:117)
    at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
    at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:340)
    at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
    at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:116)
    at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:222)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:361)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:216)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: backers.classA
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    ... 39 more

1 个答案:

答案 0 :(得分:1)

这是因为您仍然有一个.class文件,其中包含对旧类名的引用,或旧的小写名称出现在JSF和/或Tomcat配置文件中。在所有文件中搜索classA,区分大小写的完整工作区,以查找错误的参考。