-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Error when lookup JNDI
PostPosted: Thu Aug 17, 2006 5:31 am 
Regular
Regular

Joined: Wed Apr 12, 2006 12:49 am
Posts: 105
Location: Malaysia
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.

_________________
Thank you.

Regards,
Jap.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 6:20 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Go to an appropriate forum.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.