Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that this question has been answered before, but none of the responses seem to help me, since i am not using a datasource in my project.
I a have a Maven project, integrated with Spring and Hibernate, connecting to a SQL Server 2014 database.
This is my pom.xml, where you can see the versions:



This is hibernate.cfg.xml:



And the class where i create the session factory:



I use Tomcat 8. Whenever i run it, i get UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]
I have tried adding the details for the c3p0 connection pool as i have seen in an earlier post and i don't get the error anymore, but the server doesn't start up either, just hangs there after creating the pool.
Can someone, please, help with that?
 
A Misa
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UPDATE

Well, i have figured it out. Seems like, instead of my current sessionFactory creation, I should have had something like:




Which means i externalized the properties from hibernate.cfg.xml like that:



Which is pretty ok for me, I am not really into xml configurations. But i still don't understand why i cannot import the properties from hibernate.cfg.xml. It should be a way of loading them, even though this kind of configuration isn't the newest or the most up to date.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!