16

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>

Community
  • 1
  • 1
Ram
  • 865
  • 1
  • 8
  • 20

1 Answers1

20

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.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • 4
    Thank you @khmarbaise. That explains the problem. As a follow-up: What could be the purpose of _only_ exposing an artifact's pom. To me, the purpose of publishing an artifact at a repository is to let others use it. Is it possible to depend/re-use on an artifact only by using its pom? – Ram Dec 04 '14 at 21:40
  • 3
    The purpose of this kind of artifacts is based on the nature of the project which produces the artifacts. The pom is the parent of the other artifacts which is published to maven central. Some projects prevent that and some don't. – khmarbaise May 17 '15 at 11:29
  • Why does it "defines a jar" – Philip Rego Apr 03 '19 at 13:24
  • 1
    The simple thing is cause if you define a dependency as given the `jar` is the default. See the pom.xsd https://maven.apache.org/xsd/maven-4.0.0.xsd – khmarbaise Apr 03 '19 at 19:58