Looking for some articles about Play's classloader

391 views
Skip to first unread message

Freewind

unread,
Sep 15, 2011, 3:53:48 AM9/15/11
to play-framework
I'm write a plugin to integrate activejdbc with play. Now, it's
basically OK, but if I modified some model classes and play reloaded
them, there will be a ClassCastException like:

Can't cast "models.User" to "models.User"

In order to fix this mistake, I'm looking for some articles about how
the play's classloader running, but not found.

Is there any articles or documents can help?

GrailsDeveloper

unread,
Sep 15, 2011, 6:06:27 AM9/15/11
to play-framework
I only have this from http://groups.google.com/group/play-framework/browse_thread/thread/a0c371f08a64e004#
Hi,

In short, when a Java application is running, it requires the current
ClassLoader (java.lang.ClassLoader) of the VM to define its classes,
that's to say take some binary data and transform then into Class
objects that can be used. A typical ClassLoader will open .class files
on disk or in archive and make then Class objects. In Play, the
ApplicationClassloader (classloading package) is used to do this job.
Instead of reading .class files, it will have the ApplicationCompiler
(that's where Eclipse's JDT is used) read source files and compile
them, before actually making the Class objects available to the VM.
Controlling the ClassLoading process allows us to do cool stuf like:

- If you run your application in production mode, play will pre-
compile all your application, it almost behaves like a standard app.
But when running in Dev mode, Play will check if for modifications in
your application, recompile and replace/hot swap outdated code
automatically.
- Play will enhance your code, that's to say the framework will do a
part of the coding for you. By example, JPAEnhancer will add count(),
findAll() methods implementation to your model objects.
- You can ask play questions regarding the current Classpath, like get
all subclasses of a given class
(ApplicationClasses.getAssignableClasses()), get ll classes with a
given annotation (ApplicationClasses.getAnnotatedClasses()), are
iterate over the classes of your application cleanly
(ApplicationClasses.all()).

Regards,
Jean-Francois

Niels

nowind_lee

unread,
Sep 15, 2011, 6:43:53 AM9/15/11
to play-framework
Thank you very much, it's helpful. And I hope there is a detail description about the classloader in the offical documents, since many people will have this question if they want to integrate something with play.
 
 
------------------ Original ------------------
From:  "GrailsDeveloper"<openso...@googlemail.com>;
Date:  Thu, Sep 15, 2011 06:06 PM
To:  "play-framework"<play-fr...@googlegroups.com>;
Subject:  [play-framework] Re: Looking for some articles about Play's classloader
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

jsh

unread,
Sep 15, 2011, 8:04:37 AM9/15/11
to play-fr...@googlegroups.com
I had a similar problem in dev mode with a plugin using a class that could be recompiled by Play.
See this thread https://groups.google.com/forum/#!searchin/play-framework/godevin/play-framework/i3OUMjz4EHs/-8_7jTtVEnsJ

Cheers

sas

unread,
Sep 15, 2011, 5:40:06 PM9/15/11
to play-framework
great explanation, Jean Froncois... I hope it can get it's way into
play's documentation

saludos

sas

On 15 sep, 07:06, GrailsDeveloper <opensourc...@googlemail.com> wrote:
> I only have this fromhttp://groups.google.com/group/play-framework/browse_thread/thread/a0...
Reply all
Reply to author
Forward
0 new messages