DataSource binding to org.jboss.resource.adapter.jdbc.Wrappe
mendret Feb 24, 2009 6:12 AMHello
i'm trying to migrate a webapp from tomcat 4.x to JBoss 5.0.0.GA but got stuck with the DataSources, the webapp uses two of them, both are mySql-Databases, though i created a mysql-ds.xml and put it into the deploy-directory, than edited the web.xml of the webapp and added a jboss-web.xml both in the WEB-INF folder of the webapp.
I hope it is a config error, because since it is not my webapp i cannot change the code.
the webapp is an exploded war wich i put under an deploy.last in the deploy folder of the server.
but i get the following error when starting the server:
... Caused by: java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.WrapperDataSource cannot be cast to javax.sql.DataSource ...
the mysql-ds.xml
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>jdbc/ProdDataSource</jndi-name> <connection-url>jdbc:mysql://localhost:3306/mydb?characterEncoding=utf-8&autoReconnect=true </connection-url> <use-java-context>true</use-java-context> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>***</user-name> <password>***</password> <max-pool-size>10</max-pool-size> <check-valid-connection-sql> select CID from COMMON_ASSET where CID=1000 </check-valid-connection-sql> <metadata> <type-mapping>mySQL</type-mapping> </metadata> </local-tx-datasource> </datasources>
web.xml
<?xml version="1.0" encoding="ISO-8859-15"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <resource-ref> <res-ref-name>java:jdbc/ProdDataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> <resource-ref> <res-ref-name>java:jdbc/LiveDataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> ... </web-app>
jboss-web.xml
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd"> <jboss-web> <resource-ref> <res-ref-name>jdbc/ProdDataSource</res-ref-name> <jndi-name>java:jdbc/ProdDataSource</jndi-name> </resource-ref> <resource-ref> <res-ref-name>jdbc/LiveDataSource</res-ref-name> <jndi-name>java:jdbc/LiveDataSource</jndi-name> </resource-ref> </jboss-web>
and the corresponding code snippet
... Context initContext = new InitialContext(); Context appContext = (Context)initContext.lookup("java:comp/env"); DataSource ds = (DataSource)appContext.lookup(datasourceName); ...
if someone could tell me what i'm doing wrong, that would be really nice.