0

When I imported Existing Maven Projects downloaded from open-source-website(eg. Apache, Github) into Eclipse, Several errors happened :( . Note that, all maven projects can correctly compile and test under the Eclipse.

  • Firstly, after importing maven projects into Eclipse, there will be a red X on the project icon, but there are no error in projects. I found there exist parent node in pom.xml file. I deleted the node then the error is gone, I want to know why since there is no module in maven project. the following code is the node I deleted before.
<parent>
    <groupId> org.apache.commons </groupId>
    <artifactId> commons-parent </artifactId>
    <version> 38</version>
  </parent>
  • Next, In the project jaxen, this project's structure is odd. In the project I just found src/java/main and src/java/test rather than src/main/java and src/test/java, is there any other configuration I should do even though it can correctly run under Eclipse?

  • What's more, I also found errors in code sources of jaxen, See this picture, the error information is partial given as follows, look for your help and thanks in advance :)

Failure to transfer xerces:xmlParserAPIs:jar:2.6.2 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact xerces:xmlParserAPIs:jar:2.6.2 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled.

org.eclipse.aether.transfer.ArtifactTransferException: Failure to transfer xerces:xmlParserAPIs:jar:2.6.2 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact xerces:xmlParserAPIs:jar:2.6.2 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled.
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:238)
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)
Yongfeng
  • 345
  • 1
  • 3
  • 15

2 Answers2

0

The following error org.eclipse.aether.transfer.ArtifactTransferException: Failure to transfer xerces:xmlParserAPIs:jar:2.6.2 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact xerces:xmlParserAPIs:jar:2.6.2 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled will be fixed by Step 2.

Try this, if 1 does not work try 2:

1) First update the project, Alt-F5

2) Then go to your repo and blow away the directory for that dependency which should be in the directory HOME_DIRECTORY/.m2/repo/xerces/xmlParserAPIs/2.6.2 Then do an Alt-F5 again.

3) If this fails try a mvn clean install -U from the command line.

Essex Boy
  • 7,565
  • 2
  • 21
  • 24
  • I just wonder about the strange project structure of `jaxen`. The common maven project structure are `src/main/java` and `src/test/java`, aren't they? So why the developers use `src/java/main` and `src/java/test` those odd structures? – Yongfeng Jan 11 '17 at 10:59
  • The eclipse errors do not make any influence on running this maven project. Should I ignore these error or ... T^T – Yongfeng Jan 11 '17 at 11:05
  • @Yongfeng I would change the project structure to be src/main/java and src/test/java. Eclipse will work as the command line if you have your maven pointing at the correct settings.xml (should be HOME/.m2/settings.xml). Check if your eclipse settings. – Essex Boy Jan 11 '17 at 11:18
  • Hi, @Essex Boy, After deleting the corresponding jar in local repository , the errors of `jaxen` in Eclipse are gone. Could you please explain the reason of using this `strange project structure`? In addition, can you tell me how to solve the first question I asked :) Thank you very much ! – Yongfeng Jan 11 '17 at 11:52
  • @Yongfeng as I said step 2 will correct the error. The problem is that Maven has tried to download the dependency from maven central and failed (for what ever reason), but it's left some place holder files in your repo and decided it will wait until it tries again. If you blow the directory away it will say "I do not have that dependency in my local repo, so I will download it now" .... :) :) – Essex Boy Jan 11 '17 at 12:22
  • Soga, deleting these directories in local maven repository will tell maven to download these dependencies from scratch ^-^. Thank you! – Yongfeng Jan 11 '17 at 14:13
0

Although I have accepted Essex Boy's answer, I'd like to say that another link Error on Importing existing Maven project to eclipse is similar to my third question. Maybe cleaning up the corresponding jars from local maven repository is a good solution.

As for my first question, http://maven.apache.org/guides/introduction/introduction-to-the-pom.html tells us the preliminary usage of parent. But I still don't know why.

Uh... And second questions needs my another efforts to work it out. Perhaps that developers need these strange and odd project structure for another target, And I also will appreciate it if someone can tell me the answer, Thanks all the same > <

Community
  • 1
  • 1
Yongfeng
  • 345
  • 1
  • 3
  • 15