aspose file tools*
The moose likes Spring and the fly likes Error creating bean with name 'mySessionFactory' defined in class path:Error setting property values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Error creating bean with name Watch "Error creating bean with name New topic
Author

Error creating bean with name 'mySessionFactory' defined in class path:Error setting property values

ali honarmand
Ranch Hand

Joined: Oct 12, 2009
Posts: 32

Hi all,
I have got problems instantiating a bean. here is the stack trace:


and the Course class:


and here is the beans.xml


Thanks priorly,


A. Honarmand
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Property "mappingResources" is expecting an hibernate xml mapping file.
See# http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/LocalSessionFactoryBean.html#setMappingResources%28java.lang.String[]%29


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Yes, or since you are using Hibernate/JPA annotations, the factoryBean has a property for "packagesToScan" which scans those packages for Annotated classes, there is also another property to use to list out the classes I forget what it was called, probably "mappedClasses"

I prefer to use the packagesToScan since that list will be smaller than the list in mappedClasses.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Tommy Delson
Ranch Hand

Joined: Apr 13, 2011
Posts: 206
The code you're trying to run is a Tutorial from com.vaannila so, I think it missing something or not fully configured.

Try the solution below...hope it help.





Here is an example:



From the example above, you can make it works.

OCPJP6-05-11
"Your life is in your hands, to make of it what you choose."
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Tommy, he is not using xml mapping, he is using Annotation mapping. So you example will not work for him. He is just setting the wrong property in the AnnotationSessionFactoryBean.

Mark
Tommy Delson
Ranch Hand

Joined: Apr 13, 2011
Posts: 206
Mark Spritzler wrote:Tommy, he is not using xml mapping, he is using Annotation mapping. So you example will not work for him. He is just setting the wrong property in the AnnotationSessionFactoryBean.

Mark



Well, based on the exception "Caused by: org.springframework.beans.NotWritablePropertyException:
Invalid property 'mappingResources' of bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]:
Bean property 'mappingResources' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?"

I can tell that "mappingResources" is not proper configured, the app looking for a resources, but it can not find due not configure correctly. Whether using Annotation mapping or not doesn't matter since, the error indicated at configuration level not application level error.

If you look carefully and check Spring document you'll find out the "mappingResources" is not configured correctly.

You can recreate the problem and confirm, I'll try and see if that's the problem or there are other problems.


@ali honarmand
Could you tell what's your status and did you get the problem solved?

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Tommy Delson wrote:
Mark Spritzler wrote:Tommy, he is not using xml mapping, he is using Annotation mapping. So you example will not work for him. He is just setting the wrong property in the AnnotationSessionFactoryBean.

Mark



Well, based on the exception "Caused by: org.springframework.beans.NotWritablePropertyException:
Invalid property 'mappingResources' of bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]:
Bean property 'mappingResources' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?"

I can tell that "mappingResources" is not proper configured, the app looking for a resources, but it can not find due not configure correctly. Whether using Annotation mapping or not doesn't matter since, the error indicated at configuration level not application level error.

If you look carefully and check Spring document you'll find out the "mappingResources" is not configured correctly.

You can recreate the problem and confirm, I'll try and see if that's the problem or there are other problems.


@ali honarmand
Could you tell what's your status and did you get the problem solved?



Yes, but he shouldn't even be setting or using the mappingResource property in his configuration. He needs to remove it and use the correct property.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error creating bean with name 'mySessionFactory' defined in class path:Error setting property values