Skip to content

[8.x] Fix enhancing single model classes and packages without classes - #896

Merged
mkurz merged 2 commits into
playframework:8.xfrom
mkurz:fix-model-enhancement-8.x
Oct 8, 2026
Merged

mkurz merged 2 commits into
playframework:8.xfrom
mkurz:fix-model-enhancement-8.x

Conversation

@mkurz

@mkurz mkurz commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Backport of #895 to 8.x.

The sbt plugin passed the configured models (the ebean.* entries, or models.* by default) as they are to Ebean's offline enhancer, which treats every entry as a package directory below the classes directory and throws if that directory doesn't exist. That's the case for:

  • single classes, e.g. ebean.orders = ["models.Order", "models.OrderItem"], as shown in the docs (models/Order is not a directory)
  • packages without compiled classes, e.g. when there are no models yet, or when they come from a dependency

The plugin swallowed that exception. However, the enhancer processes the entries one after the other, so that also silently skipped all following entries: entities stayed unenhanced and the application failed at runtime with a BeanNotEnhancedException.

Now the plugin keeps packages as they are (models.*, or plain package names like models, which can be set via playEbeanModels), turns single classes into their package, and skips entries without compiled classes. If nothing is left, it doesn't call the enhancer at all, since an empty list would make it process all classes. Other enhancement errors are not swallowed anymore, but fail the build.

Testing

New scripted test enhancement-model-entries with ebean.default = [ "missing.*", "models.Task" ] (the missing package comes first, so it must not stop the enhancement of the class):

  • Without this fix it fails with BeanNotEnhancedException: Bean class models.Task is not enhanced? at runtime.
  • New scripted test enhancement-plain-package with Compile / playEbeanModels := Seq("models") checks that models.Task gets enhanced, but an entity in another package doesn't (plain package names must not be taken for classes).
  • With this fix all scripted tests pass, for Scala 2.13 and 3.3.

The sbt plugin passed the configured models as they are to Ebean's
enhancer, which treats every entry as a package directory. So single
classes (e.g. "models.Task", as shown in the docs) and packages without
compiled classes (e.g. not existing yet, or provided by a dependency)
made it throw. The plugin swallowed that error, which also skipped all
following entries, so entities silently stayed unenhanced and the
application failed at runtime.

Now single classes get enhanced via their package and packages without
compiled classes get skipped. Other enhancement errors are not
swallowed anymore.
@mergify

mergify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

playEbeanModels can also contain package names without a ".*" suffix,
e.g. Seq("models"), which Ebean's enhancer handles just like "models.*".
However, the previous commit took them for single classes and enhanced
their parent package instead, which for "models" is the whole classes
directory.

Now only entries that are no package with compiled classes are treated
as single classes.
@mkurz
mkurz merged commit ec7e705 into playframework:8.x Oct 8, 2026
21 checks passed
@mkurz
mkurz deleted the fix-model-enhancement-8.x branch October 8, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant