NoSuchMethodError: javax.ws.rs.core.MultivaluedMap.addAll - PullRequest
0 голосов
/ 17 мая 2018

Я занимаюсь разработкой динамического веб-приложения на Java (1.8) на основе Джерси и использую Maven для определения зависимостей.Я работаю в Eclipse Oxygen с использованием Tomcat 9. Я новичок как в разработке веб-приложений, так и в Maven, поэтому я изо всех сил пытаюсь понять, как заставить все работать.

Когда я запускаю приложение, оно завершается с ошибкой, показанной ниже.Я прочитал несколько статей.Эта ошибка, по-видимому, связана с несоответствием между средой времени компиляции и средой времени выполнения.

Я пытался изменить версии различных компонентов, надеясь найти правильную комбинацию, но безуспешно.Я также попытался удалить .m2 / repository и запустить Maven / Update Project, чтобы обновить среду, но это не помогло.Возможно, кто-то с большим опытом может обнаружить источник несовместимости в моем файле pom.xml.

java.lang.NoSuchMethodError: javax.ws.rs.core.MultivaluedMap.addAll(Ljava/lang/Object;[Ljava/lang/Object;)V
    at org.glassfish.jersey.client.ClientRequest.accept(ClientRequest.java:335)
    at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:222)
    at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:60)
    at com.simfinit.client.SimDcmClient.get(SimDcmClient.java:36)
    at com.simfinit.client.SimDcmClientTest.testGetList(SimDcmClientTest.java:19)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)

Вот мой файл pom.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 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.simfinit.resources</groupId>
    <artifactId>SimWebServiceDcm</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>SimWebServiceDcm</name>

    <build>
        <finalName>SimWebServiceDcm</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <inherited>true</inherited>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey</groupId>
                <artifactId>jersey-bom</artifactId>
                <version>${jersey.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
            <!-- artifactId>jersey-container-servlet</artifactId -->
        </dependency>
        <!-- uncomment this to get JSON support -->
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <version>${jersey.version}</version>
        </dependency>

<!--        <dependency>
            <groupId>org.glassfish.jersey.inject</groupId>
            <artifactId>jersey-hk2</artifactId>
            <version>${jersey.version}</version>
        </dependency>
 -->
        <dependency>
            <groupId>com.simfinit</groupId>
            <artifactId>SimService</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.simfinit</groupId>
            <artifactId>SimCommunication</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.simfinit</groupId>
            <artifactId>SimServiceDcm</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.simfinit</groupId>
            <artifactId>SimBase</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

    </dependencies>
    <properties>
        <jersey.version>2.26</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

Я пытался использовать "mvn"Зависимость: дерево "для выявления возможных конфликтов.Эта команда вернула ошибку:

[ERROR] No plugin found for prefix 'dependency' in the current project and in the plugin groups...

Я прочитал справочную статью и другие статьи, в которых предлагалось удалить папку .m2 / repository и повторить команду mvn.Там результат показан ниже.Эти ошибки указывают на то, что я указал неверный номер версии в файле pom?Я полагаю, что эта информация должна помочь мне, но я не знаю, каким должен быть следующий шаг.Содержание моего pom взято из других статей, но может быть действительным только для определенных версий.Я добавлял и заменял pom-зависимости, не зная, как определить совместимость изменений.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.758 s
[INFO] Finished at: 2018-05-17T14:56:56-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'help' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\Kent\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

E:\GitRepositories\simfiniclient\SimWebServiceDcm>mvn help:active-profiles
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/glassfish/jersey/jersey-bom/2.26/jersey-bom-2.26.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Could not transfer artifact org.glassfish.jersey:jersey-bom:pom:2.26 from/to central (https://repo.maven.apache.org/maven2): Permission denied: connect @ line 31, column 16
[ERROR] 'dependencies.dependency.version' for org.glassfish.jersey.containers:jersey-container-servlet-core:jar is missing. @ line 47, column 15
[ERROR] 'dependencies.dependency.version' for org.glassfish.jersey.media:jersey-media-moxy:jar is missing. @ line 54, column 15
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project com.simfinit.resources:SimWebServiceDcm:1.0-SNAPSHOT (E:\GitRepositories\simfiniclient\SimWebServiceDcm\pom.xml) has 3 errors
[ERROR]     Non-resolvable import POM: Could not transfer artifact org.glassfish.jersey:jersey-bom:pom:2.26 from/to central (https://repo.maven.apache.org/maven2): Permission denied: connect @ line 31, column 16 -> [Help 2]
[ERROR]     'dependencies.dependency.version' for org.glassfish.jersey.containers:jersey-container-servlet-core:jar is missing. @ line 47, column 15
[ERROR]     'dependencies.dependency.version' for org.glassfish.jersey.media:jersey-media-moxy:jar is missing. @ line 54, column 15
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

1 Ответ

0 голосов
/ 18 мая 2018

Эта ошибка действительно происходит из-за несоответствия между версиями зависимостей во время компиляции и во время выполнения, но она может быть не полностью на стороне maven.

Прежде всего: сделайте mvn dependency:tree и ищите jax-WS.Если вы найдете несколько из них с разными версиями: исключите их в pom, используя параметр исключения .

Если вы ничего не нашли или это не помогло: проверьте установку и настройку tomcat(папки, такие как libs или дополнительные банки добавляются во время запуска).Как только у меня возникла такая проблема с Guava, я использовал 23.0, а мой сервер приложений использовал 12.0, и он имел приоритет над моим.

Если это не помогает проверить вашу папку JDK и endorsed, возможно, выесть что-то дополнительное.

Никогда не работал с новейшими версиями JavaEE и Tomcat, но, возможно, здесь помогут общие решения.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...