easility / Play2Plugin

Playorm plugin for Play2.1
0 stars 0 forks source link

Lost annotations on playframework restart #12

Closed hsn10 closed 11 years ago

hsn10 commented 11 years ago

If you restart play framework (its done automatically after edit in dev mode) then components are not rescanned for annotations.

put operation fails with:

[IllegalArgumentException: Entity type=models.Token was not scanned and added to meta information on startup. It is either missing @NoSqlEntity annotation or it was not in list of scanned packages]

nrelbuilder commented 11 years ago

There is a rescan method on NoSqlEntityManagerFactory that we used in play 1.2.x so we wired into their application reload function so that this is called and reloads the annotations. In play 1.2.x, play scanned the classes :( which I never really liked. To rescan though, we need the new classloader, not the old one so somehow play 2.x would have to pass the classloader and rescan takes the entities to rescan. In NosqlPlugin.java for 1.2.x the relevant code was

    List<Class> classes = Play.classloader.getAnnotatedClasses(NoSqlEntity.class);
    List<Class> classEmbeddables = Play.classloader.getAnnotatedClasses(NoSqlEmbeddable.class);

to get the the list of classes to pass to the rescan method. Is this possible?