• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in accessing Data Source via Spring's Java Configuration

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using following way to create sessionFactory.

I want to use JNDI Name configured on Tomcat Server for instantiating the Data Source.

So I created another Bean

When I use ,I am not able to instantiate the DataSource and get following Exception.

Please let me know what am I doing wrong.

Regards,
Ankur
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens if you don't call afterPropertiesSet in your dataSOurce method? You shouldn't need to call afterPropertiesSet. Spring will call it for you at the right time. It could be that you are calling it too early

Also, can you put the whole exception in your next post?
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


That does not look like you are using the JNDI datasource I saw above, so that is your first problem.

Also make sure you are using the correct package namespace for LocalSessionFactory bean depending on your version of Hibernate. If you are using the latest Hibernate make sure to also be using the latest Spring.

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/orm/hibernate4/LocalSessionFactoryBean.html

Are you setting hibernate.dialect property in those properties you are passing in?

Btw it sounds like your moving to JNDI anyway but I would not recommend using BasicDataSource in a production application or the Apache Commons DBCP stuff. That is pretty dated and has known issues. There are more viable solutions available.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic