• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Chris Da
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic