0

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 :(

4

1 回答 1

1

亲爱的开发者和兄弟们。

如果您在运行时遇到 NoClassDefFoundError 异常,请停止查看您的 HIBERNATE 注释或代码。

此异常与类路径问题有关。

1) 在运行时找不到类 2) 重复的 jar。

基本上对我来说,我的类路径中有一个 ejb3-persistence.jar, 2 javax persistence.jar。

从 Eclipse 的构建路径中删除 javax persistence.jar 后一切正常

转到项目>属性>java构建路径>库

并正确配置您的构建路径。这应该可以解决错误。

希望它可以帮助另一个陷入困境的开发人员。

于 2012-04-24T11:14:23.877 回答