Playframework 2.5 and ebean errors

809 views
Skip to first unread message

klmbear

unread,
Sep 25, 2017, 9:59:49 AM9/25/17
to Play Framework
I have done many searches and tried everything I have found nothing works, how do you get this ebean to work?  Yes I am new to this play framework.  I am using intelliJ 2017.2.3, Play Framework 2.5

Was just trying a simple example:
package models;
import com.sun.javafx.beans.IDProperty;
import play.db.ebean.Model;
import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Account extends Model {
@ID
public String id;
public String dstr;
public String rt;
public String ctrl;
public String folioz;

}

errors:
Error:(3, 21) java: package play.db.ebean does not exist
Error:(4, 25) java: package javax.persistence does not exist
Error:(5, 25) java: package javax.persistence does not exist
Error:(8, 30) java: cannot find symbol
  symbol: class Model
Error:(7, 2) java: cannot find symbol
  symbol: class Entity
Error:(9, 6) java: cannot find symbol
  symbol:   class ID
  location: class models.Account


application.conf:

db {
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`

# https://www.playframework.com/documentation/latest/Developing-with-the-H2-Database
default.driver = org.h2.Driver
default.url = "jdbc:h2:mem:play"
default.username = sa
default.password = ""

# You can turn on SQL logging for any datasource
# https://www.playframework.com/documentation/latest/Highlights25#Logging-SQL-statements
#default.logSql=true
}
ebean.default = ["models.*"]



build.sbt:

lazy val root = (project in file(".")).enablePlugins(PlayJava,PlayEbean)

scalaVersion := "2.11.7"

libraryDependencies ++= Seq(
javaCore,
javaJdbc,
cache,
javaWs,
evolutions
)


fork in run := true

plugins.sbt:
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.10")

// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.6")

// Play enhancer - this automatically generates getters/setters for public fields
// and rewrites accessors of these fields to use the getters/setters. Remove this
// plugin if you prefer not to have this feature, or disable on a per project
// basis using disablePlugins(PlayEnhancer) in your build.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
// enablePlugins(PlayEbean).
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.2")
//("org.avaje.ebeanorm" % "avaje-ebeanorm" % "7.11.4")

Adis Corovic

unread,
Sep 25, 2017, 10:06:59 AM9/25/17
to Play Framework
New version of Ebean is using the model in io.ebean.Model and not play.db.ebean.Model.
Beside that, you ar using a wrong annotation? @ID instead of @Id

I have this in my plugins.sbt:


addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "4.0.2")

klmbear

unread,
Sep 25, 2017, 10:19:14 AM9/25/17
to Play Framework
k, I changed it like you said still get errors:
Error:(3, 16) java: package io.ebean does not exist

Error:(4, 25) java: package javax.persistence does not exist
Error:(5, 25) java: package javax.persistence does not exist
Error:(8, 30) java: cannot find symbol
  symbol: class Model
Error:(7, 2) java: cannot find symbol
  symbol: class Entity
Error:(9, 6) java: cannot find symbol
  symbol:   class Id
  location: class models.Account

plugins.sbt:
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.10")

// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.6")

// Play enhancer - this automatically generates getters/setters for public fields
// and rewrites accessors of these fields to use the getters/setters. Remove this
// plugin if you prefer not to have this feature, or disable on a per project
// basis using disablePlugins(PlayEnhancer) in your build.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
// enablePlugins(PlayEbean).
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "4.0.2")

//("org.avaje.ebeanorm" % "avaje-ebeanorm" % "7.11.4")


test:
package models;
import com.sun.javafx.beans.IDProperty;
import io.ebean.Model;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Account extends Model {
    @Id

klmbear

unread,
Sep 25, 2017, 4:31:04 PM9/25/17
to Play Framework
GOT IT!!!!

I have done many searches and tried everything I have found nothing works, and I tried all kind of recommendations, downloaded a sample (play 2.5 ebean sample from playframework website) got it to work!
matched all configuration parms to my program, still did not work, then finally found this post:

it talked about the files in the .idea directory, so I tried coping the ebean files over from the one that worked since none were in my .idea directory, it did not work.  So finally copy replace my whole .idea directory with the one from the sample and THAT WORKED!!!

GIVE ME SPEGETTI CODE ANY DAY, OVER SPEGETTI CONFIGURATION!
Reply all
Reply to author
Forward
0 new messages