wildfly / wildfly-glow

Galleon Layers Output from War: Automatic discover of WildFly provisioning information from an application.
Apache License 2.0
7 stars 7 forks source link

Support of EAR project with submodules #82

Closed deamn closed 3 months ago

deamn commented 3 months ago

Do you have a sample code for EAR project? I have this structure but it's seems that the provisioning coming before the generation of provisioning.xml and it doesn't work with wildfly-glow. proj-jee/ ├─ proj-ear/ │ ├─ pom.xml -> wildfly-maven-plugin (goal default to build ear) ├─ proj-ejb/ │ ├─ pom.xml ├─ proj-test/ │ ├─ pom.xml -> wildfly-glow-arquillian-plugin (goal scan) and maven-surefire-plugin ├─ pom.xml -> wildfly-maven-plugin (goal provision)

jfdenise commented 3 months ago

@deamn would you share a simplified project that we could see the phase of each plugin? Thank-you.

deamn commented 3 months ago

@jfdenise please find the simplified project in attachment. Thanks proj-jee.zip

jfdenise commented 3 months ago

@deamn ,thank-you. The arquilian maven plugin is used to discover the galleon layers needed by your tests. It build and scan the deployment defined in your tests. For example: https://github.com/wildfly/wildfly/blob/main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jaxrs/JaxrsTestCase.java#L34 It seems that you are more in a case where you should:

I wrote on blog on this topic: https://www.wildfly.org/news/2024/02/05/testing-with-wildfly-glow/

I have made some changes and attached the proj-ee, just call mvn clean install, and you will see the scanning occurring and the server being provisioned.

proj-jee-fix.zip

deamn commented 3 months ago

@jfdenise thanks. I already read your blog topic but it's missing a runnable example to understand all steps. I integrated your changes into my project, but the maven build failed on mvn clean install at ear project build. It seems that the ear is created but the provisioning failed. [ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:5.0.0.Final:package (test-provisioning) on project proj-ear: No feature-pack has been configured, can't provision a server.

jfdenise commented 3 months ago

Make sure to have

<discover-provisioning-info>
  <version>31.0.1.Final</version>
  <verbose>true</verbose>
</discover-provisioning-info>

in the wildfly-maven-plugin config

deamn commented 3 months ago

Ok, with discover-provisioning-info, I step forward but now, I have this error on ear project during test-provisioning:

[ERROR] * an add-on of the messaging family is expected by the messaging-activemq layer
  To correct this error, enable one of the following add-ons:
  - embedded-activemq
  - remote-activemq

But I have specified in the test project the add-on mentioned:

<plugin>
  <groupId>org.wildfly.glow</groupId>
  <artifactId>wildfly-glow-arquillian-plugin</artifactId>
  <version>1.1.0.Final</version>
  <configuration>
      <verbose>false</verbose>
      <server-version>31.0.1.Final</server-version>
      <add-ons>
          <add-on>mariadb</add-on>
          <add-on>wildfly-cli</add-on>
          <add-on>remote-activemq</add-on>
      </add-ons>
  </configuration>
  <executions>
      <execution>
          <id>scan</id>
          <goals>
              <goal>scan</goal>
          </goals>
          <phase>test-compile</phase>
      </execution>
  </executions>
</plugin>
jfdenise commented 3 months ago

Hi, you need to add the add-ons to the wildfly-maven-plugin configuration, not the arquillian one. Regards.

deamn commented 3 months ago

ok, but how I could specify add-ons to the wildfly-maven-plugin? <add-ons/> isn't supported and <layers/> generate this error: layers must be empty when enabling glow

jfdenise commented 3 months ago

Inside

<discover-provisioning-info>
deamn commented 3 months ago

Thanks for your times. The provisioning seems to be ok, but now I would like to apply configuration to this instance (database and jms) and it's seems that the <commands/> specified into <configuration/> of wildfly-maven-plugin aren't executed. Moreover I have always an error with the database configuration with <env/> (I tested with mariadb and mysql):

ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "MariaDBDS")
]) - failure description: "WFLYCTL0211: Cannot resolve expression '${org.wildfly.datasources.mariadb.user-name,env.MARIADB_USER}'"

