problem loading initial-data.yml

261 views
Skip to first unread message

Luther Baker

unread,
Oct 2, 2011, 2:54:24 PM10/2/11
to play-framework
I have a Project entity:


package models;

@Entity
public class Project extends Model {

public String title;
public String subtitle;

public Project(String title, String subtitle) {
this.title = title;
this.subtitle = subtitle;
}
}

and I'm trying to create a few on startup:

@OnApplicationStart
public class Bootstrap extends Job<Bootstrap> {

public void doJob() {
if (Project.count() == 0) {
Fixtures.loadModels("initial-data.yml");
}
}

}


I mimic'd the data.yml found in the tutorial - (I don't know what the
value in parens is for):


"initial-data.yml"

Project(P1):
title:Project 1
subtitle:An application called Project 1.

Project(P2):
title:Project 2
subtitle:An application called Project 2.


but I get the folllowing error:


RuntimeException occured : Cannot load fixture initial-data.yml:
java.lang.String cannot be cast to java.util.Map

play.exceptions.JavaExecutionException: Cannot load fixture initial-
data.yml: java.lang.String cannot be cast to java.util.Map
at play.jobs.Job.call(Job.java:155)
at Invocation.Job(Play!)
Caused by: java.lang.RuntimeException: Cannot load fixture initial-
data.yml: java.lang.String cannot be cast to java.util.Map
at play.test.Fixtures.loadModels(Fixtures.java:223)
at Bootstrap.doJob(Bootstrap.java:17)
at play.jobs.Job.doJobWithResult(Job.java:50)
at play.jobs.Job.call(Job.java:146)
... 1 more
Caused by: java.lang.ClassCastException: java.lang.String cannot be
cast to java.util.Map
at play.test.Fixtures.loadModels(Fixtures.java:194)
... 4 more


If I change the yml file to the following, the error disappears but
the projects don't show up in my first page's query.


"initial-data.yml"

Project:
title:Project 1
subtitle:An application called Project 1.

Project:
title:Project 2
subtitle:An application called Project 2.


Any thoughts/help would be appreciated.

Thanks,
-Luther

Luther Baker

unread,
Oct 3, 2011, 5:18:28 AM10/3/11
to play-framework
> Do not crowd the value of the field and put in a space after the colon delimiter
> Thanks,
> Arindam

That was it! In yml file, I needed to insert a space between the
"key:" and the actual value.

Thanks very much,
-Luther
Reply all
Reply to author
Forward
0 new messages