10

i have just started building applications with Maven. One of my approaches is to build a multimodule web application. Working with Eclipse makes it very easy to build that kind of an application. So far everything works fine. The point at which i fail is the deployment. I am using Wildfly as my application Server and the deployment of the presentation layer works well. But when i want to deploy from the parent project i get this message:

Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.1.Final:deploy (default-cli) on project build: Error executing FORCE_DEPLOY: C:\Users\*****\Desktop\workspace\mvnexbook-examples-1.0\ch-multi\target\parent-0.8-SNAPSHOT.maven-project (No such file or directory)

This is very confusing. Does the deployment not take place from the previously installed files at the .m2/repository folder? Do i need a target directory in my parent folder?

My parent pom file

<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.sonatype.mavenbook.multi</groupId>
        <artifactId>simple-parent</artifactId>
        <version>0.8-SNAPSHOT</version>
    </parent>

    <artifactId>simple-webapp</artifactId>
    <packaging>war</packaging>
    <name>Multi Chapter Simple Web Application Project</name>
    <dependencies>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-servlet_2.4_spec</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.sonatype.mavenbook.multi</groupId>
            <artifactId>simple-weather</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>simple-webapp</finalName>
        <plugins>

            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

EDIT: I just tried it with jetty. Works fine. Why it's not working with Wildfly?

EDIT2: I am using the simple-parent-project example from the sonatype book

claim
  • 506
  • 6
  • 13

2 Answers2

19

In the parent POM you need to add <skip>true</skip> to the configuration. Then set it to false for the your WAR POM.

Parent POM

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>1.0.1.Final</version>
    <configuration>
        <skip>true</skip>
    </configuration>
</plugin>

WAR POM

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <configuration>
        <skip>false</skip>
    </configuration>
</plugin>
James R. Perkins
  • 16,800
  • 44
  • 60
  • thanks, skip did the job. But still I am confused. First, why do we need to skip the parent pom. I thought by building the parent pom every module will be autodeployed and the parent will be handled as the aggregator project by the wildfly plugin. And second thing is, why does any website which are addressing this topic not mention that. Maybe i just didn't get it. – claim May 16 '14 at 19:51
  • 1
    It's just the way the plugin was written. We should change it to automatically ignore pom package types. – James R. Perkins May 19 '14 at 15:32
  • @James R. Perkins what I need to do in case when I don't have war pom? Child modules are packed as jars and added by 'maven-war-plugin' to war, during install on parent. How to deploy this kind of war? – bmlynarczyk Nov 18 '14 at 17:26
  • 2
    You just need to either add `true` to the modules you don't want deployed or only specify the plugin in the module you do want deployed. The later would require you be in that directory when executing goals for the plugin. – James R. Perkins Nov 18 '14 at 23:34
1

You application EAR is probably not located in parent project build folder. It's probably located in APP module build project. If you look here: you will see, there is targetDir defaulting to build directory of current project. You can provide another value. And filename parameter points to filename. It defaults to ${project.build.finalName}.${project.packaging}, and in your case it doesn't have a meaningful extension.

You may want to try something like

        <configuration>
            <targetDir>path</targetDir>
            <filename>filename</filename>
        </configuration> 

to your plugin defenition. You can use relative path of course. You may also try to run your plugin from APP project.

skegg99
  • 415
  • 2
  • 8
  • Doesn't the parent project need to be pom. Tried to change it but eclipse is saying: Aggregator projects need to be pom. Just want to mention that I am using the simple parent example from sonatype. And the only thing i changed was the wildfly maven plugin which i added. Even if i change targetDir, i don't know where to point at. – claim May 16 '14 at 13:52
  • Yes, that's my fault. You are correct. So you may have to redefine filename from default value. You may also try to run plugin from your app project. I'll update my answer – skegg99 May 16 '14 at 13:56
  • changing the targetdir and filename didn't work out. I am still getting the same error. Why does it work with jetty and not with jboss? What do you mean with "run your plugin from APP project"? – claim May 16 '14 at 14:22
  • Ok, if it doesn't make sense, you should disregard my answer. I couldn't find the exact archetype you used. For me it's usual to have something like parent project and child projects - one for client (interfaces and entities), one for implementation, one for war and one for assembly. The latter is what I call APP. Sorry if I've misled you. Just make sure you point to correct file. – skegg99 May 16 '14 at 14:29
  • Thanks anyway you are trying at least. Couldn't find anything similiar on the web about that issue – claim May 16 '14 at 15:00
  • Still the problem is probably with file location. Just find the file you need to deploy after the normal build and rewrite you plugin settings, including the corrected filename and possibly path. – skegg99 May 16 '14 at 15:03
  • Now i am going with this: I build my project with the parent pom and deploying the webapp war file which i am now pointing to at the parent pom. This works but sounds somehow wrong. – claim May 16 '14 at 15:51