Fixtures: accept entities with no initial values

Bug #582246 reported by Eve Pokua
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
play framework
Fix Committed
Low
Erwan Loisant

Bug Description

I get the following error when I try running my app. -

@62gidn956
Internal Server Error (500) for request GET /

Java exception (In /app/Bootstrap.java around line 13)
RuntimeException occured : Cannot load fixture initial-data.yml: null

play.exceptions.JavaExecutionException: Cannot load fixture initial-data.yml: nu
ll
        at play.jobs.Job.call(Job.java:119)
        at Invocation.Job(Play!)
Caused by: java.lang.RuntimeException: Cannot load fixture initial-data.yml: nul
l
        at play.test.Fixtures.load(Fixtures.java:196)
        at Bootstrap.doJob(Bootstrap.java:13)
        at play.jobs.Job.doJobWithResult(Job.java:37)
        at play.jobs.Job.call(Job.java:110)
        ... 1 more
Caused by: java.lang.NullPointerException
        at play.test.Fixtures.serialize(Fixtures.java:201)
        at play.test.Fixtures.load(Fixtures.java:161)
        ... 4 more

Bootstrap file :

import play.*;
import play.jobs.*;
import play.test.*;

import models.*;

@OnApplicationStart
public class Bootstrap extends Job {

    public void doJob() {
        // Check if the database is empty
        if(UserGroups.count() == 0) {
            Fixtures.load("initial-data.yml");
          }
    }

}

yml file :

# Test data

DEPARTMENT(K):
deptId: K
departmentname: Kids

DEPARTMENT(M):
deptId: M
departmentname: Mens ware

DEPARTMENT(W):
deptId: W
departmentname: Momens ware

DEPARTMENT(H):
deptId: H
departmentname: Homeware

USERGROUPS(Store Manager):
name: Store-Manager
description: Store Manager

USERGROUPS(Manager):
name: Manager
description: Manager of KAK

USERGROUPS(Co-worker):
name: Co-worker
description: A member of staff

USERGROUPS(Customer):
name: Customer
description: A customer

USERGROUPS(Boss):
name: Boss
description: The boss

SUPPLIERS(The Hyde Ltd):
address1: 566 Wall Road
address2: Barmingham, UK
suppliername: The Hyde Ltd
postcode: BQ1 7WU
phoneno: 87986768

SUPPLIERS(Hanna Ltd):
address1: 78 Market Place Street
address2: Oxford
suppliername: Hanna Ltd
postcode: OR4 8ET
phoneno: 8998786

SUPPLIERS(Maner Ltd):
address1: 87 Corner Street
address2: Manchester
suppliername: Maner Ltd
postcode: MW3 7TY
phoneno: 987986778

STAFF(Paul):
address1: P . O. BOX, 8765, Kumasi
address2: West Africa
surname: White
postcode: 8765
firstname: Paul
phoneno: 798790987
password: p

STAFF(Sarah):
address1: P . O. BOX, 9876, Kumasi
address2: West Africa
surname: Walters
postcode: 9876
firstname: Sarah
phoneno: 879879988
password: p2

STAFF(Paul):
address1: P . O. BOX, 8745, Kumasi
address2: West Africa
surname: Smith
postcode: 8745
firstname: Paul
phoneno: 798711653
password: p4

STAFF(Akos):
address1: P . O. BOX, 9811, Kumasi
address2: West Africa
surname: Brown
postcode: 9811
firstname: Akos
phoneno: 879877652
password: p3

DISCOUNTRATE(H):
discntcode: H
rate: 3000.0

DISCOUNTRATE(L):
discntcode: L
rate: 1000.0

DISCOUNTRATE(M):
discntcode: M
rate: 1500.0

DISCOUNTRATE(N):
discntcode: N
rate: 0.0

CONTAINERS(3cont):
contId: 3cont
totalbales: 450
suppliercompanyent: 1

CONTAINERS(4cont):
contId: 4cont
totalbales: 450
suppliercompanyent: 2

CONTAINERS(1):
contId: 1
totalbales: 450
suppliercompanyent: 1

