gpt4 book ai didi

java - 异常(exception)是 REST Jersey

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:53:44 26 4
gpt4 key购买 nike

我是新手。我正在尝试制作一个网络应用程序。它在本地运行良好,但是当我将它部署在 Heroku 上并在此处尝试时,问题就来了:

java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:298)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:698)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:519)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:564)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:213)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1097)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:446)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1031)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:445)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:269)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:229)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532)
at java.lang.Thread.run(Thread.java:745)

我的 pom 文件是:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-core_2.10</artifactId>
<version>1.3.11</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<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>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson1</artifactId>
<version>2.22.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-bundle</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.socrata</groupId>
<artifactId>soda-api-java</artifactId>
<version>0.9.12</version>
</dependency>
</dependencies>

<build>
<finalName>FoodTrucks</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>1.0.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>compile</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<contextPath>/</contextPath>
<webApp>
<contextPath>/</contextPath>
<webInfIncludeJarPattern>.*/.*jersey-[^/]\.jar$</webInfIncludeJarPattern>
</webApp>
<war>${project.build.directory}/${project.build.finalName}.war</war>
</configuration>
</plugin>
</plugins>
</build>

关于如何解决这个问题的任何想法?如果我应该添加另一个文件以便您找出问题,请告诉我。我已经为此工作了 2 天。

--更新--

这是maven依赖列表

remote:        [INFO] Copying guava-12.0.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/guava-12.0.jar
remote: [INFO] Copying jersey-server-2.22.2.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-server-2.22.2.jar
remote: [INFO] Copying javassist-3.18.1-GA.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/javassist-3.18.1-GA.jar
remote: [INFO] Copying mimepull-1.6.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/mimepull-1.6.jar
remote: [INFO] Copying jsr305-1.3.9.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jsr305-1.3.9.jar
remote: [INFO] Copying commons-beanutils-1.8.3.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/commons-beanutils-1.8.3.jar
remote: [INFO] Copying hk2-locator-2.4.0-b34.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/hk2-locator-2.4.0-b34.jar
remote: [INFO] Copying soda-api-java-0.9.12.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/soda-api-java-0.9.12.jar
remote: [INFO] Copying jersey-container-servlet-core-2.22.2.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-container-servlet-core-2.22.2.jar
remote: [INFO] Copying jersey-common-2.22.2.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-common-2.22.2.jar
remote: [INFO] Copying jetty-security-9.0.6.v20130930.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jetty-security-9.0.6.v20130930.jar
remote: [INFO] Copying jersey-bundle-1.9.1.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-bundle-1.9.1.jar
remote: [INFO] Copying jackson-jaxrs-1.9.13.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jackson-jaxrs-1.9.13.jar
remote: [INFO] Copying joda-time-2.1.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/joda-time-2.1.jar
remote: [INFO] Copying commons-logging-1.1.1.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/commons-logging-1.1.1.jar
remote: [INFO] Copying jersey-client-2.22.2.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-client-2.22.2.jar
remote: [INFO] Copying validation-api-1.1.0.Final.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/validation-api-1.1.0.Final.jar
remote: [INFO] Copying jetty-webapp-9.0.6.v20130930.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jetty-webapp-9.0.6.v20130930.jar
remote: [INFO] Copying jersey-container-servlet-2.22.2.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-container-servlet-2.22.2.jar
remote: [INFO] Copying osgi-resource-locator-1.0.1.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/osgi-resource-locator-1.0.1.jar
remote: [INFO] Copying jackson-xc-1.9.13.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jackson-xc-1.9.13.jar
remote: [INFO] Copying jersey-guava-2.22.2.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-guava-2.22.2.jar
remote: [INFO] Copying jackson-mapper-asl-1.9.13.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jackson-mapper-asl-1.9.13.jar
remote: [INFO] Copying javax.inject-2.4.0-b34.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/javax.inject-2.4.0-b34.jar
remote: [INFO] Copying opencsv-2.0.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/opencsv-2.0.jar
remote: [INFO] Copying jetty-server-9.0.6.v20130930.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jetty-server-9.0.6.v20130930.jar
remote: [INFO] Copying jetty-io-9.0.6.v20130930.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jetty-io-9.0.6.v20130930.jar
remote: [INFO] Copying hk2-api-2.4.0-b34.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/hk2-api-2.4.0-b34.jar
remote: [INFO] Copying jetty-util-9.0.6.v20130930.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jetty-util-9.0.6.v20130930.jar
remote: [INFO] Copying aopalliance-repackaged-2.4.0-b34.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/aopalliance-repackaged-2.4.0-b34.jar
remote: [INFO] Copying jetty-http-9.0.6.v20130930.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jetty-http-9.0.6.v20130930.jar
remote: [INFO] Copying jackson-core-asl-1.9.13.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jackson-core-asl-1.9.13.jar
remote: [INFO] Copying jersey-multipart-1.9.1.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-multipart-1.9.1.jar
remote: [INFO] Copying hk2-utils-2.4.0-b34.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/hk2-utils-2.4.0-b34.jar
remote: [INFO] Copying jetty-xml-9.0.6.v20130930.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jetty-xml-9.0.6.v20130930.jar
remote: [INFO] Copying jersey-media-json-jackson1-2.22.2.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-media-json-jackson1-2.22.2.jar
remote: [INFO] Copying commons-lang3-3.1.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/commons-lang3-3.1.jar
remote: [INFO] Copying jsr311-api-1.1.1.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jsr311-api-1.1.1.jar
remote: [INFO] Copying jersey-media-jaxb-2.22.2.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-media-jaxb-2.22.2.jar
remote: [INFO] Copying jersey-core-1.9.1.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jersey-core-1.9.1.jar
remote: [INFO] Copying jetty-servlet-9.0.6.v20130930.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/jetty-servlet-9.0.6.v20130930.jar
remote: [INFO] Copying commons-io-1.3.2.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/commons-io-1.3.2.jar
remote: [INFO] Copying javax.annotation-api-1.2.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/javax.annotation-api-1.2.jar
remote: [INFO] Copying javax.servlet-3.0.0.v201112011016.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/javax.servlet-3.0.0.v201112011016.jar
remote: [INFO] Copying javax.ws.rs-api-2.0.1.jar to /tmp/build_4959660edbd9bc2e826e322947728edc/target/dependency/javax.ws.rs-api-2.0.1.jar

最佳答案

看起来您的类路径上有 Jersey 1 和 Jersey 2 的冲突。我不确定如何解决此问题,但我认为您需要尝试摆脱 jersey-core-1.9.1.jar 依赖项。

这是关于这个问题的另一个讨论: Exception in REST Jersey

关于java - 异常(exception)是 REST Jersey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37422196/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com