tags:

views:

1151

answers:

1

By default, grails seems to return <class name>:<id> for toString() of an Java domain object. That's not at all what I want of course, so I tried to @Override the toString() to return what I want. When I tried grails generate-all Tagtype, I got the following error:

java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a differen
t type with name "org/w3c/dom/NamedNodeMap"

My code is below. Any help would be greatly appreciated.

@Entity
@Table(name = "tagtype", catalog = "tigger")
@SuppressWarnings("serial")
public class Tagtype implements Serializable {

    /**
     * Attribute id.
     */
    private Integer id;

    /**
     * Attribute tagtype.
     */
    private String tagtype;

    /**
     * Attribute regexpression
     */
     private Regexpression regexpression; 

 . . .  

  @Override public String toString() {
    StringBuilder result = new StringBuilder();

    result.append(this.tagtype);

    return result.toString();
  }

}
+1  A: 

I've overriden toString() in Grails domain classes without any problems, so that can't be the reason. This blog suggests it could be a result of name collisions, either temporary (have you tried running "grails clean"?) or perhaps your class name Tagtype collides with some grails internals.

Another thing you could try is using different versions of Grails, especially the latest 1.1.1 if you aren't already using that. This ML post describes an identical error message that was apparently version dependant.

Michael Borgwardt
Thanks for your reply. Just to make sure my question is clear, I'm trying to override toString in a JAVA class, NOT a Grails class.I am using 1.1.1 and I did do grails clean.
Brad Rhoads
Since there's less "magic" happening in Java classes, there should be even less potential for problems. According to the article I linked to, it could be a collision between JARs required by a grails plugin and your own project
Michael Borgwardt
Brad Rhoads