Search code examples
javaeclipsemavenbuildworkspace

Unable to open a newly created Maven project in eclipse


I created a new maven project using the following maven command

mvn archetype:generate -DgroupId=com.company.lib_name -DartifactId=lib_name -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

When I open this newly created project in eclipse it gives the following error:

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-jar-  plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-jar-plugin:jar:2.3.2
Plugin org.apache.maven.plugins:maven-jar-plugin:2.3.2 or one of its    dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-jar-plugin:jar:2.3.2: Hostname cannot be null

I tried th following:

  1. Deleted the .m2/repository and rebuilt the project
  2. Verified that the artifact exists in the maven repo
  3. Maven user settings point to the correct settings.xml
  4. Project compiles on the command line
  5. Cleaned the project
  6. Forced updates n the project
  7. Checked repo to see all the dependencies are downloaded
  8. Change eclipse to use the external maven instead of embeded Also I am using Kepler and Maven 3.

Any idea what 'hostname cannot be null' is pointing at?

THis is the pom content

  <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/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.company.lib</groupId>
  <artifactId>liby</artifactId>
   <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
 <name>lib</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>jcl-over-slf4j</artifactId>
       <version>1.7.0</version>
       <scope>runtime</scope>
       </dependency>
       <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
        <version>1.7.0</version>
        <scope>runtime</scope>
    </dependency>
   <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <scope>runtime</scope>
   </dependency>
   <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.14</version>
   </dependency>
   </dependencies>
 </project>

And the settings.xml

<settings>
<profiles>
    <profile>
        <id>Blah</id>
        <repositories>
            <repository>
                <id>inhouse</id>
                <url>http://mavenrepo/maven2_repositories/inhouse</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
            <repository>
                <id>inhouse_snapshot</id>
                <url>http://mavenrepo/maven2_repositories/inhouse_snapshot</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>inhouse</id>
                <url>http://mavenrepo/maven2_repositories/inhouse</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
            <pluginRepository>
                <id>inhouse_snapshot</id>
                <url>http://mavenrepo/maven2_repositories/inhouse_snapshot</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile> 
</profiles>
<activeProfiles>
    <activeProfile>company_name</activeProfile>
</activeProfiles>

<mirrors>
    <mirror>
        <id>central-to-nexus</id> 
        <mirrorOf>*</mirrorOf>
        <url>http://mw_maven_repository_readonly/nexus/content/groups/cached</url>
    </mirror>
</mirrors>


Solution

  • Thank you all for the answers. but the problem was with the maven repo url.