Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Problem in accessing Data Source via Spring's Java Configuration

 
Ankur Luthra
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
 
Jayesh A Lalwani
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?
 
Bill Gorder
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic