Eclipse maven编译java.lang.初始化错误异常

k4ymrczo  于 2023-01-12  发布在  Maven
关注(0)|答案(1)|浏览(202)

我有一个非常奇怪的错误与Eclipse IDE的RCP和RAP开发人员版本:2020年12月(4.18.0)构建版本ID:20201210-1552.
我有一个项目(jax-ws项目),我可以用控制台构建它,使用maven 3.6.0和java 1.8。war文件创建没有问题。
但是当我尝试导入项目到eclipse,或清理eclipse中的项目时,我得到下面的错误

!ENTRY org.eclipse.m2e.logback.appender 2 0 2021-03-08 12:07:50.992
!MESSAGE Error injecting: org.codehaus.plexus.archiver.jar.JarArchiver
!STACK 0
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.plexus.archiver.jar.JarArchiver
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
...

!ENTRY org.eclipse.m2e.logback.appender 2 0 2021-03-08 12:07:51.001
!MESSAGE Error injecting: org.apache.maven.plugin.war.WarMojo
!STACK 0
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.plexus.archiver.jar.JarArchiver
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.google.inject.internal.DefaultConstructionProxyFactory$ReflectiveProxy.newInstance(DefaultConstructionProxyFactory.java:126)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
...

!ENTRY org.eclipse.core.resources 4 2 2021-03-08 12:07:51.009
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".
!STACK 0
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.plexus.archiver.jar.JarArchiver
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.google.inject.internal.DefaultConstructionProxyFactory$ReflectiveProxy.newInstance(DefaultConstructionProxyFactory.java:126)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
...

!SUBENTRY 1 org.eclipse.m2e.core 4 75 2021-03-08 12:07:51.056
!MESSAGE Errors running builder 'Maven Project Builder' on project 'webservice'.
!STACK 0
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.plexus.archiver.jar.JarArchiver
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.google.inject.internal.DefaultConstructionProxyFactory$ReflectiveProxy.newInstance(DefaultConstructionProxyFactory.java:126)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
...

它看起来像一些问题相关的codehaus.plexus插件,但如果有什么问题,我也不应该建立一个项目在maven的权利?
我也设置了eclipse使用maven 3.6.0和java1.8,但是都不起作用。尝试清理工作空间,元数据和eclipse相关的项目文件,并重新导入项目,但是没有成功。
那么,我应该在哪里搜索问题?(我有下面的依赖关系在我的m2文件夹btw)
下面您可以在pom.xml中找到构建配置

<build>
        <finalName>vc-myservice</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>1.12</version>
                <executions>
                    <execution>
                        <id>wsimport</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <verbose>true</verbose>
                            <packageName>com.myservice.verteilcenter.webservice</packageName>
                            <wsdlDirectory>${basedir}/src/main/webapp/WEB-INF/wsdl</wsdlDirectory>
                            <wsdlFiles>
                                <wsdlFile>myservice.wsdl</wsdlFile>
                            </wsdlFiles>
                            <wsdlLocation>../WEB-INF/wsdl/myservice.wsdl</wsdlLocation>
                            <extension>true</extension>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/generated-sources/xjc </source>
                                <source>${project.build.directory}/jaxws/wsimport/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>${tomcat.path}</path>
                    <update>true</update>
                    <url>${tomcat.url}</url>
                    <server>${tomcat.server}</server>
                </configuration>
            </plugin>
        </plugins>
        
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <warName>${project.build.finalname}</warName>
                        <webResources>
                            <resource>
                                <directory>${basedir}/src/main/webapp</directory>
                                <filtering>true</filtering>
                                <includes>
                                    <include>**/*.xml</include>
                                    <include>**/version</include>
                                    <!-- include any other file types you want to filter -->
                                </includes>
                            </resource>
                        </webResources>
                    </configuration>
                </plugin>
                <!--This plugin's configuration is used to store Eclipse m2e settings 
                    only. It has no influence on the Maven build itself. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.codehaus.mojo</groupId>
                                        <artifactId>jaxws-maven-plugin</artifactId>
                                        <versionRange>[1.12,)</versionRange>
                                        <goals>
                                            <goal>wsimport</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
5gfr0r5j

5gfr0r5j1#

不确定实际原因是什么,但通过在pom.xml中添加以下插件条目解决了问题。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.2.0</version>
    </plugin>

相关问题