Reputation: 2472
I'm not sure what happened, but the POM for my project no longer works. Its complaining about the dependency element. Is it that the dependency no longer exists? What does this error mean? To be clear I haven't change the POM, it just does not work now.
The exact error message is cvc-complex-type.2.3: Element 'dependency' cannot have character (children), because this type's content type is element-only.
<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>com.medfusion</groupId>
<artifactId>Estatements-core</artifactId>
<version>14.6.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Estatements-core</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.group.id.Launcher1</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>nexus-qhg-dev</id>
<name>Medfusion repo</name>
<url>http://maven.qhg.local/nexus/content/groups/qhg-dev</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.intuit.health</groupId>
<version>14.6.0-SNAPSHOT</version>
<artifactId>notification-reference</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.health</groupId>
<version>ihg-depot-trunk-SNAPSHOT</version>
<artifactId>attachment-reference</artifactId>
</dependency>
<dependency>
<groupId>com.intuit.health</groupId>
<version>ihg-depot-trunk-SNAPSHOT</version>
<artifactId>eCommunication-core</artifactId>
</dependency>
</dependencies>
</project>
Upvotes: 38
Views: 60740
Reputation: 313
I get this kind of error without having done copy/paste, only adding dependencies via the Dependencies tab. Select All/Cut/Paste changes the error to "Content is not allowed in trailing section" or ... something I can't seem to reproduce any more. Meanwhile the "Effective POM" tab shows no issues at all.
Upvotes: 0
Reputation: 395
This error mainly occurs due to xml parsing error for POM.xml
For me, It was not able to parse xml due to unexpected element '>' after dependencies end tag.
Upvotes: 0
Reputation: 7255
As mentioned in the comment by Powerlord, this error is due to incorrect parsing of the XML file, because there are strange and hidden characters in between a/some <dependency>...</dependency>
tag(s). Those characters could come from a copy paste from the Web.
To solve the issue, remove all spaces and newline characters between <dependency>...</dependency>
tags definitions and put them back into your editor.
Upvotes: 106
Reputation: 11
It's because you have tried to copy paste the dependencies from the web and there are some special or hidden characters are there which are causing this type of errors. So first copy to a text file then put paste it to the code for avoiding this type of an error.
Upvotes: 1
Reputation: 18653
This is because, as others have said, there are non-printable, but XML-illegal characters inserted into pom.xml, usually between XML elements. In my case, this often happens when I copy and paste from elsewhere, usually documentation, an article, tutorial, etc. in my browser.
For me, IntelliJ IDEA's editor displays these characters as rose-colored space, perhaps a function of my color scheme, so that it's easy to find and delete them.
Upvotes: 2
Reputation: 21
I recently faced that problem and the error showed at the xsi:schemaLocation of the pom.xml file and it was a problem of copy and paste from different websites introducing an invisible non-space character. To check which line have the hidden character I take a copy of the pom file and paste it to a blank word file and enable "Show paragraph mark and other formatting".
Upvotes: 2