Bonjour,
j'essaye d'utiliser une datasource mysql depuis jboss ... sans succès

Ma configuration :
- Jboss 5.1.0
- Mysql 5.1

J'ai copié mysql-connector-java-5.1.10-bin dans server/default/lib

Mysql-ds.xml (dans server/default/deploy)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?xml version="1.0" encoding="UTF-8"?>
 
<!-- See http://www.jboss.org/community/wiki/Multiple1PC for information about local-tx-datasource -->
<!-- $Id: mysql-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
<!--  Datasource config for MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html
-->
 
<datasources>
  <local-tx-datasource>
    <jndi-name>MySqlDS</jndi-name>
	<user-java-context>false</user-java-context><!-- -->
	<connection-url>jdbc:mysql://localhost:3306/dfd1</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>root</user-name>
    <password>*****</password>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
    <!-- should only be used on drivers after 3.22.1 with "ping" support
    <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
    -->
    <!-- sql to call when connection is created
    <new-connection-sql>some arbitrary sql</new-connection-sql>
      -->
    <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
    <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
      -->
 
    <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
    <metadata>
       <type-mapping>mySQL</type-mapping>
    </metadata>
  </local-tx-datasource>
</datasources>
Mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
Context initCtx = new InitialContext();
DataSource ds = (DataSource)initCtx.lookup("java:MySQLDS");
( ps: j'ai aussi essayé avec lookup("java:comp/env/MySQLDS") )

Mon erreur est:
Alors que dans le log quelque ligne plus haut il y a :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
[ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=MySqlDS' to JNDI name 'java:MySqlDS'
J'ai aussi essayé de mètre :
[dans jboss-web.xml]
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
<resource-ref>
	<res-ref-name>MySqlDS</res-ref-name>
	<!-- <res-type>javax.sql.DataSource</res-type> -->
	<jndi-name>MySqlDS</jndi-name>
</resource-ref>
ET
[dans web.xml]
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
<resource-ref>
<description>Ressource MySQL</description>
	<res-ref-name>MySQLDS</res-ref-name>
	<res-type>javax.sql.DataSource</res-type>
	<res-auth>Container</res-auth>
	<mapped-name>MySQLDS</mapped-name>
</resource-ref>
Pouvez vous m'aider ?
Merci d'avance