2

I have a JAVA EE 7 project that use WildFly 9.0.2 Final release as an application server and I had configured the datasource using the tag at web.xml it works fine, but when I use WildFly 8.1 it does not work anymore.

the relevant part of the web.xml:

<!-- Mysql datasource configuration -->

<data-source>
    <name>java:app/datasources/MysqlAuronDS</name>
    <class-name>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</class-name>
    <url>jdbc:mysql://localhost:3306/auron</url>
    <user>root</user>
    <password>123456</password>
    <transactional>true</transactional>
    <isolation-level>TRANSACTION_READ_COMMITTED</isolation-level>
    <initial-pool-size>2</initial-pool-size>
    <max-pool-size>100</max-pool-size>
    <min-pool-size>10</min-pool-size>
    <max-statements>0</max-statements>
</data-source>
<!-- Postgres datasource configuration -->
<data-source>
    <name>java:app/datasources/PostgresAuronDS</name>
    <class-name>org.postgresql.xa.PGXADataSource</class-name>
    <url>jdbc:postgresql://localhost:5432/auron</url>
    <user>postgres</user>
    <password>123456</password>
    <transactional>true</transactional>
    <isolation-level>TRANSACTION_READ_COMMITTED</isolation-level>
    <initial-pool-size>2</initial-pool-size>
    <max-pool-size>100</max-pool-size>
    <min-pool-size>10</min-pool-size>
    <max-statements>0</max-statements>
</data-source>

the persistence unit on persistence.xml:

<persistence-unit name="" transaction-type="JTA">
    <description>Forge Persistence Unit</description>
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <jta-data-source>java:app/datasources/PostgresAuronDS</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
        <property name="hibernate.hbm2ddl.auto" value="update" />
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.format_sql" value="true" />
        <property name="hibernate.transaction.flush_before_completion"
            value="true" />
        <!-- 
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
         -->
        <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
    </properties>
</persistence-unit>

The log is :

18:34:31,251 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "auron.war")]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"auron.war#\".__FIRST_PHASE__ is missing [jboss.naming.context.java.app.auron.datasources.PostgresAuronDS]"]}
18:34:31,314 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "auron.war" (runtime-name : "auron.war")
18:34:31,320 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
    service jboss.naming.context.java.app.auron.datasources.PostgresAuronDS (missing) dependents: [service jboss.persistenceunit."auron.war#".__FIRST_PHASE__] 

18:34:31,558 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment auron.war (runtime-name: auron.war) in 18ms
18:34:31,605 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
18:34:31,605 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
18:34:31,606 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.1.0.Final "Kenny" started in 6119ms - Started 184 of 233 services (81 services are lazy, passive or on-demand)
18:34:31,817 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018558: Undeployed "auron.war" (runtime-name: "auron.war")
18:34:31,818 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
    service jboss.persistenceunit."auron.war#".__FIRST_PHASE__ (missing) dependents: [service jboss.deployment.unit."auron.war".POST_MODULE] 

Note that I have configured two datasources and I can change the datasource on the persistence unit also note that the drivers needed are handled by maven.

danillosl
  • 519
  • 3
  • 7
  • 13
  • Configuring the MySQL root user as datasource is a bad idea from a security point of view. Beside that: you should add the expected and actual behaviour and error messages you get. Further, ensure the drivers where installed properly (I'm not familar with Wildfly, but in JBoss 7 they have to be installed into the modules folder or be deployed - check that). – try-catch-finally Nov 28 '15 at 18:44
  • That datasource is just for testing and just edited the question with the error messaging, thanks @try-catch-finnaly. – danillosl Nov 28 '15 at 18:56
  • Those error messages don't seem to indicate anything about a datasource issue. How are you deploying your application? – James R. Perkins Nov 30 '15 at 18:59
  • I'm using the eclipse flow to deploy, about the error, if I configure the datasource on the wildfly 8.1 using the standalone.xml it works fine, but don't work when configured on web.xml, thats why I think that the problem lies on wildfly 8.1 hability to understand the datasource on web.xml. obs: Just edited the log, for some reason the relevant part got cutted out. – danillosl Dec 01 '15 at 20:49
  • 1
    Instead of keeping datasources in web.xml, you should configure it in `$WILDFLY_HOME/standalone/conf/standalone.xml`. – Everv0id Dec 01 '15 at 22:33
  • 2
    Everv0id I know that functionality of the wildfly server and it works fine as I said on the previous comment, but I have the need to configure the datasource on the project and not on the server, thanks for the attention. – danillosl Dec 02 '15 at 00:38
  • did you find out if you could do the ds on web.xml ? – Ced Jun 02 '16 at 23:41
  • @Everv0id why *should* data sources be defined in standalone.xml? – Arjan Tijms Apr 30 '18 at 16:42

0 Answers0