Maven突然抛出错误,Truncated类文件

时间:2013-08-15 12:36:09

标签: java eclipse maven maven-deploy-plugin

昨天Maven工作正常,今天它显示问题,我尝试备份也不起作用,并且对于你的信息tomcat工作正常它的maven问题,我卸载maven并重新安装它以及之前的所有事情发表这个问题

{Stack trace: 
    -----------------------------------------------------------------------
    Exception in thread "main" java.lang.ClassFormatError: Truncated class file
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:30)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:588)
        at sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:239)
        at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:229)
        at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
        at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
        at java.lang.reflect.Field.declaredAnnotations(Field.java:1016)
        at java.lang.reflect.Field.getAnnotation(Field.java:1000)
        at com.google.inject.spi.InjectionPoint.getAtInject(InjectionPoint.java:468)
        at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:653)
        at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:358)
        at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:377)
        at com.google.inject.internal.BindingBuilder.toProvider(BindingBuilder.java:106)
        at com.google.inject.internal.BindingBuilder.toProvider(BindingBuilder.java:43)
        at org.sonatype.guice.plexus.binders.PlexusTypeBinder.hear(PlexusTypeBinder.java:85)
        at org.sonatype.guice.plexus.binders.PlexusXmlBeanModule.configure(PlexusXmlBeanModule.java:91)
        at org.sonatype.guice.plexus.binders.PlexusBindingModule.configure(PlexusBindingModule.java:62)
        at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
        at com.google.inject.spi.Elements.getElements(Elements.java:103)
        at com.google.inject.spi.Elements.getElements(Elements.java:80)
        at org.sonatype.guice.bean.binders.MergedModule.configure(MergedModule.java:54)
        at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
        at com.google.inject.spi.Elements.getElements(Elements.java:103)
        at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
        at com.google.inject.Guice.createInjector(Guice.java:94)
        at com.google.inject.Guice.createInjector(Guice.java:71)
        at com.google.inject.Guice.createInjector(Guice.java:61)
        at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:470)
        at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:196)
        at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:160)
        at org.apache.maven.cli.MavenCli.container(MavenCli.java:375)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:191)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)}

4 个答案:

答案 0 :(得分:6)

清理您的maven存储库:

(默认情况下在您的用户文件夹中)

~/.m2/repository

然后执行全新安装,以便再次下载依赖项并重新编译整个项目:

mvn clean install

答案 1 :(得分:1)

ClassFormatError: Truncated class file 

表示其中一个类文件已损坏。在运行clean目标之前,尝试运行install目标来执行错误的类清理。或者只是组合两个目标并为您的项目执行mvn clean install

答案 2 :(得分:0)

我可以从堆栈跟踪中看到您正在使用反射。当你正常使用它时,该课程是否正常工作?是否有可能在使用反射时,该类无法访问或被使用?

答案 3 :(得分:0)

经过所有的研究和改变,我找到了解决方案, 我更新了Maven依赖,它不起作用,

我卸载tomcat和Java然后重新安装它。

错误是Java Jdk因某些原因而被破坏我不知道为什么.....

并感谢您的所有建议