Search code examples
javaspringmavendependency-injectionartifact

maven Missing artifact javax.transaction:jta:jar:1.0.1B


I know i probably put together different versions which don't work together but i don;t know how to figure out where. I'm new to maven and spring and this is a common problem i have so can you tell me what's wrong here and how to recognize on the future incompatible versions ? Here is my pom.xml:

<dependencies>
    <dependency>
        <groupId>aopalliance</groupId>
        <artifactId>aopalliance</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.8.6</version>
    </dependency>
    <dependency>
        <groupId>org.gatein.common</groupId>
        <artifactId>common-logging</artifactId>
        <version>2.2.2.Final</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-asm</artifactId>
        <version>3.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>servletapi</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4-20040521</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>1.2.6</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>4.0.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>4.0.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>4.0.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>4.2.0.RELEASE</version>
    </dependency>
</dependencies>

I follow different tutorials while creating projects and because they are older I always face the dependency problem http://www.studytrails.com/frameworks/spring/spring-security-using-xml.jsp


Solution

  • First try to create the property values as such (in pom.xml):

    <properties>
        <spring.version>4.2.0.RELEASE</spring.version>
    </properties>
    <!-- both properties as dependencies are directly under `project`!, don't use 
    `dependencyManagement` until later -->
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
    </dependencies>
    

    which makes it easier to update all at the same time.
    To see whether different dependencies are used, open the pom.xml (in Eclipse)
    Click on the Dependency Hierarchy tab (bottom)
    Here you can see whether there are conflicts between dependencies, and how they are related with your code and the hierarchy of directly or indirectly imported dependencies.

    Also what helps, is to check whether you've imported the last versions, by calling (see https://stackoverflow.com/a/2687228/928952 for an example)

    mvn versions:display-dependency-updates
    

    One more thing, wrt versions (see version update policy):

    7.1 How Version Numbers Work in Maven Maven's versioning scheme uses the following standards:

    MajorVersion
    MinorVersion
    IncrementalVersion
    BuildNumber
    Qualifier For

    example:

    MajorVersion: 1.2.1
    MinorVersion: 2.0
    IncrementalVersion: 1.2-SNAPSHOT
    BuildNumber: 1.4.2-12
    Qualifier: 1.2-beta-2