The same EAR won't deploy directly from Eclipse in JBoss EAP 7.4

142 views Asked by At

I am migrating an old application from Weblogic to JBoss EAP 7.4.

I have a local instance of EAP 7.4 that's working fine and if I build my ear through maven and deploy it "manually" through the EAP 7.4 Management Console, it will work perfectly.

I also have it configured on Eclipse for debug, and when it's deployed via the Management Console, the debug on Eclipse works. So the application works, its pom is correct as far as Maven is concerned, and the EAR is well structured as far as JBoss is concerned.

But I would like to deploy it on EAP from Eclipse 2022-12 directly, using the Servers feature, so that for a simple change I don't have to actually repack the project using Maven, un-deploy the old ear and deploy the new ear, which is a time-consuming process. In my old Weblogic configuration, if I edited and saved a JSP page, I could simply refresh the page from my browser and the changes would be immediately visible. As for Java edits, sometimes the server managed to hotswap the difference, other times it didn't; but I still didn't have to repackage the whole ear to see the difference, just reboot the server.

Eclipse has the Server configured and it is pointing to the very same instance (I only have one JBoss instance in my computer).

The ear is structured like this:

  • ear

  • --- some wars

  • --- some ejbs

  • --- a lib folder with all the libs (the wars are thin), both external an internal (jar modules compiled by maven and included in the project)

  • --- a META-INF folder with the MANIFEST.MF and the maven folder with the pom

On the root folder of the project I have a pom.xml which defines the entries for internal libraries and wars:

<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>[omitted]</groupId>
        <artifactId>[omitted]</artifactId>
        <version>[omitted]</version>
    </parent>
    <groupId>[my group id]</groupId>
    <artifactId>[my artifact id]</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>container</name>
    <properties>
            [omitted project properties]
    </properties>
    <modules>
        <module>war1</module>
        <module>war2</module>
        <module>war3</module>
        <module>war4</module>
        <module>jar1</module>
        <module>jar2</module>
        <module>jar3</module>
        <module>jar4</module>
        <module>jar5</module>
        <module>jar6</module>
    </modules>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Then I have a folder called [projectname]-ear which has this pom.xml:

<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>[omitted]</groupId>
        <artifactId>[omitted]</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <artifactId>[projectname]-ear</artifactId>
    <packaging>ear</packaging>
    <build>
        <finalName>${project.artifactId}</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.2.0</version>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                            <configuration>
                                <includeScope>compile</includeScope>
                                <outputDirectory>${basedir}/../OPENSHIFT</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-ear-plugin</artifactId>
                    <version>${version.ear.plugin}</version>
                    <configuration>
                        <generateApplicationXml>false</generateApplicationXml>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                                <classpathPrefix>lib/</classpathPrefix>
                            </manifest>
                        </archive>
                        <outputDirectory>${basedir}/../OPENSHIFT</outputDirectory>
                        <version>7</version>
                        <defaultLibBundleDir>lib/</defaultLibBundleDir>
                        <skinnyModules>true</skinnyModules>
                        <modules>
                            <webModule>
                                <groupId>[my group id]</groupId>
                                <artifactId>war1</artifactId>
                                <contextRoot>/war1<contextRoot>
                                <bundleFileName>war1.war</bundleFileName>
                            </webModule>
                            <webModule>
                                [... other wars]
                            </webModule>
                            <jarModule>
                                <groupId>[my group id]</groupId>
                                <artifactId>jar1</artifactId>
                                <bundleDir>lib/</bundleDir>
                                <bundleFileName>jar1.jar</bundleFileName>
                            </jarModule>
                            <jarModule>
                                [... other jars]
                            </jarModule>
                            <ejbModule>
                                <groupId>[my group id]</groupId>
                                <artifactId>ejb1</artifactId>
                                <bundleFileName>ejb1.jar</bundleFileName>
                            </ejbModule>
                        </modules>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <dependencies>
        [many dependencies]
    </dependencies>
</project>

On my "Add and remove..." menu in the Servers section in Eclipse, the ear file isn't even listed! I tried to "Mark as deployable" manually and then I see this: Add and remove...

But when I start the server, EAP tries to deploy all the jars and the wars and it fails, giving me some errors:

java.lang.NoClassDefFoundError: Failed to link org/displaytag/tags/TableTag

And also a ClassNotFoundException on some custom classes that are clearly there.

Again: the deployment on the Management Console works perfectly, so the ear isn't wrong.

Somehow I don't think that's the correct ear icon...

Maybe for some reason this is due to the fact that I have thin wars and all the libraries are stored in the /lib folder in the ear? But the ear works perfectly when I deploy it manually through the Management Console.

What could I do to make this project run on EAP 7.4 through my Eclipse?

0

There are 0 answers