Search code examples
javaapachemavenm2eclipsem2e

Maven null dependency and multiple annotations on this line


Something has gone wrong with my pom and I have a blank dependency and artifactId in the xml but get the same error whether I delete the tags or not.

I am using eclipse with m2eclipse installed in my home folder on Linux Mint 14 with maven version 'Apache Maven 2.2.1 (rdebian-8)' installed

Here is the pom.xml

<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>TransferHandler</groupId>
  <artifactId>TransferHandler</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <testSourceDirectory>test</testSourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>com.sun.mail</groupId>
        <artifactId>javax.mail</artifactId>
        <version>1.4.6-rc1</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-vfs2</artifactId>
        <version>2.0</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>com.jcraft</groupId>
        <artifactId>jsch</artifactId>
        <version>0.1.49</version>
    </dependency>
    <dependency>
        <groupId>commons-net</groupId>
        <artifactId>commons-net</artifactId>
        <version>3.2</version>
        <classifier>ftp</classifier>
    </dependency>
    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>
    <dependency>
        <artifactId></artifactId>
    </dependency>
  </dependencies>
</project>

There are three error messages displayed:

On line1:

Multiple annotations found at this line: - null (org.apache.maven.plugins:maven-resources-plugin:2.5:resources:default-resources:process-resources) - null (org.apache.maven.plugins:maven-resources-plugin:2.5:testResources:default-testResources:process-test- resources)

On line70:

Multiple annotations found at this line: - Project build error: 'dependencies.dependency.groupId' for null::jar is missing. - Project build error: 'dependencies.dependency.version' for null::jar is missing.

On line 71:

Project build error: 'dependencies.dependency.artifactId' for null::jar is missing.

It seems like the one on line 70 with the empty tags is the root cause (excerpt below) but I'm not sure.

<dependency>
        <artifactId></artifactId>
</dependency> 

Even if I delete the empty tags from the xml and refresh maven and the project the error remains. On my Dependencies tab I see a jar with a '?' next to it but can't delete it and in my Dependency Hierachy tab I see a ' : [compile]' jar but can delete or exclude it.

How can I remove this ghost/null jar?


Solution

  • I found a way around the problem using git but was not able to solve it directly by removing the offending packages. The work-around was to shutdown eclipse, remove the pom and then use git to discard changes in the working directory. Commands:

     rm pom.xml
     git checkout -- pom.xml
    

    Then the pom should reappear returned to its state at the last commit (which luckily for me was before this error arose). Not a very satisfying answer but at least it worked. If anyone posts an answer and explanation to the heart of the real problem (ie why can't I remove a null package and how did it get there in the first place) I would still be happy to accept it.