Grails

Association refers to an unmapped class

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.0-RC3
  • Fix Version/s: 1.0.4
  • Component/s: Persistence
  • Labels:
    None

Description

More and more often I've been getting exceptions from Grails RC2 and RC3 regarding an 'unmapped class'. Doing a grails clean solves the problem, but it would seem something's wrong for it to appear so often.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table customer_note refers to an unmapped class: Customer

I'll add the full stack trace ad an attachment.

Activity

Hide
Ricardo J. Méndez added a comment -

Full exception stack trace.

Show
Ricardo J. Méndez added a comment - Full exception stack trace.
Hide
Graeme Rocher added a comment -

please attach a sample with steps to reproduce

Show
Graeme Rocher added a comment - please attach a sample with steps to reproduce
Hide
Ricardo J. Méndez added a comment -

Haven't gotten this issue in 1.0.1 at all.

Show
Ricardo J. Méndez added a comment - Haven't gotten this issue in 1.0.1 at all.
Hide
Pam added a comment -

Hi, I'm still got this issue and grails clean doesn't fix it. I had to go in manually and delete a bunch of *.class files in the project directory. I think they were something that Eclipse created when I imported the project. I had checked "Disable Groovy compiler generating class files" but sometimes it still does it when I import a project.

Deleting the .class files, and then doing grails clean fixed this for me.

Show
Pam added a comment - Hi, I'm still got this issue and grails clean doesn't fix it. I had to go in manually and delete a bunch of *.class files in the project directory. I think they were something that Eclipse created when I imported the project. I had checked "Disable Groovy compiler generating class files" but sometimes it still does it when I import a project. Deleting the .class files, and then doing grails clean fixed this for me.
Hide
Matthias added a comment -

I just had this same issue with grails-1.0.3-SNAPSHOT.

grails-clean alone did not help; I then did a Project --> clean in Eclipse followed by a grails clean. That did the job. Don't think it's a grails bug; much more one of the myriads of issues related to developing a Grails app using Eclipse... the Eclipse support is really extremely poor.

Show
Matthias added a comment - I just had this same issue with grails-1.0.3-SNAPSHOT. grails-clean alone did not help; I then did a Project --> clean in Eclipse followed by a grails clean. That did the job. Don't think it's a grails bug; much more one of the myriads of issues related to developing a Grails app using Eclipse... the Eclipse support is really extremely poor.
Hide
Alberto Brandolini added a comment -

Same situation, deleting .class files from within Eclipse solved the problem.

I made 2 mistakes before that are maybe related to the root cause:
1) a typo while creating a controller so I had 2 controller classes for the same class, which was the one pointing to the apparently unmapped class
2) i declared in class A an attribute of type B without the 'static belongsTo = A', then I added it, but was too late.

I think it's related to 2) I'll try to isolate the conditions.

Show
Alberto Brandolini added a comment - Same situation, deleting .class files from within Eclipse solved the problem. I made 2 mistakes before that are maybe related to the root cause: 1) a typo while creating a controller so I had 2 controller classes for the same class, which was the one pointing to the apparently unmapped class 2) i declared in class A an attribute of type B without the 'static belongsTo = A', then I added it, but was too late. I think it's related to 2) I'll try to isolate the conditions.
Hide
Matthias added a comment -

This is actually very easy to reproduce: I get this error everytime when I "grails run-app" after I changed something in a domain class and did not do a full clean and package thereafter.

I always have to clean and rebuild everything when changing even the slightest thing in a domain class.

This should be reopened, as it is extremely annoying and time consuming.

Show
Matthias added a comment - This is actually very easy to reproduce: I get this error everytime when I "grails run-app" after I changed something in a domain class and did not do a full clean and package thereafter. I always have to clean and rebuild everything when changing even the slightest thing in a domain class. This should be reopened, as it is extremely annoying and time consuming.
Hide
Graeme Rocher added a comment -

attach an example with steps to reproduce please

Show
Graeme Rocher added a comment - attach an example with steps to reproduce please
Hide
Matthias added a comment -

Well, it happens in any of my domain classes, whenever I modify code there... So the example is:
1) Create domain class
2) start server
3) everything OK
4) stop server
5) modify domain class
6) start server
7) exception occurs (see bug report)
8) grails clean && grails package
9) start server
10) everything works again

I suppose it doesn't happen with your setup, otherwise you had already gone nuts like me
But having to rebuild the entire project after every tiny weeny change in a domain class is... well... not cool.

I'm sorry if I cannot give you better input, I can just say that the problem is there, and I had it from day one (that's roughly six months now).

Show
Matthias added a comment - Well, it happens in any of my domain classes, whenever I modify code there... So the example is: 1) Create domain class 2) start server 3) everything OK 4) stop server 5) modify domain class 6) start server 7) exception occurs (see bug report) 8) grails clean && grails package 9) start server 10) everything works again I suppose it doesn't happen with your setup, otherwise you had already gone nuts like me But having to rebuild the entire project after every tiny weeny change in a domain class is... well... not cool. I'm sorry if I cannot give you better input, I can just say that the problem is there, and I had it from day one (that's roughly six months now).

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: