• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
ali honarmand
Ranch Hand
Posts: 32
Java Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tommy Delson
Ranch Hand
Posts: 206
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 206
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic