File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Invocation of init method failed; exception is org.hibernate.InvalidMappingException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Invocation of init method failed; exception is org.hibernate.InvalidMappingException" Watch "Invocation of init method failed; exception is org.hibernate.InvalidMappingException" New topic
Author

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

Chris Da
Greenhorn

Joined: Apr 10, 2009
Posts: 6
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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

Joined: Apr 10, 2009
Posts: 6
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Invocation of init method failed; exception is org.hibernate.InvalidMappingException
 
Similar Threads
Help needed plzzzzz
Spring-Hibernate transaction management
Problem with: org.hibernate.mappingException: Unknown entity: Person
spring + hibernate
org hibernate InvalidMappingException : Could not parse mapping document from invalid