Обновление maven в Eclipse: не удалось обновить проект

Я делаю первые шаги в REST с помощью Джерси, следуя здесь, используя m2e. Он отлично работает на tomcat 10.1 после нескольких адаптаций к tomcat 10 и Java-17.

Теперь я хотел бы сделать следующий шаг и добавить что-то новое в pom.xml. Но выполнение Maven/Update Project... приводит к сообщению об ошибке:

Could not update project HelloREST configuration
Cannot invoke "org.eclipse.wst.common.componentcore.internal.WorkbenchComponent.findResourcesByRuntimePath(org.eclipse.core.runtime.IPath)"
because "aComponent" is null

Кроме того, журнал ошибок также показывает

eclipse.buildId=4.26.0.20221201-1200
java.version=17.0.5
java.vendor=Eclipse Adoptium
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product

org.eclipse.m2e.logback.appender
Error
Tue Feb 07 13:19:45 CET 2023
HelloREST/.settings/org.eclipse.wst.common.component is missing or invalid. Skipping module dependency configuration. Deployment issues may arise.

и

eclipse.buildId=4.26.0.20221201-1200
java.version=17.0.5
java.vendor=Eclipse Adoptium
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product

org.eclipse.wst.common.frameworks
Error
Tue Feb 07 13:19:45 CET 2023
Cannot invoke "org.eclipse.wst.common.componentcore.internal.WorkbenchComponent.getProperties()" because "component" is null

java.lang.NullPointerException: Cannot invoke "org.eclipse.wst.common.componentcore.internal.WorkbenchComponent.getProperties()" because "component" is null
    at org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent.setMetaProperty(VirtualComponent.java:285)
    at org.eclipse.wst.common.componentcore.internal.operation.ServerContextRootUpdateOperation.execute(ServerContextRootUpdateOperation.java:40)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl$1.run(DataModelPausibleOperationImpl.java:385)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2380)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2405)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:410)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:360)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.doExecute(DataModelPausibleOperationImpl.java:247)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.executeImpl(DataModelPausibleOperationImpl.java:219)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.cacheThreadAndContinue(DataModelPausibleOperationImpl.java:89)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.execute(DataModelPausibleOperationImpl.java:207)
    at org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities.setServerContextRoot(ComponentUtilities.java:337)
    at org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities.setServerContextRoot(J2EEProjectUtilities.java:948)
    at org.eclipse.m2e.wtp.WebProjectConfiguratorDelegate.configure(WebProjectConfiguratorDelegate.java:157)
    at org.eclipse.m2e.wtp.AbstractProjectConfiguratorDelegate.configureProject(AbstractProjectConfiguratorDelegate.java:88)
    at org.eclipse.m2e.wtp.WTPProjectConfigurator.configure(WTPProjectConfigurator.java:70)
    at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:123)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$6(ProjectConfigurationManager.java:494)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:364)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:274)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:488)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$4(ProjectConfigurationManager.java:416)
    at java.base/java.util.Collection.removeIf(Collection.java:576)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:410)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.lambda$3(ProjectConfigurationManager.java:340)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:364)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:274)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:213)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1102)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:339)
    at org.eclipse.m2e.core.ui.internal.UpdateMavenProjectJob.runInWorkspace(UpdateMavenProjectJob.java:80)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Других проблем пока не вижу, но они могут появиться. Любая идея, что может быть причиной?

Сообщения об ошибках не исчезают, когда я пытаюсь уменьшить проект, даже если я удаляю .metadata и перезапускаю Eclipse.

Пом.xml:

<project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>net.codejava</groupId>
    <artifactId>HelloREST</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>HelloREST</name>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>17</release>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <warName>HelloREST</warName>
                    <outputDirectory>/opt/tomcat/webapps/</outputDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet</artifactId>
            <version>3.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.inject</groupId>
            <artifactId>jersey-hk2</artifactId>
            <version>3.1.1</version>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>4.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>4.0.1</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
</project>

134
1

Ответ:

Решено

Следующие шаги решили мою проблему:

  1. Удаление проекта из Eclipse Project Explorer, но не из файловой системы.
  2. Удаление папки .settings в файловой системе
  3. Снова импортируйте проект как существующий проект Maven.

=====

Я исследовал немного глубже. Нашел причину с 2 файлом в папке .settings:

  1. org.eclipse.wst.common.component
  2. org.eclipse.wst.common.project.facet.core.xml

Первый был почти пуст. Только

<?xml version = "1.0" encoding = "UTF-8"?><project-modules id = "moduleCoreId"/>

Во второй была строка

 <installed facet = "jst.web" version = "5.0"/>

Удаление этой строки и повторный импорт проекта заменили ее на

<installed facet = "jst.web" version = "2.5"/>

и заполнил первый файл

<?xml version = "1.0" encoding = "UTF-8"?><project-modules id = "moduleCoreId" project-version = "1.5.0">
    <wb-module deploy-name = "HelloREST">
        <wb-resource deploy-path = "/" source-path = "/target/m2e-wtp/web-resources"/>
        <wb-resource deploy-path = "/" source-path = "/src/main/webapp" tag = "defaultRootSource"/>
        <wb-resource deploy-path = "/WEB-INF/classes" source-path = "/src/main/java"/>
        <property name = "context-root" value = "HelloREST"/>
        <property name = "java-output-path" value = "/HelloREST/target/classes"/>
    </wb-module>
</project-modules>

Я понятия не имею об этом, но два вопроса все еще остаются без ответа (в настоящее время не очень важны для меня):

  • Как файлы .settings были искажены?
  • Почему Eclipse Import Existing Maven Project просматривает файлы .settings, хотя он работает так же, когда файлы .settings удаляются?

@nitind: Из https://github.com/rolfschumacher/RoS-HelloREST.git вы можете git клонировать ошибочный проект.