Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Class reloading issue (rails) #15

Closed
pietia opened this Issue Sep 27, 2011 · 7 comments

Comments

Projects
None yet
2 participants
Collaborator

pietia commented Sep 27, 2011

org.hibernate.MappingException: Unknown entity: org.jruby.RubyObject 
Rails.root: 
app/controllers/users_controller.rb:46:in `create' 
app/controllers/users_controller.rb:45:in `create'

Looks like our hooks are not being fired up for :create

Collaborator

pietia commented Oct 2, 2011

bigger topic....

Owner

mkristian commented Oct 3, 2011

the hooks are OK, if you turn off class_caching then things go wrong. basically on startup dm-rails loads all models and somehow rails reloads them and then they are a different ruby class with the same name, i.e. Hibernate.mapped? return true but the second class did not go through become_java!

this can be improved by using the name + the hash of the class, but then you see
loader (instance of org/jruby/util/JRubyClassLoader): attempted duplicate class definition for name: "rubyobj/User"

since the jruby classloader has already a java class. with become_java!(true) the classloading is solved but now Hibernate complains

Duplicate class/entity mapping rubyobj.User

introducing the web classloader we had before jruby-1.6.4 extended become_java! would solve that problem to the extend that hibernate will see only the first class but any changes which effect the hibernate configuration will not be seen. and it could that this web classloader only worked with me (which happens apparently more often)

Collaborator

pietia commented Oct 3, 2011

That's exactly what i was thinking about yesterday. Maybe we can re-implement your classloader in jruby?

Collaborator

pietia commented Oct 3, 2011

AFAIR torqubox does the same! :)

Owner

mkristian commented Oct 3, 2011

torquebox does implement a classloader ? I can put the class loader in jruby BUT in java in jruby is pain, everything is manual and you have to be sure to delegate all methods and what about method overloading creating java classes in jruby.

Collaborator

pietia commented Oct 3, 2011

i thought torquebox uses custom classloader but after quick chat with Bob, looks like it doesn't. They use become_java!(false)

Collaborator

pietia commented Oct 16, 2011

Closing, we will reopen if needed.

@pietia pietia closed this Oct 16, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment