Why am I getting Unknown error in line 1 of pom.xml?

138,542

Solution 1

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>

Solution 2

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

Solution 3

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

Solution 4

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.

Solution 5

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>
Share:
138,542
Shravani
Author by

Shravani

Updated on July 08, 2022

Comments

  • Shravani
    Shravani almost 2 years

    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.

  • light_303
    light_303 almost 5 years
    same here! still not sure what in the spring parent pom causes this problem since 2.1.5
  • Shravani
    Shravani almost 5 years
    @fsuwailih Thanks this one worked. But I am wondering why is it only working for some people but not for others.
  • Shravani
    Shravani almost 5 years
    After changing the version for parent tag it worked magically
  • John Eipe
    John Eipe almost 5 years
    this did it for me
  • Miklos Krivan
    Miklos Krivan almost 5 years
    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.
  • Del Pedro
    Del Pedro almost 5 years
    obsolete answer was the solution that worked for me
  • Matthias
    Matthias almost 5 years
    Just for the record, my problem was solved by upgrading the mavenarchiver plugin.
  • Arijit Basu
    Arijit Basu almost 5 years
    This solution actually worked! I changed it to 2.1.4 from 2.1.6. But why the later versions are causing that error?
  • ASharma7
    ASharma7 almost 5 years
    after installing m2e connector for mavenarchiver plugin, restart maven & do maven -->update project-->force update of snapshots
  • PatVictorio
    PatVictorio over 4 years
    I meant 2.1.4.RELEASE.
  • rich p
    rich p over 4 years
    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. :^)
  • Ehsan Waris
    Ehsan Waris over 4 years
    installing the latest m2e connector for mavenarchiver fixed it for me
  • PatVictorio
    PatVictorio over 4 years
    Edited my answer and fixed the typo.
  • nix86
    nix86 about 4 years
    Yes. Inside properties you must have <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>. Then you right click on the project in the project explorer and choose "Maven -> Update Project..."
  • Jafar Karuthedath
    Jafar Karuthedath almost 4 years
    Issue solved after installing the m2e connector. Thank you.
  • Jean-Christophe
    Jean-Christophe almost 4 years
    This issue seems to appear from maven-jar-plugin 3.1.2 & 3.2.0.
  • Sadina Khatun
    Sadina Khatun over 3 years
    yes but 3.1.1 is working fine so we can use that one
  • manish bansal
    manish bansal almost 3 years
    Issue solved after installing the m2e connector. You saved my day.. Thanks :)
  • iifast
    iifast about 2 years
    Really Helpful ! I added that below the java version <java.version>1.8</java.version> and updated the project and did refresh on STS, It worked like a charm
  • Shashi Ranjan
    Shashi Ranjan about 2 years
    The only correct answer.
  • cogitoboy
    cogitoboy about 2 years
    3.2.2 Still showing the error. 3.1.1 is the latest that works for me without the error.