BALES(Men Tops):
balsize: all sort of sizes
balpic: menjeans.png
priceInPounds: 24.0
colour: All sort of colours
price: 56.0
balname: Men Tops
description: All sort of men tops
deptId: M
contId: 1
discountRateent: H
STOCKQUAN: 50

BALES(Children Clothes):
balsize: all sort of sizes
balpic: menjeans.png
priceInPounds: 34.0
colour: All sort of colours
price: 67.0
balname: Children Clothes
description: All sort of children clothes
deptId: K
contId: 3cont
discountRateent: M
STOCKQUAN: 100

BALES(Women Tops) :
balsize: all sort of sizes
balpic: menjeans.png
priceInPounds: 23.0
colour: All sort of colours
price: 45.0
balname: Women Tops
description: All sort of women tops
deptId: W
contId: 1
discountRateent: N
STOCKQUAN: 100

BALES(Men Jeans):
balsize: all sort of sizes
balpic: menjeans.png
priceInPounds: 34.0
colour: All sort of colours
price: 67.0
balname: Men Jeans
description: All sort of men jeans
deptId: M
contId: 1
discountRateent: L
STOCKQUAN: 100

If you need further details, pls let me know.

Thanks

eve

Revision history for this message
Eve Pokua (gorgeous65) wrote :
Revision history for this message
Erwan Loisant (eloisant) wrote :

That's a big file, please try to remove entries to make it as small as possible while still reproducing the error.

Changed in play:
status: New → Incomplete
Revision history for this message
Eve Pokua (gorgeous65) wrote :

I have added the app. attached as zip.

Revision history for this message
Eve Pokua (gorgeous65) wrote :

Hi,

I have taking out some and reduced it. - error reproduced -

17:06:23,260 ERROR ~

@62gj9ep4b
Internal Server Error (500) for request GET /

Java exception (In /app/Bootstrap.java around line 13)
RuntimeException occured : Cannot load fixture initial-data.yml: null

play.exceptions.JavaExecutionException: Cannot load fixture initial-data.yml: nu
ll
        at play.jobs.Job.call(Job.java:119)
        at Invocation.Job(Play!)
Caused by: java.lang.RuntimeException: Cannot load fixture initial-data.yml: nul
l
        at play.test.Fixtures.load(Fixtures.java:196)
        at Bootstrap.doJob(Bootstrap.java:13)
        at play.jobs.Job.doJobWithResult(Job.java:37)
        at play.jobs.Job.call(Job.java:110)
        ... 1 more
Caused by: java.lang.NullPointerException
        at play.test.Fixtures.serialize(Fixtures.java:201)
        at play.test.Fixtures.load(Fixtures.java:161)
        ... 4 more

Thanks

Revision history for this message
Eve Pokua (gorgeous65) wrote : RE: [Bug 582246] Re: yml file problems
Download full text (5.4 KiB)

Hi,

I've reduced the file and attached it again. Colud somebody please take a look.

Thanks.

eve

