0

I've searched in a lot of places but none seem to be working. In the first line of my pom file, I get

Project build error: Invalid packaging for parent POM , must be "pom" but is "jar".

I first tried copying/pasting similar code for that first line from other working pom files, to no luck. Then I tried going into Overview -> Artifact -> change packaging from "jar" to "pom", to no luck. I also tried installing new software, https://download.eclipse.org/m2e-wtp/releases/1.4/, but it couldn't connect. I tried changing the version of the maven-shade-plugin on the dependency from 3.0.0 to match my maven version, which was 3.3.9, but it couldn't connect. Even though the maven was in the right path and installation was there and working for other maven projects, I was told there might be something wrong with my environment, so I tried also running it in other places like IntelliJ, but ran into other issues. I'm using Spring Tool Suites, an extension of eclipse. Do any of you know how to fix this? Thanks

Pom File is:

<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.org_name.apps.pdm</groupId>
         <artifactId>product-parent</artifactId>
         <version>2.0.1-SNAPSHOT</version>
  </parent>
<artifactId>product</artifactId>
<packaging>pom</packaging>         
<name>Product</name>
<description><![CDATA[TBD.]]></description>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>
    <!-- Logback is an improvement over log4j
         The logback-classic module contains a native slf4j implementation so there is no overhead -->
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.1.7</version>
    </dependency>

    <dependency>
        <groupId>org.org_name.apps.pdm</groupId>
        <artifactId>product-utilities</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
        <version>1.5.15.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <version>1.5.15.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>1.5.15.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.org_name.apps.pdm</groupId>
        <artifactId>pbdr-content-loader-utilities</artifactId>
        <version>1.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3.0</version>
    </dependency>

    <!-- org_name Utility codebase -->
    <dependency>
        <groupId>org.org_name.utils</groupId>
        <artifactId>common-utils</artifactId>
        <version>1.0.10</version>           
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.org_name.maven.deps</groupId>
                <artifactId>spring-deps</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>
<build>
    <finalName>Product_FileName</finalName>

    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.3</version>
            <configuration>
                <skipTests>false</skipTests>
                <testFailureIgnore>false</testFailureIgnore>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.0.0</version>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>1.5.2.RELEASE</version>
                </dependency>
            </dependencies>
            <configuration>
                <!-- Add the main-class to the manifest -->
                <transformers>
                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                        <resource>META-INF/spring.handlers</resource>
                    </transformer>
                    <transformer
                        implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
                        <resource>META-INF/spring.factories</resource>
                    </transformer>
                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                        <resource>META-INF/spring.schemas</resource>
                    </transformer>
                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>org.org_name.apps.pdm.product-class.Application</mainClass>
                        <manifestEntries>
                            <group-id>${project.groupId}</group-id>
                            <artifact-id>${project.artifactId}</artifact-id>
                            <artifact-version>${project.version}</artifact-version>
                        </manifestEntries>
                    </transformer>
                </transformers>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>

PARENT POM file is:

<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.org_name.maven</groupId>
    <artifactId>org_name-Parent</artifactId>
    <version>2.0</version>
</parent>

<groupId>org.org_name.apps.pdm</groupId>
<artifactId>product-parent</artifactId>
<version>2.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Product Parent</name>

<modules>
    <module>productUtilities</module>
    <module>product</module>
</modules>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.org_name.apps.pdm</groupId>
            <artifactId>product-utilities</artifactId>
            <version>2.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.org_name.apps.pdm</groupId>
            <artifactId>product</artifactId>
            <version>2.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>
</dependencyManagement>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.5</version>
            </plugin>
            <!--
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
            </plugin>
            -->
            <!--This plugin's configuration is used to store Eclipse m2e settings
                   only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-clean-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.5,)
                                    </versionRange>
                                    <goals>
                                        <goal>clean</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<developers>
    <developer>
        <name>Lead Developer Name</name>
    </developer>
</developers>
</project>
jostroff
  • 3
  • 1
  • 4
  • I notice that the parent POM also has a parent. Have you checked the packaging of that one? – Stephen C Jun 18 '20 at 13:31
  • It's the issue of the project structure. Please check your project structure and this [link](https://stackoverflow.com/questions/13330930/invalid-packaging-for-parent-pom-xml-must-be-pom-but-is-ear) will help you understand more. – Ashish Karn Jun 18 '20 at 13:58

1 Answers1

0

The error says that your <parent> is a project that does not have <packaging>pom</packaging>.

So you either used the wrong project as parent or your parent POM has <packaging>jar</packaging> by accident.

To understand this in more detail, we need your POM file and also the one of your parent.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Hi, that's more or less what the overview change does. I have tried that and it doesn't work here. Both by right-clicking -> (F5) Refresh, and doing Maven -> Update Project, and finally Replace with -> Latest from Repository (which just changes it back to "jar"). I always receive the same error no matter what value is in . – jostroff Jun 17 '20 at 20:07
  • I have the pom file here: https://www.reddit.com/r/javahelp/comments/hatbkq/problem_with_pomxml_file_help/fv5p3z9/ When you say, "one of your parent," what do you mean? – jostroff Jun 17 '20 at 20:14
  • It would be great if you edit your question and add your POM and also the parent POM. – J Fabian Meier Jun 18 '20 at 06:27
  • Note that the error has nothing to do with the packaging of your project, but with the packaging of your parent POM. – J Fabian Meier Jun 18 '20 at 06:27