Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find artifact in maven central repo when search returns a match

Tags:

maven-3

I am attempting to introduce a dependency on the castor library in my pom. Since my project is at a preliminary stage, all artifacts are from maven central. So I search in search.maven.org for "castor". I take the first result which gives me the following dependency snippet:

<dependency>
    <groupId>org.codehaus.castor</groupId>
    <artifactId>castor</artifactId>
    <version>1.3.3</version>
</dependency>

Now I "mvn clean install" and get the following:

[ERROR] Failed to execute goal on project jaxb: Could not resolve dependencies for project org.test:jaxb:war:0.0.1-SNAPSHOT: Could not find artifact org.codehaus.castor:castor:jar:1.3.3 in central (https://repo.maven.apache.org/maven2) -> [Help 1]

How come a artifact that can be found from the web interface cannot be found by the CLI. I am certainly missing something. Request pointers on what it could be.

Among other posts, I have looked into this and this posts which are related, but not this issue.

My Complete pom:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.test</groupId>
<artifactId>jaxb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>jaxb</name>
<description>jaxb</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.1.9.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.moxy</artifactId>
        <version>2.6.0-M3</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-oxm</artifactId>
        <version>4.1.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.castor</groupId>
        <artifactId>castor</artifactId>
        <version>1.3.3</version>
    </dependency>

</dependencies>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <start-class>org.test.jaxb.Application</start-class>
    <java.version>1.7</java.version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

like image 577
Ram Avatar asked Nov 24 '14 16:11

Ram


People also ask

How do I fix missing artifact in Maven?

Try right-clicking on the project and select Maven->Update Project. Disable then re-enable dependency management (right-click Maven->Disable Maven Nature then to again convert the project to a Maven project, Right Click on the project and select Configure ->Convert To Maven Project.

Where are artifacts stored in Maven?

The first place that Maven looks for artifacts is in the local repository, which is the local cache where Maven stores all of the artifacts it has downloaded or found elsewhere. The default location of the local repository is the . m2/repository/ directory under the user's home directory.

What is artifact file in Maven?

In Maven terminology, an artifact is an output generated after a Maven project build. It can be, for example, a jar, war, or any other executable file. Also, Maven artifacts include five key elements, groupId, artifactId, version, packaging, and classifier.


1 Answers

The problem you have is that the artifact which you have defined as a dependency:

<dependency>
    <groupId>org.codehaus.castor</groupId>
    <artifactId>castor</artifactId>
    <version>1.3.3</version>
</dependency>

defines a jar artifact as the error messages implies: org.codehaus.castor:castor:jar:1.3.3

The problem is that on Maven Central this kind of artifact does not exist. It only exist a pom file but not a jar file.

like image 141
khmarbaise Avatar answered Sep 20 '22 10:09

khmarbaise