> Date: Tue, 18 May 2010 13:38:09 +0000
> From: <email address hidden>
> To: <email address hidden>
> Subject: [Bug 582246] Re: yml file problems
>
> That's a big file, please try to remove entries to make it as small as
> possible while still reproducing the error.
>
> ** Changed in: play
> Status: New => Incomplete
>
> --
> yml file problems
> https://bugs.launchpad.net/bugs/582246
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in play framework: Incomplete
>
> Bug description:
> I get the following error when I try running my app. -
>
> @62gidn956
> Internal Server Error (500) for request GET /
>
> Java exception (In /app/Bootstrap.java around line 13)
> RuntimeException occured : Cannot load fixture initial-data.yml: null
>
> play.exceptions.JavaExecutionException: Cannot load fixture initial-data.yml: nu
> ll
> at play.jobs.Job.call(Job.java:119)
> at Invocation.Job(Play!)
> Caused by: java.lang.RuntimeException: Cannot load fixture initial-data.yml: nul
> l
> at play.test.Fixtures.load(Fixtures.java:196)
> at Bootstrap.doJob(Bootstrap.java:13)
> at play.jobs.Job.doJobWithResult(Job.java:37)
> at play.jobs.Job.call(Job.java:110)
> ... 1 more
> Caused by: java.lang.NullPointerException
> at play.test.Fixtures.serialize(Fixtures.java:201)
> at play.test.Fixtures.load(Fixtures.java:161)
> ... 4 more
>
>
>
>
> Bootstrap file :
>
> import play.*;
> import play.jobs.*;
> import play.test.*;
>
> import models.*;
>
> @OnApplicationStart
> public class Bootstrap extends Job {
>
> public void doJob() {
> // Check if the database is empty
> if(UserGroups.count() == 0) {
> Fixtures.load("initial-data.yml");
> }
> }
>
> }
>
> yml file :
>
> # Test data
>
> DEPARTMENT(K):
> deptId: K
> departmentname: Kids
>
> DEPARTMENT(M):
> deptId: M
> departmentname: Mens ware
>
> DEPARTMENT(W):
> deptId: W
> departmentname: Momens ware
>
> DEPARTMENT(H):
> deptId: H
> departmentname: Homeware
>
> USERGROUPS(Store Manager):
> name: Store-Manager
> description: Store Manager
>
>
> USERGROUPS(Manager):
> name: Manager
> description: Manager of KAK
>
> USERGROUPS(Co-worker):
> name: Co-worker
> description: A member of staff
>
> USERGROUPS(Customer):
> name: Customer
> description: A customer
>
> USERGROUPS(Boss):
> name: Boss
> description: The boss
>
> SUPPLIERS(The Hyde Ltd):
> address1: 566 Wall Road
> address2: Barmingham, UK
> suppliername: The Hyde Ltd
> postcode: BQ1 7WU
> phoneno: 87986768
>
> SUPPLIERS(Hanna Ltd):
> address1: 78 Market Place Street
> address2: Oxford
> suppliername: Hanna Ltd
> postcode: OR4 8ET
> phoneno: 8998786
>
>
> SUPPLIERS(Maner Ltd):
> address1: 87 Corner Street
> address2: Manchester
> suppliername: Maner Ltd
> postcode: MW3 7TY
> phoneno: 987986778
>
>
> STAFF(Paul):
> address1: P . O. BOX, 8765, Kumasi
> address2: West Africa
> surname: White
> postcode: 8765
> firstname: Paul
> phoneno: 798790987
> password: p
>
>
> STAFF(Sarah):
> address1: P . O. BOX, 9876, Kumasi
> address2: West Africa
> surname: Walters
> postcode: 9876
...

Read more...

Revision history for this message
Erwan Loisant (eloisant) wrote : Re: yml file problems

Thanks, I'll take a look at it.

Changed in play:
assignee: nobody → Erwan Loisant (eloisant)
status: Incomplete → Confirmed
Revision history for this message
Erwan Loisant (eloisant) wrote :

It's probably a problem in your file but we need to provide a better error message. I'm working on it.

Revision history for this message
Erwan Loisant (eloisant) wrote :

Your yaml says DEPARTMENT but your entity is Departmentent. They should match, you should just call your entity Department.

I'm keeping the bug open to fix the vague error message thing.

Erwan Loisant (eloisant)
summary: - yml file problems
+ Better error reporting in Fixtures
Revision history for this message
Erwan Loisant (eloisant) wrote : Re: Better error reporting in Fixtures

Gee, there's a lot of issues in your code. As I said you have the wrong name for your entities (or in your YAML file). That causes a correct error message, unless it's hidden by another error. The error that you have is that you didn't indent anything in your yaml file. See examples or doc specific to Yaml.

So I just fixed a null pointer exception that happened when you tried to create an entity with no property set in it, such as simply:

User:

instead of

User:
   name: toto
   url: http://tata.com

I decided to accept it because (1) it's valid YAML and (2) you can actually create a instance with no default argument from Java, so there's no reason to forbid it from fixtures. So it may not be very useful, but it's there.

Obviously you'll still have issues until you indent your file correctly. Feel free to come back to us through the mailing list or the bug tracker if you suspect a bug or see an other area where error reporting can be improved.

summary: - Better error reporting in Fixtures
+ Fixtures: accept entities with no initial values
Changed in play:
importance: Undecided → Low
status: Confirmed → Fix Committed
Revision history for this message
Eve Pokua (gorgeous65) wrote : RE: [Bug 582246] Re: yml file problems
Download full text (5.4 KiB)

Hi,

I had @Table(name=DEPARTMENT)

So I thought I had to use the table's name

eve

> Date: Mon, 31 May 2010 13:13:08 +0000
> From: <email address hidden>
> To: <email address hidden>
> Subject: [Bug 582246] Re: yml file problems
>
> Your yaml says DEPARTMENT but your entity is Departmentent. They should
> match, you should just call your entity Department.
>
> I'm keeping the bug open to fix the vague error message thing.
>
> --
> yml file problems
> https://bugs.launchpad.net/bugs/582246
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in play framework: Confirmed
>
> Bug description:
> I get the following error when I try running my app. -
>
> @62gidn956
> Internal Server Error (500) for request GET /
>
> Java exception (In /app/Bootstrap.java around line 13)
> RuntimeException occured : Cannot load fixture initial-data.yml: null
>
> play.exceptions.JavaExecutionException: Cannot load fixture initial-data.yml: nu
> ll
> at play.jobs.Job.call(Job.java:119)
> at Invocation.Job(Play!)
> Caused by: java.lang.RuntimeException: Cannot load fixture initial-data.yml: nul
> l
> at play.test.Fixtures.load(Fixtures.java:196)
> at Bootstrap.doJob(Bootstrap.java:13)
> at play.jobs.Job.doJobWithResult(Job.java:37)
> at play.jobs.Job.call(Job.java:110)
> ... 1 more
> Caused by: java.lang.NullPointerException
> at play.test.Fixtures.serialize(Fixtures.java:201)
> at play.test.Fixtures.load(Fixtures.java:161)
> ... 4 more
>
>
>
>
> Bootstrap file :
>
> import play.*;
> import play.jobs.*;
> import play.test.*;
>
> import models.*;
>
> @OnApplicationStart
> public class Bootstrap extends Job {
>
> public void doJob() {
> // Check if the database is empty
> if(UserGroups.count() == 0) {
> Fixtures.load("initial-data.yml");
> }
> }
>
> }
>
> yml file :
>
> # Test data
>
> DEPARTMENT(K):
> deptId: K
> departmentname: Kids
>
> DEPARTMENT(M):
> deptId: M
> departmentname: Mens ware
>
> DEPARTMENT(W):
> deptId: W
> departmentname: Momens ware
>
> DEPARTMENT(H):
> deptId: H
> departmentname: Homeware
>
> USERGROUPS(Store Manager):
> name: Store-Manager
> description: Store Manager
>
>
> USERGROUPS(Manager):
> name: Manager
> description: Manager of KAK
>
> USERGROUPS(Co-worker):
> name: Co-worker
> description: A member of staff
>
> USERGROUPS(Customer):
> name: Customer
> description: A customer
>
> USERGROUPS(Boss):
> name: Boss
> description: The boss
>
> SUPPLIERS(The Hyde Ltd):
> address1: 566 Wall Road
> address2: Barmingham, UK
> suppliername: The Hyde Ltd
> postcode: BQ1 7WU
> phoneno: 87986768
>
> SUPPLIERS(Hanna Ltd):
> address1: 78 Market Place Street
> address2: Oxford
> suppliername: Hanna Ltd
> postcode: OR4 8ET
> phoneno: 8998786
>
>
> SUPPLIERS(Maner Ltd):
> address1: 87 Corner Street
> address2: Manchester
> suppliername: Maner Ltd
> postcode: MW3 7TY
> phoneno: 987986778
>
>
> STAFF(Paul):
> address1: P . O. BOX, 8765, Kumasi
> address2: West Africa
> surname: White
> postcode: 8765
> firstname: Paul
> phoneno: 798790987
> password: p
>
>
> STAFF(Sarah):
> address1: P . O. BOX, 9876, Kumasi
> address2: West Africa
> surname: Walters
> postcode...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.