This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

class cast exception while lookup

Oct 22nd, 2005, 05:30 AM

HI,

Thanks in advance.please help me to solve this exception.
I am new to JBOSS and spring.I wrote a simple program which gets database connection from connection pool.In lookup I am getting class cast exception saying "Cannot cast javax.naming.Reference to javax.sql.DataSource-Class cast exception".I cannot understand how lookup returns a Reference object. The same thing works well in a JSP page.Here's my code:

Your problem is related to JBoss and not Spring; search the forums, IIRC there was a certain configuration parameter needed.
Btw, you can use org.springframework.jndi.JndiObjectFactoryBean which can retrieve objects from JNDI (and use it inside your application context).