143

Getting unknown error at Line 1 in pom.xml in Eclipse IDE. It was working fine till yesterday, but all of a sudden after updating my project from master and after fixing merge conflicts getting "Unknown error" in pom.xml. Except me, none of my teammates are facing this issue. I also changed the workspace, deleted cache but still no luck.

I am using the h2 database for this project, in spite of inserting values in data.sql, it is not picking up any values and inserting into h2 DB tables. Before this issue, it was working fine. I feel its due to the issue in pom.xml, I am not sure though. Please help

I deleted the existing project and took the latest code from master. After that deleted .m2 folder under users including the repository folder. I did update project and enabled Forced update of snapshots/releases, maven clean and maven build. But nothing helps.

pom.xml

<?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>com.abc.roster</groupId>
    <artifactId>spring-boot-roster-app</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>spring-boot-roster-app</name>
    <description>Demo project for Spring Boot Roster</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.BUILD-SNAPSHOT</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <!-- <start-class>com.infosys.roster.SpringBootRosterAppApplication</start-class> -->
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <!--encryption lib -->
        <dependency>
            <groupId>org.jasypt</groupId>
            <artifactId>jasypt</artifactId>
            <version>1.9.2</version>
        </dependency>

        <dependency>
            <groupId>org.jasypt</groupId>
            <artifactId>jasypt-springsecurity3</artifactId>
            <version>1.9.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>

        </dependency>


<!--        <dependency> -->
<!--         <groupId>org.hibernate</groupId> -->
<!--         <artifactId>hibernate-core</artifactId> -->
<!--         <version>5.2.10.Final</version> -->
<!--   </dependency> -->

        <!-- <dependency> -->
        <!-- <groupId>io.springfox</groupId> -->
        <!-- <artifactId>springfox-swagger2</artifactId> -->
        <!-- <version>2.7.0</version> -->
        <!-- <scope>compile</scope> -->
        <!-- </dependency> -->


        <!-- <dependency> -->
        <!-- <groupId>io.springfox</groupId> -->
        <!-- <artifactId>springfox-swagger-ui</artifactId> -->
        <!-- <version>2.7.0</version> -->
        <!-- <scope>compile</scope> -->
        <!-- </dependency> -->

        <!-- <dependency> -->
        <!-- <groupId>io.springfox</groupId> -->
        <!-- <artifactId>springfox-data-rest</artifactId> -->
        <!-- <version>2.7.0</version> -->
        <!-- </dependency> -->
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </pluginRepository>
    </pluginRepositories>

</project> 

application.properties

server.port=
spring.h2.console.path=/h2
spring.h2.console.enabled=true

spring.datasource.url=


spring.datasource.username=
spring.datasource.password=
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.platform=h2
spring.datasource.initialization-mode=always

spring.jpa.hibernate.ddl-auto=update
spring.datasource.continue-on-error=true

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=false

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect

Should remove unknown error in pom.xml and also I must be able to populate values in H2 db.

INDRAJITH EKANAYAKE
  • 3,894
  • 11
  • 41
  • 63
Shravani
  • 1,622
  • 2
  • 11
  • 16
  • Are you saying no one else is having an issue with the same pom file? – Joakim Danielson May 15 '19 at 05:50
  • update the error log in question – vels4j May 15 '19 at 06:08
  • @JoakimDanielson yes none of them in my team is facing the issue with the code base I'm using. Only I am facing this issue – Shravani May 15 '19 at 15:02
  • @vels4j I am not getting any error log when I run the application, but in pom.xml it is showing as "unknown error" – Shravani May 15 '19 at 15:58
  • I didn’t mean the code base but the actual pom file – Joakim Danielson May 15 '19 at 16:07
  • Are you using intelliJ? This is a longshot, but I suggest to do maven->clean, then do maven->install. Sometimes IntelliJ keeps old/partial builds lingering around. Despite the fact that maven->install also does a clean, it is important to do a separate clean. – user1884155 May 15 '19 at 21:48
  • @user1884155 I am using Eclipse Oxygen version. I have also done maven clean and then maven install, but nothing seems to work – Shravani May 15 '19 at 21:53
  • if your maven commands are working i would recommend to remove the files generated by Eclipse. Not sure which files as I do not use Eclipse but you can find googling. – Carlos May 15 '19 at 22:23
  • *....getting Unknown error in line1 of pom.xml*...where is line 1?? – Vishwa Ratna May 16 '19 at 06:43
  • @CommonMan Accidentally Line 1 was commented out when I pasted in stackoverflow. But thats not the problem. I am still getting the same error – Shravani May 16 '19 at 15:52
  • @Carlos I tried deleting .m2 files generated by eclipse. I even uninstalled eclipse and installed spring tool suite. But no luck – Shravani May 16 '19 at 15:53
  • 1
    I'm having the exact same problem. I've created several new spring boot projects from http://start.spring.io, and after importing the projects into Spring Tool Suite, I'm getting 'Unknown Error' on line 1 of my pom.xml file. This just started this week. – Stephen May 17 '19 at 20:16
  • I've tried the following: - tried renaming my .m2 folder and letting maven re-download all of the dependencies - I've deleted and recreated the entire pom.xml file - I created a new project on http://start.spring.io that's a higher version. None of this has worked for me. I'm still getting the 'Unknown Error' on the first line of the pom.xml file. – Stephen May 17 '19 at 20:37
  • 1
    @Stephen Are you still facing this issue. I was able to solve after changing 2.2.0.BUILD-SNAPSHOT to 2.1.4.BUILD-SNAPSHOT – Shravani May 22 '19 at 19:12
  • @Shravani, that fixed it for me. Thank you for following up with me! – Stephen May 23 '19 at 18:30
  • *Refer the below Solution* https://stackoverflow.com/questions/37157105/project-is-running-and-working-but-pom-xml-is-showing-error/60213827#60213827 – Lakshyaveer Chaudhary Feb 21 '20 at 18:08

