Alan C.
Alan C.

Reputation: 635

Play Framework routing error that I can't fix

I am building my first controller with the Play Framework. I'm receiving the error:

Compilation error value getAll is not a member of controllers.api.protocol.Period

My routes.conf file looks like:

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET        /                                     controllers.Application.index()

GET        /api/protocol/period                  controllers.api.protocol.Period.getAll()

# Map static resources from the /public folder to the /assets URL path
GET        /assets/*file        controllers.Assets.versioned(path="/public", file: Asset)

and "controllers/api/protocol/Period.java" looks like:

package controllers.api.protocol;

import com.avaje.ebean.Model;
import play.mvc.Controller;
import java.util.List;
import play.mvc.*;
import static play.libs.Json.toJson;

public class Period extends Controller {

    public static Result getAll() {
        List<model.Protocol.Period> periods = new Model.Finder<Integer.class>(model.Protocol.Period.class).all();
        return ok(toJson(periods));
    }
}

I am lost.

Upvotes: 0

Views: 124

Answers (1)

bjfletcher
bjfletcher

Reputation: 11508

That's great, and welcome. :)

Remove static from public static Result getAll() and you're sorted.

Upvotes: 1

Related Questions