Fatima Tahir Fatima Tahir - 9 days ago 4
Java Question

Unable to resolve data source dependencies in Jboss

I am trying to deploy a JEE web app on JBoss server through eclipse but i am unable to resolve a dependency error related to data sources. Strange thing is when i am start deploying console shows this message

JBAS014776: Newly corrected services:
service jboss.naming.context.java.jboss.datasources.AssetTrackerDS (no longer required)


But deployment fails with this error.

ERROR [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "AssetTracker.war" was rolled back with the following failure message: {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.persistenceunit.\"AssetTracker.war#AssetTracker\" is missing [jboss.naming.context.java.jboss.datasources.AssetTrackerDS]"]}


JBoss server is correctly configured with database, connection test shows positive result.

Data source configuration in standalone.xml

<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jta="true" jndi-name="java:jboss/datasource/AssetTrackerDS" pool-name="AssetTrackerDS" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:postgresql://localhost:5432/test</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgresql-9.4.1212.jre6.jar</driver>
<security>
<user-name>***</user-name>
<password>***</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
<background-validation>true</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
</validation>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>


persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit transaction-type="JTA" name="AssetTracker">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/AssetTrackerDS</jta-data-source>
<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.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="transaction.flush_before_completion" value="true" />
<property name="connection.pool_size" value="5" />
<property name="hibernate.format_sql" value="false"/>
</properties>
</persistence-unit>
</persistence>


I am using JBoss EAP 6.2 and Eclipse Neon.

Answer

You have a spelling error:

 <datasource jta="true" jndi-name="java:jboss/datasource/AssetTrackerDS"

versus

<jta-data-source>java:jboss/datasources/AssetTrackerDS</jta-data-source>