Grails

not possible to instantiate Java domain class with create()

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.2 final
  • Fix Version/s: 1.2.1
  • Component/s: Persistence
  • Labels:
    None
  • Environment:
    max osx 10.6

Description

creating a java domain class instance with the static create() method fails with the following exception:

e.g. com.troii.domain.User.create()

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.troii.domain.User' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1041)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:273)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:265)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1004)
at org.springframework.beans.factory.BeanFactory$getBean.call(Unknown Source)

it seems that the bug occurs in DomainClassGrailsPlugin.doWithSpring where the application's domain class instances et.al. are added to the ApplicationContext.

caused by this bug, data-binding throws exceptions when auto-instantiating java domain classes e.g. in GrailsDataBinder.autoInstantiateDomainInstance

Activity

Hide
Jeff Brown added a comment -

All domain classes (Java or otherwise) should have the create method now.

http://github.com/grails/grails/commit/3e164013950a2b1de649014b603b23054f85d616

Show
Jeff Brown added a comment - All domain classes (Java or otherwise) should have the create method now. http://github.com/grails/grails/commit/3e164013950a2b1de649014b603b23054f85d616

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: