Possible bug: JPA's persistence.xml is deployed before datasources are created through application.xml
renannp Jan 25, 2016 9:18 AMHello.
So basically I'm creating a datasource through application.xml and referencing it in my persistence.xml.
However when I try to deploy the EAR file, it fails because the datasource is being accessed before it was created.
I did the following test:
1 - Create a datasource before deploying the application
2 - Deploy the application with a datasource to be created through application.xml
3 - Now it works and both datasources exist (so no problem with the application.xml)
I don't think it's important, but the JDBC driver is being deployed together with the EAR.
So, my guess is that this is a bug in Wildfly, but I want to confirm with you guys.
Is there an existing workaround for this, a configuration to be done or is creating the datasource before deploying the only way to avoid the issue?
I'm using Wildfly 10.0.0.CR5 and was following this sample: javaee7-samples/jpa/datasourcedefinition-applicationxml-pu at master · javaee-samples/javaee7-samples · GitHub
Thanks
application.xml
<?xml version="1.0" encoding="UTF-8"?> <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" version="7"> <display-name>Abcd-ear</display-name> <module> <web> <web-uri>Abcd-web.war</web-uri> </web> </module> <module> <ejb>Abcd-ejb.jar</ejb> </module> <library-directory>lib</library-directory> <data-source> <name>java:jboss/datasources/TestMariaDS</name> <class-name>org.mariadb.jdbc.Driver</class-name> <url>jdbc:mariadb://xxx.xxx.xxx.xxx:3306/abcd</url> <user>root</user> <password>123</password> </data-source> </application>
persistence.xml
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="Abcd_PersistenceUnit" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:jboss/datasources/TestMariaDS</jta-data-source> <properties> <!-- Properties for Hibernate --> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/> <property name="hibernate.enable_lazy_load_no_trans" value="true"/> </properties> </persistence-unit> </persistence>
Error:
02:28:08,166 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 24) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "Abcd-ear.ear")]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"Abcd-ear.ear/Abcd-ejb.jar#Abcd_PersistenceUnit\" is missing [jboss.naming.context.java.jboss.datasources.TestMariaDS]"]}
02:28:08,171 ERROR [org.jboss.as.server] (management-handler-thread - 24) WFLYSRV0021: Deploy of deployment "Abcd-ear.ear" was rolled back with the following failure message: {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"Abcd-ear.ear/Abcd-ejb.jar#Abcd_PersistenceUnit\" is missing [jboss.naming.context.java.jboss.datasources.TestMariaDS]"]}
-
server.log.zip 6.2 KB
-
server.2.log.zip 6.2 KB