Hi,
I gotten the following code from the caveatEmptor project. I deploy my application to Jboss 4.0.3SP1.
Code:
/**
* Returns the SessionFactory used for this static class.
*
* @return SessionFactory
*/
public static SessionFactory getSessionFactory() {
/* Instead of a static variable, use JNDI:*/
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) {
throw new InfrastructureException(ex);
}
return sessions;
/*return sessionFactory;*/
}
However, the application gives the following error when run.
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
I seems like error happen at "sessions = (SessionFactory)ctx.lookup(jndiName);" because i don't see the output of "2222".
Can you please advise what is wrong here?
Thanks in advance.