How I could configure two datasource connections with env variables? Isn't possible?

My wildfly-maven-plugin is like this:

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>5.0.0.Final</version>
    <configuration>
        <overwrite-provisioned-server>true</overwrite-provisioned-server>
        <provisioning-file>${project.build.directory}/glow-scan/provisioning.xml</provisioning-file>
        <layersConfigurationFileName>standalone-full.xml</layersConfigurationFileName>
        <env>
            <MARIADB_DATASOURCE>testDS</MARIADB_DATASOURCE>
            <MARIADB_JNDI>java:/jdbc/testDS</MARIADB_JNDI>
            <MARIADB_URL>jdbc:mariadb://test:3306/test</MARIADB_URL>
            <MARIADB_USER>test</MARIADB_USER>
            <MARIADB_PASSWORD>test</MARIADB_PASSWORD>
        </env>
        <discover-provisioning-info>
            <version>31.0.1.Final</version>
            <verbose>true</verbose>
            <add-ons>
                <add-on>mariadb</add-on>
                <add-on>wildfly-cli</add-on>
                <add-on>remote-activemq</add-on>
            </add-ons>
        </discover-provisioning-info>
        <commands>
            <command>/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=remote-artemis:add(host=test,port=61616)</command>
            <command>/subsystem=messaging-activemq/remote-connector=remote-artemis:add(socket-binding=remote-artemis)</command>
            <command>/subsystem=messaging-activemq/pooled-connection-factory=remote-artemis:add(connectors=[remote-artemis],entries=[java:/jms/artemisConnectionFactory])</command>
            <command>/subsystem=messaging-activemq/pooled-connection-factory=remote-artemis:write-attribute(name=enable-amq1-prefix,value=false)</command>
            <command>/subsystem=messaging-activemq/external-jms-queue=test:add(entries=[jms/queue/test])</command>
        </commands>
    </configuration>
    <executions>
        <execution>
            <id>test-provisioning</id>
            <goals>
                <goal>package</goal>
            </goals>
            <phase>test-compile</phase>
        </execution>
    </executions>
</plugin>
jfdenise commented 3 months ago

Hi, you should look at: https://docs.wildfly.org/wildfly-maven-plugin/releases/5.0/package-example.html You wil lsee how to call CLI commands during packaging: Search for <packaging-scripts>

deamn commented 3 months ago

Thanks @jfdenise I will check quickly. For

ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "MariaDBDS")
]) - failure description: "WFLYCTL0211: Cannot resolve expression '${org.wildfly.datasources.mariadb.user-name,env.MARIADB_USER}'"

Do you think is a bug?

jfdenise commented 3 months ago

These env variables need to be set when launching the server, unrelated to provisioning time. You can have a bash script that export them all then launch the server.

deamn commented 3 months ago

@jfdenise Thanks, it's ok now. Here the wildfly-maven-plugin section:

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>5.0.0.Final</version>
    <configuration>
        <overwrite-provisioned-server>true</overwrite-provisioned-server>
        <provisioning-file>${project.build.directory}/glow-scan/provisioning.xml</provisioning-file>
        <layersConfigurationFileName>standalone-full.xml</layersConfigurationFileName>
        <discover-provisioning-info>
            <version>31.0.1.Final</version>
            <verbose>true</verbose>
            <add-ons>
                <add-on>wildfly-cli</add-on>
                <add-on>remote-activemq</add-on>
            </add-ons>
        </discover-provisioning-info>
        <packaging-scripts>
            <execution>
                <!-- Properties files containing System Properties to resolve expressions -->
                <properties-files>
                    <file>../cli-test.properties</file>
                </properties-files>
                <!-- Enable expression resolution prior to send the commands to the server, false by default -->
                <resolve-expressions>true</resolve-expressions>
                <!-- List of CLI script files -->
                <scripts>
                    <script>../configure-test.cli</script>
                </scripts>
            </execution>
        </packaging-scripts>
    </configuration>
    <executions>
        <execution>
            <id>test-provisioning</id>
            <goals>
                <goal>package</goal>
            </goals>
            <phase>test-compile</phase>
        </execution>
    </executions>
</plugin>