Voulzy Voulzy - 6 months ago 15
Java Question

Missing dependency JBoss AS 7.1.1

I know there is a lots of topics on this error, but I am still having some troubles with it.

I'm actually trying to deploy a war on JBoss 7.1.1 and unfortunately i'm getting this error again and again :

JBAS014775: New missing/unsatisfied dependencies:
service jboss.naming.context.java.module.myapplication.myapplication.env.jdbc_app (missing) dependents: [service jboss.naming.context.java.module.myapplication.myapplication.env.jdbc.PKBNM01]


This is how my DS is defined in standalone.xml (I'm well connected to my DB) :

<datasource jta="false" jndi-name="java:/jdbc/jdbc_app" pool-name="jdbc_app" enabled="true" use-ccm="false">
<connection-url>jdbc:oracle:thin:@localhost:1521:xe</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>ojdbc6.jar</driver>
<security>
<user-name>ADMIN</user-name>
<password>PASSWORD</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>


This is the jboss-web.xml :

<jboss-web>
<resource-ref>
<res-ref-name>jdbc/PKBNM01</res-ref-name>
<jndi-name>jdbc_app</jndi-name>
</resource-ref>
<context-root>myApplication</context-root>
</jboss-web>


And this is my web.xml :

<resource-ref>
<res-ref-name>jdbc/PKBNM01</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>


If someone could explain me what I did wrong or even just give me a clue, it would be very welcomed...

Thank you

Answer

Bit hard to give a definitive answer, but I can make some observations.

1) I've never had to configure anything in a jboss-web.xml or web.xml to make a datasource available to an application module in JBoss. The datasource declaration in the standalone.xml is enough

2) The official documentation states you should create a driver module; I suggest you follow that. https://community.jboss.org/wiki/DataSourceConfigurationInAS7

3) This is what my datasources look like (MySQL database example):

<datasource jndi-name="java:jboss/datasources/MyDS" pool-name="MyDS" enabled="true" use-java-context="true">
  <connection-url>jdbc:mysql://localhost:3306/somedatabase?useUnicode=true&amp;characterEncoding=UTF-8</connection-url>
  <driver>mysql</driver>
  <security>
    <user-name>someuser</user-name>
    <password>somepass</password>
  </security>
</datasource>
<drivers>
  <driver name="mysql" module="com.mysql"/>
</drivers>

Basically I just copied and adapted the 'ExampleDS' that is in the standalone.xml by default.

For completion, a JPA persistence.xml could then look like this; I removed some junk from it to make it to the point:

<persistence ... version="2.0">  
   <persistence-unit name="MyPU">  
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:jboss/datasources/MyDS</jta-data-source>
      ...
   </persistence-unit>  
</persistence>

So just the JNDI name of the datasource as it is defined in the standalone.xml.

Hope one of these observations helps you to get a step further.

Comments