Eclipse can not find the location pom.xml

advertisements

I have an existing maven project that I am planning on deploying using WebLogic Server. Since I need an ear file for the same, I am following the steps to create a jar module and a war module which I later plan on including in a parent module. However, when I make a jar module, the moment the folder reflects in eclipse, I get an error regarding the pom.xml. The error says that Project build error: Non-readable POM pom.xml /*ProjectName*JARModule line 1 Maven pom Loading Problem. Any idea why this is happening? The same happens when I try to create a war module as well. And till I dont have those two modules ready, I cannot proceed to making an ear module and including both. Help much appreciated! **UPDATE - ** Here is my parent project pom.xml (On which I right cliked and chose to create a new module named projectnameJAR and projectnameWAR and even projectnameEAR-

    <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>Project_name</groupId>
<artifactId>Project_name</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Project_name</name>
<build>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <inherited>true</inherited>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
    <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
        <warSourceDirectory>WebContent</warSourceDirectory>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
    </plugin>
    </plugins>
</build>
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey</groupId>
                <artifactId>jersey-bom</artifactId>
                <version>${jersey.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.jaxrs</groupId>
                <artifactId>jackson-jaxrs-json-provider</artifactId>
                <version>2.6.0</version>
        </dependency>
        <dependency>
                    <groupId>javax</groupId>
                    <artifactId>javaee-web-api</artifactId>
                    <version>7.0</version> <!-- Put here the version of your Java EE app, in my case 7.0 -->
                    <scope>provided</scope>
            </dependency>

          <dependency>
                    <groupId>javax.servlet</groupId>
                    <artifactId>javax.servlet-api</artifactId>
                    <version>3.1.0</version>
                    <scope>provided</scope>
            </dependency>

            <dependency>
                    <groupId>javax.servlet</groupId>
                    <artifactId>jstl</artifactId>
                    <version>1.2</version>
            </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
            <!-- artifactId>jersey-container-servlet</artifactId -->
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
        </dependency>
        </dependencies>
    </dependencyManagement>

    <properties>
        <jersey.version>2.16</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <modules>
        <module>Project_nameJARModule</module>
        <module>Project_nameWARModule</module>
        <module>Project_nameEARModule</module>
    </modules>
</project>

Following is the pom that was generated for the JAR module -

    <?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>Project_name</groupId>
    <artifactId>Project_name</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>Project_nameJAR</groupId>
<artifactId>Project_nameJAR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CADJAR</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
</dependencies>
</project>

And the pom generated for the WAR module -

    <?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>Project_name</groupId>
    <artifactId>Project_name</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>Project_nameWAR</groupId>
<artifactId>Project_nameWAR</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Project_nameWAR Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <finalName>Project_nameWAR</finalName>
</build>
</project>


Your pom's seems to be okay, so it's probably a path issue between your parent pom and his childs.

parent-module (i.e. your eclipse workspace)
|_Project_nameJARModule
|   |_pom.xml
|_Project_nameWARModule
|  |_pom.xml
|_Project_nameEARodule
|  |_pom.xml
|_pom.xml

This is the same tree as @Aurelien already posted. If you don't structure the tree like this, you have to define the parent and module path.

How it works:

<modules>
    <module>../path/to/your/child/module/</module>
</modules>

<parent>
    <groupId>com.mycompany.app</groupId>
    <artifactId>my-app</artifactId>
    <version>1</version>

    <!-- define the path to the parent -->
    <relativePath>../path/pom.xml</relativePath>
</parent>

Otherwise the tree strucutre above is the default if you don't define a specific <relativePath>