Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8590241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:15:03+00:00 2026-06-11T23:15:03+00:00

I have a Play! 2 application and some functions that are reused across models.

  • 0

I have a Play! 2 application and some functions that are reused across models. I thought to put them inside the models package object, as in the following example

import java.util.Date

package object models {
  case class RichDate(d: Date) {
    def timestamp: Long = d.getTime / 1000
  }

  implicit def enrich(d: Date): RichDate = new RichDate(d)
}

so that everywhere I have a date field in a model I can write myDate.timestamp.ù

This compiles and even works in unit tests. For some reason, though, when I run the actual application, I get an Execution Exception [NoSuchMethodError: models.package$.enrich(Ljava/util/Date;)Lmodels/package$RichDate;]

Is there a reason why the above should not work in a Play! application, while being valid Scala?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:15:04+00:00Added an answer on June 11, 2026 at 11:15 pm

    I’ve run across this as well and it turned out that the weird behavior was due to package object models already being defined in the framework. This basically makes the package object models off limits to users of the framework. My solution was to put my library pimping in utility objects (such as utils.DateUtils) and just import them when appropriate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a play application and have some models. One of them contains
I have a c#/winforms application that uses directx to play some video and audio.
I have a Play! 2 application (Scala) and there I have some classes that
I have a Play! 2.0.2 application that needs to store some files in the
I have recently launched my application into the Google Play store but unfortunately some
in my application i have the playvideo page where video will play, below that
I have a play application connecting to a database at 1.2.3.4 but for some
I have created iphone application to play some video files. I kept all the
I have an application which now is on google play. Ther developement and testing
I have an application thats main goal is to play a specific video file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.