• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Invocation of init method failed; exception is org.hibernate.InvalidMappingException

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am trying to write one example for spring and hibernate usage. I am getting the following error in ApplicationContext.xml.
Can you please guide me.

Error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in class path resource [spring/swh/ApplicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1175)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory

************************************************************************************************************

ApplicationContext.xml

***********************************************************
Servlet Invocation


ApplicationContext ctx = new ClassPathXmlApplicationContext("/spring/swh/ApplicationContext.xml");
BeanFactory factory=(BeanFactory)ctx;


Thanks in Advance.

Regards
Kris
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like it is having problems parsing your hbm file. Is there a closing tag missing or missing a "/"

I can't tell, your post is too tough to read. You can try to repost using the CODE tags so that your XML will retain the indentation and then we can see how everything lines up.

Mark
 
Mark Spritzler
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As that is nicer looking. I added the code tags for you.

For your mappings you need <list></list> around your <value></value> tags like



Mark
 
Chris Da
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
Thank you very much for your response.
I have tried with following code, however it doesn't work, getting same error message


<property name="mappingResources">
<list>
<value>/spring/swh/user.hbm.xml</value>
</list>
</property>

I am really wondering why it is not working.
Appreciate your help.

Regards
Kris
 
Mark Spritzler
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then my next belief would be that the value you have set is incorrect. Still keep the <list> though. that should still be in there.

<value>/spring/swh/user.hbm.xml</value>

Do you need the "/" in the front? That to me says that the file is from the root of your filesystem.

Mark
 
Hot dog! An advertiser loves us THIS much:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic