3

what is ExecutionException: Boxed Error? also is it possible to make this more readable or specific? PLease see below for the codes.

Useful note : After I added yrBuilt, everything goes wrong!

Error displayed are :

java.util.concurrent.ExecutionException: Boxed Error
    at scala.concurrent.impl.Promise$.resolver(Promise.scala:52) ~[scala-library.jar:na]
    at scala.concurrent.impl.Promise$.scala$concurrent$impl$Promise$$resolveTry(Promise.scala:44) ~[scala-library.jar:na]
    at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:116) ~[scala-library.jar:na]
    at scala.concurrent.Promise$class.complete(Promise.scala:55) ~[scala-library.jar:na]
    at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:58) ~[scala-library.jar:na]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:23) [scala-library.jar:na]
Caused by: java.lang.Error: could not parse form
    at controllers.SnoopController$$anonfun$11.apply(SnoopController.scala:187) ~[classes/:na]
    at controllers.SnoopController$$anonfun$11.apply(SnoopController.scala:186) ~[classes/:na]
    at play.api.data.Form$$anonfun$fold$2.apply(Form.scala:134) ~[play_2.10-2.1.1.jar:2.1.1]
    at scala.Option.getOrElse(Option.scala:120) [scala-library.jar:na]
    at play.api.data.Form.fold(Form.scala:134) ~[play_2.10-2.1.1.jar:2.1.1]
    at controllers.SnoopController$.getPropertyFromRequest(SnoopController.scala:185) ~[classes/:na]

Codes : in View part

<div class="inputGroup">
<div class="efInput">
<label for="year_built">Year Built:</label>
<input type="text" id="lotsize" name="year_built" value="@property.yrBuilt">
</div>
</div>

Controller Part :

    def getPropertyFromRequest(implicit request: Request[AnyContent]): (Property, Option[ObjectId], Option[ObjectId]) = {
        val p =
          Form(tuple(
            "desc" -> text,
            "url" -> text,
            "image" -> text,
            "price" -> text,
            "sqft" -> text,
            "address2" -> text,
            "lotsize" -> text,
            "taxes" -> text,
            "status" -> optional(text),
            "maint" -> text,
            "address" -> text,
            "mls" -> text,
            "baths" -> text,
            "beds" -> text,
            "partial_baths" -> text,
            "propertyId" -> optional(text),
            "snoopId" -> optional(text),
            "yrBuilt" -> text
          )).bindFromRequest().fold(
              errors => {Logger.error(errors.toString())
                throw new Error("could not parse form")},
              success => success
          )

          val a = GeoCoder.create(p._11 + " " + p._6)
          val property = Property(url = p._2,
            description = p._1,
            image = p._3,
            price = parseAmount(p._4).toDouble,
            sqft = p._5,
            lotSize = p._7,
            taxes = parseAmount(p._8),
            status = PropertyStatus.ACTIVE,
            maintenance = parseAmount(p._10),
            mls = p._12,
            baths = try{p._13.toDouble}catch{case e => 0},
            beds = try{p._14.toInt}catch{case e=> 0},
            partialBaths = try{p._15.toDouble}catch{case e => 0},
            address = a,
            yrBuilt = p._18)

          (property,p._16.map(new ObjectId(_)),p._17.map(new ObjectId(_)))
      }

Model Part :

case class Property(
  id: ObjectId = new ObjectId,
  parentId: Option[ObjectId] = None,
  url: String,
  price: Double,
  parentPrice: Option[Double] = None,
  beds: Int,
  baths: Double,
  partialBaths: Double = 0.0,
  address: Address,
  mls: String,
  sqft: String,
  lotSize: String,
  taxes: Int,
  maintenance: Int,
  description: String,
  image: String,
  status: PropertyStatus.Value = PropertyStatus.ACTIVE,
  updated: Date = new Date(),
  priceHistory: List[PriceChange] = Nil,
  failedSnoops: Int = 0,
  yrBuilt: String
) {
  def monthlyFees: Double = {
    val t = try { taxes / 12 } catch { case e: Exception => 0 }
    val m = try { maintenance / 12 } catch { case e: Exception => 0 }
    t + m
  }

  def diff(that: Property): List[(String,Any,Any)] = {
    var changes: List[(String,Any,Any)] = Nil
    if (this.url != that.url) changes = ("url", this.url, that.url) :: changes
    if (this.price != that.price) changes = ("price", this.price, that.price) :: changes
    if (this.beds != that.beds) changes = ("beds", this.beds, that.beds) :: changes
    if (this.baths != that.baths) changes = ("baths", this.baths, that.baths) :: changes
    if (this.partialBaths != that.partialBaths) changes = ("partialBaths", this.partialBaths, that.partialBaths) :: changes
    if (this.address != that.address) changes = ("address", this.address, that.address) :: changes
    if (this.mls != that.mls) changes = ("mls", this.mls, that.mls) :: changes
    if (this.sqft != that.sqft) changes = ("sqft", this.sqft, that.sqft) :: changes
    if (this.lotSize != that.lotSize) changes = ("lotSize", this.lotSize, that.lotSize) :: changes
    if (this.taxes != that.taxes) changes = ("taxes", this.taxes, that.taxes) :: changes
    if (this.maintenance != that.maintenance) changes = ("maintenance", this.maintenance, that.maintenance) :: changes
    if (this.description != that.description) changes = ("description", this.description, that.description) :: changes
    if (this.yrBuilt != that.yrBuilt) changes = ("yrBuilt", this.yrBuilt, that.yrBuilt) :: changes
    changes
  }
}
1
  • Post some code of yours Commented Mar 14, 2014 at 13:40

1 Answer 1

1

It looks like it is struggling to parse your form, and the reason could be that it can't find the yrBuild field. You've over-ridden the default id/name for the field. Try:

<input type="text" id="yrBuilt" name="yrBuilt" value="@property.yrBuilt">

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @wwkudu, by the way is it possible to make the error more specific?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.