21 Answers21

186

answer according to current status

This issue got fixed:

Please install the m2e connector for mavenarchiver plugin 0.17.3 from https://download.eclipse.org/m2e-wtp/releases/1.4/


obsolete answer

A less profound change than a downgrade from Spring Boot 2.1.5.RELEASE to 2.1.4.RELEASE would be downgrading only the affected Maven JAR Plugin from 3.1.2 to 3.1.1 as long as this bug exists:

<properties>
    <!-- ... -->
    <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
Matthias
  • 7,432
  • 6
  • 55
  • 88
  • 10
    The newest Eclipse (2019-03) has the same problem. Changing the maven-jar-plugin from 3.1.2 to 3.1.1 based on your suggestion solved the issue. Many thanks. – Miklos Krivan May 25 '19 at 23:03
  • 6
    obsolete answer was the solution that worked for me – Del Pedro Jun 13 '19 at 08:19
  • 1
    Just for the record, my problem was solved by upgrading the mavenarchiver plugin. – Matthias Jun 13 '19 at 09:26
  • 3
    after installing m2e connector for mavenarchiver plugin, restart maven & do maven -->update project-->force update of snapshots – ASharma7 Jul 27 '19 at 12:37
  • 1
    installing the latest m2e connector for mavenarchiver fixed it for me – Ehsan Waris Nov 13 '19 at 08:02
  • Yes. Inside properties you must have 3.1.1. Then you right click on the project in the project explorer and choose "Maven -> Update Project..." – nix86 Mar 06 '20 at 09:23
  • Some times behind a corporate proxy the m2e connector plugin download in eclipse may take more time to load and consumes huge memory, in such cases, below answer helps https://stackoverflow.com/a/59300898/3625752 – rinilnath Apr 13 '23 at 13:37
51

Add 3.1.1 in to properties like below than fix issue

<properties>
        <java.version>1.8</java.version>
        <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>

Just Update Project => right click => Maven=> Update Project

shubh gaikwad
  • 127
  • 2
  • 10
Sadina Khatun
  • 1,136
  • 2
  • 18
  • 27
36

For me I changed in the parent tag of the pom.xml and it solved it change 2.1.5 to 2.1.4 then Maven-> Update Project

fsuwailih
  • 379
  • 2
  • 2
  • 2
    same here! still not sure what in the spring parent pom causes this problem since 2.1.5 – light_303 May 20 '19 at 11:18
  • @fsuwailih Thanks this one worked. But I am wondering why is it only working for some people but not for others. – Shravani May 22 '19 at 19:20
  • This solution actually worked! I changed it to 2.1.4 from 2.1.6. But why the later versions are causing that error? – Arijit Basu Jul 10 '19 at 12:03
23

As per the suggestion from @Shravani, in my pom.xml file, I changed my version number in the area from this:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

to this:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.4.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

I then right clicked on the project and did a 'Maven -> Update project...'. This made the problem go away for me.

Stephen
  • 1,977
  • 2
  • 15
  • 19
15

You must to upgrade the m2e connector. It's a known bug, but there is a solution:

  1. Into Eclipse click "Help" > "Install new Software..."

  2. Appears a window. In the "Install" window:

    2a. Into the input box "Work with", enter next site location and press Enter https://download.eclipse.org/m2e-wtp/releases/1.4/

    2b. Appears a lot of information into "Name" input Box. Select all the items

    2c. Click "Next" Button.

Finish the installation and restart Eclipse.

Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40
Antonio
  • 352
  • 5
  • 12
  • 1
    I found these instructions the clearest path to implementing the solution that everyone says is the root cause problem, the need to upgrade this connector. _Also, it worked._ :^) – rich p Oct 22 '19 at 23:48
