1

I'm trying to configure a datasource in Wildfly Maven plugin...

I have searched for solutions but I didn't find!

My project is too basic and I'm following the documentation examples (https://docs.jboss.org/wildfly/plugins/maven/latest)

I did the following steps:

1)I added MySql Connector dependency in my Pom.xml

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>6.0.6</version>
</dependency>

2)Wildfly plugin configuration

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>1.2.1.Final</version>
        <configuration>
            <jboss-home>/opt/wildfly</jboss-home>
            <filename>${project.build.finalName}.war</filename>

            <executions>
                <execution>
                    <id>MySQL-Driver</id>
                    <phase>install</phase>
                        <goals>
                            <goal>deploy-artifact</goal>
                        </goals>
                        <configuration>
                            <groupId>mysql</groupId>
                            <artifactId>mysql-connector-java</artifactId>
                            <version>6.0.6</version>
                            <name>mysql-connector-java-6.0.6</name>
                            <driver-name>mysql-connector-java-6.0.6</driver-name>
                        </configuration>
                </execution>
                <execution>
                    <id>DataSource</id>
                        <phase>install</phase>
                        <configuration>
                            <force>false</force>
                            <address>subsystem=datasources,data-source=java:/CondominioDS</address>
                            <resources>
                                <resource>
                                    <enableResource>true</enableResource>
                                            <properties>
                                        <jndi-name>java:/CondominioDS</jndi-name>
                                        <enable>true</enable>
                                        <connection-url>jdbc:mysql://localhost:3306/Condominio?useSSL=false</connection-url>
                                        <driver-class>com.mysql.cj.jdbc.Driver</driver-class>
                                        <driver-name>mysql-connector-java-6.0.6</driver-name>
                                        <user-name>root</user-name>
                                        <password>123</password>
                                    </properties>
                                </resource>
                            </resources>
                        <retryFailedDeploymentCount>1</retryFailedDeploymentCount>
                    </configuration>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                </execution>
                <execution>
                    <id>deploy</id>
                        <phase>install</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                </execution>
            </executions>
    </configuration>
</plugin>

3)Part of Persistence.xml

<persistence-unit name="Condominio" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>java:/CondominioDS</jta-data-source>

4) mvn clean install

5) mvn wildfly:start

6) mvn wildfly:deploy

And I get the error below ....

09:47:49,668 INFO  [org.jboss.as.repository] (management-handler-thread - 1) WFLYDR0001: Content added at location /opt/wildfly/standalone/data/content/06/1a91a0f2082869d2b08334631636973944d062/content

09:47:49,692 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "teste.war" (runtime-name: "teste.war")

09:47:50,941 INFO  [org.jboss.as.jpa] (MSC service thread 1-6) WFLYJPA0002: Read persistence.xml for Condominio

09:47:51,120 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) WFLYWELD0003: Processing weld deployment teste.war

09:47:51,171 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-3) HV000001: Hibernate Validator 5.2.4.Final

09:47:51,340 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.cj.jdbc.Driver (version 6.0)

09:47:51,375 INFO  [org.jboss.weld.Version] (MSC service thread 1-3) WELD-000900: 2.3.5 (Final)

09:47:51,414 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) WFLYJCA0018: Started Driver service with driver-name = teste.war_com.mysql.cj.jdbc.Driver_6_0

09:47:51,546 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "teste.war")]) - failure description:

{
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.CondominioDS"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.persistenceunit.\"teste.war#Condominio\" is missing [jboss.naming.context.java.CondominioDS]",
        "jboss.persistenceunit.\"teste.war#Condominio\".__FIRST_PHASE__ is missing [jboss.naming.context.java.CondominioDS]"
    ]
}

09:47:51,547 ERROR [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0021: Deploy of deployment "teste.war" was rolled back with the following failure message: 
{
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.CondominioDS"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.persistenceunit.\"teste.war#Condominio\" is missing [jboss.naming.context.java.CondominioDS]",
        "jboss.persistenceunit.\"teste.war#Condominio\".__FIRST_PHASE__ is missing [jboss.naming.context.java.CondominioDS]"
    ]
}
Pickles Dog
  • 155
  • 2
  • 11
  • Do you have a server already running? Given the `wildfly-maven-plugin` configuration it should deploy the artifact, create the DS then deploy the application when you do `mvn install`. – James R. Perkins Nov 16 '17 at 18:13
  • Yes @JamesR.Perkins , I have already a server running (in Eclipse servers tab or using mvn wildfly:start before all other commands).... When I run just mvn install nothing happens on Wildfly! just build success... installing my project on my local repository... – Pickles Dog Nov 16 '17 at 18:40
  • look http://www.dontpad.com/question-47306801 – Pickles Dog Nov 16 '17 at 18:47

1 Answers1

0

OMG!!!!

I found my error!

<configuration> </configuration>

tag was closed in wrong location ..... after executions and so did not perfom the phases and goals.

Now with "mvn install" the artifact was deployed, DS was created and the application deployed..... how said @JamesR.Perkins

Pickles Dog
  • 155
  • 2
  • 11