Brad Rhoads
Brad Rhoads

Reputation: 1846

toString() in Grails Java Domain Class Causes

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();
  }

}

Upvotes: 2

Views: 8104

Answers (1)

Michael Borgwardt
Michael Borgwardt

Reputation: 346317

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.

Upvotes: 1

Related Questions