13

There is a bug about Eclipse and spring-boot-starter-parent 2.1.5

"if the maven packaging attribute is war then no problem.The problem is in jar type." So you can also fix this problem by changing packaging type.

<packaging>war</packaging>
鄭脈龍
  • 336
  • 1
  • 10
4

I updated spring tool suits by going help > check for update.

franiis
  • 1,378
  • 1
  • 18
  • 33
2

Simply add below maven jar version in properties tag in pom.xml, <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>

Then follow below steps,

Step 1: mvn clean

Step 2 : update project

Problem solved for me! You should also try this :)

  • Really Helpful ! I added that below the java version 1.8 and updated the project and did refresh on STS, It worked like a charm – iifast2 Feb 13 '22 at 19:08
1

While I cannot reproduce your error (as none of your team mates can either), I have a suggestion, that might help you.

Have you heard of the Byte Order Mark? As it appears on line 1 it is a likely candidate for your troubles. Maybe you changed a setting somewhere that somehow leads to the error. This quote from the Wikipedia article is particularly relevant I think:

BOM use is optional. Its presence interferes with the use of UTF-8 by software that does not expect non-ASCII bytes at the start of a file but that could otherwise handle the text stream.

AplusKminus
  • 1,542
  • 1
  • 19
  • 32
1

For me I changed in the parent tag of the pom.xml and it solved it change 2.1.5 to 2.1.4 then Maven-> Update Project. its worked for me also.

Romil Patel
  • 12,879
  • 7
  • 47
  • 76
1

same problem for me, original code from spring starter demo gives unknown error on line 1:

<?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>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.6.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
...

Changing just the version of 2.1.6.RELEASE to 2.1.4.RELEASE fixes the problem.

mjames276
  • 71
  • 1
  • 7
1

For me, changing pom.xml for SpringBoot 2 project from 2.1.6.RELEASE

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.REL`enter code here`EASE</version>
        <relativePath /> <!-- lookup parent from repository -->
</parent>

to 2.1.4.RELEASE verified and works

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
</parent>
0

Got this error on eclipse IDE version 4.10, Spring boot 2.2.0.M4, changed the Spring boot version to 2.2.0.M2 (after many other solutions recommended and it solved the error). Maybe something missing or broken in the latest version of Spring boot starter project module maven POM.

tksilicon
  • 3,276
  • 3
  • 24
  • 36
0

In my pom.xml file I had to downgrade the version from 2.1.6.RELEASE for spring-boot-starter-parent artifact to 2.1.4.RELEASE

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
</parent>

to be changed to

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
</parent>

And that weird Unknown error disappeared

nitinr708
  • 1,393
  • 2
  • 19
  • 29
0

You just need a latest Eclipse or Spring tool suite 4.5 and above.Nothing else.refresh project and it works

0

I was getting same error in Version 3. It worked after upgrading STS to latest version: 4.5.1.RELEASE. No change in code or configuration in latest STS was required.

Vikash Gupta
  • 179
  • 2
  • 10
0

whenever you facing this type of error simply change the Release version just like In my case it is showing Error in 2.2.7 I changed to 2.2.6

Problem:

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.7.RELEASE</version>

Solution:

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
MartenCatcher
  • 2,713
  • 8
  • 26
  • 39
0

Add <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> in property tag

problem resolve

https://medium.com/@saannjaay/unknown-error-in-pom-xml-66fb2414991b

Rakesh Ray
  • 62
  • 1
  • 9
0

My silly solution was to just "Delete" the error message in the problems list.

Right click => select delete and you get a warning message saying it may come back. But the error message has not returned even after I did a clean and Build All.

TLDR:

I did the following from the command line "mvn clean" Result : No errors

"mvn compile" Result: Jar build in target folder. Result : No errors on screen.

So the error is in eclipse not in the pom.xml

I tried the following:

Update Project => right click => Maven=> Update Project

Project => clean Autobuild results in the same error message.

I tried changing the packaging from a jar to a war in the pom.xml Rebuild... Still the same error message.

I tried the "upgrade the m2e connector" option. Rebuild... Still the same error message.

I tried turn off automatic rebuild, clean and exit Eclipse. Restart Eclipse and Build all... Still the same error message.

Maybe one of the above fixed it for me it just did not update or clear the problem logs in Eclipse properly.

Peter
  • 21
  • 5
0

If someone having similar issues in VS Code please follow this: Open pom.xml >> Right Click and select "Update Project"

Ranjan Kumar
  • 321
  • 3
  • 4
-1

Following actions worked for me.

1.Go to Project in toolbar -> Unchecked "Build Automatically"

2.In POM File,Downgrade the spring-boot version to 2.1.4 RELEASE.

3.Right Click on Project name -> Select Maven -> Click on "Update Project". ->OK Wait till all the maven dependency to get downloaded(Need internet).