简体   繁体   English

Maven突然抛出错误,截断了类文件

[英]Maven is suddenly throwing error, Truncated class file

Yesterday Maven is working fine,,today it shows that problem,I tried backup also it does not work ,and for your information tomcat is working fine its a maven problem ,and I uninstall maven and install it again and all things before posting this question 昨天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)}

Clean your maven repository: 清理您的Maven存储库:

(By default in your user folder) (默认情况下,在您的用户文件夹中)

~/.m2/repository

Then perform a clean install so it download the dependencies again and recompile your entire project: 然后执行全新安装,以便它再次下载依赖项并重新编译整个项目:

mvn clean install
ClassFormatError: Truncated class file 

means that one of the class file is corrupted. 表示其中一个类文件已损坏。 Try to run clean goal to do the bad classes cleanup before you run the install target. 在运行install目标之前,请尝试运行clean目标以进行错误的类清理。 Or simply combine both the targets and do mvn clean install for your project. 或简单地组合两个目标并为您的项目进行mvn clean install

I can see from your stac-trace that you are using reflection. 从您的笔迹中可以看到您正在使用反射。 Is the class working when you use it normally? 正常使用该类时,该类是否正常工作? Is it possible that when you use reflection, the class is unreachable or mis-used? 使用反射时,类是否可能无法访问或使用不当?

After all the research and changing things, i found the solution, I updated Maven dependency,it doesn't work, 经过所有的研究和不断变化的东西,我找到了解决方案,更新了Maven依赖关系,它不起作用,

I uninstall tomcat and Java and then reinstall it. 我卸载了tomcat和Java,然后重新安装了它。

And the error is that Java Jdk is corrupted due to some reason i Dont Know it why..... 错误是Java Jdk由于某种原因而损坏,我不知道为什么。

and thanks all for your suggestions 并感谢大家的建议

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM