1
votes

I am integrating jersey and spring, for which I have following dependencies, but I am unable to build due to following error:

My POM file:

<dependencies>

        <!-- Jersey -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.8</version>
        </dependency>

        <!-- Spring 3 dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>

        <!-- Jersey + Spring -->
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-spring</artifactId>
            <version>1.8</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-web</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    </dependencies>

CONSOLE SCREEN SAYS:

Failed to execute goal on project SpringRestMavenCalc: Could not resolve dependencies for project SpringRestMavenCalc:SpringRestMavenCalc:war:0.0.1-SNAPSHOT: Failed to collect dependencies for [com.sun.jersey:jersey-server:jar:1.8 (compile), org.springframework:spring-core:jar:3.0.5.RELEASE (compile), org.springframework:spring-context:jar:3.0.5.RELEASE (compile), org.springframework:spring-web:jar:3.0.5.RELEASE (compile), com.sun.jersey.contribs:jersey-spring:jar:1.8 (compile)]: No versions available for org.springframework:spring-aop:jar:[2.5.2,3) within specified range -> [Help 1]

Is this versions problem ?

3

3 Answers

0
votes

try adding maven dependency for spring-aop with the below:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>2.5.2</version>
</dependency>

or

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>3.0.5.RELEASE</version>
</dependency>

i guess one of this should work

0
votes

No versions available for org.springframework:spring-aop:jar:[2.5.2,3)

Meaning jersey-spring needs spring-aop 2.5<= version < 3

So jersey-spring 1.8 and spring 3.0.5 are incompatible

I would try the following:

  1. Look for newer version of jersey-spring that works with spring 3.0.5. Maybe jersey-spring3 as suggested by peeskillet above.
  2. Try my luck with spring 3.0.5 by adding exclusions to jersey-spring dependency. Consult the pom here and including them with version 3.0.5 if needed.
0
votes

Thanks All for your answers, Learnt lot from your answers.

BUT FOLLOWING CHANGE IN MY POM MADE MY CODE RUN:

Addition of ,

<exclusion>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
</exclusion>