简体   繁体   中英

Exception is REST Jersey

I'm new to this. I am trying to make a web app. It runs fine locally but when I deploy it on Heroku and try there here is the problem:

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)

my pom file is:

<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>

Any ideas on how to fix this? If I should add another file so you can figure out the problem let me know. Ive been wrking on this for 2 days.

--UPDATE--

Here is the maven dependancy list

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

It looks like you have a collision of Jersey 1 & Jersey 2 on your classpath. I'm not certain how to fix this, but I think you need to try and get rid of the jersey-core-1.9.1.jar dependency.

Here is another discussion on the problem: Exception in REST Jersey

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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