I've attached a sample project that demonstrates the problem I'm having. I've tried both Play! 1.0 and 1.1 and can reproduce every time.
When using Fixtures.load("data.yml") in a Bootstrap Job (I followed the steps from the YABE tutorial), I get the following exception when the application loads (either in test or run mode; dev & prod) from first request:
@60g752c95
Internal Server Error (500) for request GET /@tests
Java exception (In /app/jobs/Bootstrap.java around line 15)
RuntimeException occured : Cannot load fixture data.yml: play.exceptions.UnexpectedException: Unexpected Error
play.exceptions.JavaExecutionException: Cannot load fixture data.yml: play.exceptions.UnexpectedException: Unexpected Error
at play.jobs.Job.call(Job.java:120)
at Invocation.Job(Play!)
Caused by: java.lang.RuntimeException: Cannot load fixture data.yml: play.exceptions.UnexpectedException: Unexpected Error
at play.test.Fixtures.load(Fixtures.java:147)
at jobs.Bootstrap.doJob(Bootstrap.java:15)
at play.jobs.Job.doJobWithResult(Job.java:38)
at play.jobs.Job.call(Job.java:111)
... 1 more
Caused by: java.lang.RuntimeException: play.exceptions.UnexpectedException: Unexpected Error
at play.db.jpa.JPASupport.create(JPASupport.java:53)
at play.test.Fixtures.load(Fixtures.java:132)
... 4 more
Caused by: play.exceptions.UnexpectedException: Unexpected Error
at play.db.jpa.JPASupport.edit(JPASupport.java:139)
at play.db.jpa.JPASupport.create(JPASupport.java:51)
... 5 more
Caused by: java.lang.NullPointerException
at play.data.validation.Validation.error(Validation.java:84)
at play.data.validation.Validation.addError(Validation.java:67)
at play.data.binding.Binder.bindInternal(Binder.java:187)
at play.data.binding.BeanWrapper.bind(BeanWrapper.java:47)
at play.db.jpa.JPASupport.edit(JPASupport.java:64)
... 6 more
01:59:47,461 ERROR ~
refreshing the page, the error changes to:
@60g752c96
Error during job execution (jobs.Bootstrap)
Java exception (In /app/jobs/Bootstrap.java around line 15)
RuntimeException occured : Cannot load fixture data.yml: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of models.User.lastName
play.exceptions.JavaExecutionException: Cannot load fixture data.yml: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of models.User.lastName
at play.jobs.Job.call(Job.java:120)
at Invocation.Job(Play!)
Caused by: java.lang.RuntimeException: Cannot load fixture data.yml: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of models.User.lastName
at play.test.Fixtures.load(Fixtures.java:147)
at jobs.Bootstrap.doJob(Bootstrap.java:15)
at play.jobs.Job.doJobWithResult(Job.java:38)
at play.jobs.Job.call(Job.java:111)
... 1 more
Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of models.User.lastName
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226)
at play.db.jpa.JPASupport.save(JPASupport.java:148)
at play.test.Fixtures.load(Fixtures.java:133)
... 4 more
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of models.User.lastName
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:58)
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.getForInsert(DirectPropertyAccessor.java:63)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValuesToInsert(AbstractEntityTuplizer.java:287)
at org.hibernate.tuple.entity.PojoEntityTuplizer.getPropertyValuesToInsert(PojoEntityTuplizer.java:256)
at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyValuesToInsert(AbstractEntityPersister.java:3677)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49)
at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:154)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:110)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:646)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:620)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:624)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220)
... 6 more
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String field models.User.lastName to models.User
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:55)
... 21 more
01:59:47,479 ERROR ~
I use the exact same .yml file for testing (test-data.yml) and have written full usage of the data in BasicTest.java. If I comment out the Fixtures.load("data.yml") line in Bootstrap.java, and launch in test mode, all the tests (which all load test-data.yml using Fixtures) pass fine. Yet when I try to bootstrap this data, it doesn't work.
I can't for the life of me see what I'm doing wrong, hence this bug report.
Well, the root cause is that you have a binding error on the createdAt field. Your date format is not supported. I will check why it result with some UnexpectedError however.