Error when lookup JNDI
Hi all,
I'm using Netbeans 5, Hibernate 3.2 cr2 and Jboss 4.0.3SP1, mysql 5
When I try to run the project from netbeans 5, I got the following error. Anything not right that cause the error?
08:05:53,246 INFO [STDOUT] 1111
08:05:53,246 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: org.jboss.resource.adapter.jdbc.WrapperDataSource
So far from what I find out, it looks like the error happens at sessions = (SessionFactory)ctx.lookup(jndiName) line, because I don't see the output of "2222". Below is the function of getSessionFactory() that resides in my HibernateUtil.java
publicstatic SessionFactory getSessionFactory(){
SessionFactory sessions =null;
try{
Context ctx =new InitialContext();
String jndiName ="java:jdbc/cis";
System.out.println("1111");
sessions = (SessionFactory)ctx.lookup(jndiName);
System.out.println("2222");
}catch (NamingException ex){
thrownew InfrastructureException(ex);
}
return sessions;
}
Below is my mysql-ds.xml in Jboss
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: mysql-ds.xml,v 1.3.2.1 2004/12/01 11:46:00 schrouf Exp $ -->
<!-- Datasource configfor MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html
-->
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/cis</jndi-name>
<connection-url>jdbc:mysql://localhost:3309/test</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>password</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- sql to call when connection is created
<new-connection-sql>select count(*) from t_department</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool
<check-valid-connection-sql>select count(*) from t_department</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Really appreciate some help.
--
Thank you.
Regards,
Jap

