seesee
seesee

Reputation: 1155

Hibernate Annotation - Adult and jointable (parent Child)

I have 2 tables..

Adult
-------------------
id

ParentChild
-------------------
parentID(adult's id)
childID(adult's id)

When I try to annotate them.. I keep getting NoClassDefFoundError

public class Adult

private id

private Set<Adult> children

.
.
.

@ManyToMany(fetch = FetchType.Lazy)
@JoinTable(name= "ParentChild",
joinColumns=@JoinColumn(name="id",referencedColumnName="parentID")
inverseJoinColumn=@JoinColumn(name=childID,referencedColumnName="id")
public Set<Adult> getChildren() {
.
.
}

public class ParentChild{
.
.
.
.
private String parentID
private String childID

}

I know the above codes are a bit messy but I'm stuck in a place with only an internet 1 access terminal and the rest are development PC that can't be attached to internet.

I hope some kind soul can help me up. I am quite sure the exception is cause by the @ManyToMany statement as when I comment it off.. it will cause error.

is there anything I can download to trap the exception at HibernateUtil? The exception seems to be unrelated.

Gratitude from the mountain :(

Upvotes: 0

Views: 187

Answers (1)

seesee
seesee

Reputation: 1155

Dear developers and brothers.

If you hit NoClassDefFoundError exception during runtime, STOP LOOKING AT YOUR HIBERNATE ANNOTATIONS OR CODES.

This exception is related to class path issues.

1) Unable to find class during run time 2) Duplicated jar.

Basically for me, I had a ejb3-persistence.jar, 2 javax persistence.jar in my classpath.

everything works after i remove the javax persistence.jar from the build path in eclipse

go project>properties>java build path>Libraries

and configure your build path properly. This should solve the error.

Hope it help another developer stuck in the mountain.

Upvotes: 1

Related Questions