2013-04-12 14 views
2

在部署到tomcat後,我在axis2 Web服務中獲得以下內容。EclipseLink - 在元模型中找不到關鍵類[CurriculumTree]的[EntityType]

java.lang.IllegalArgumentException: No [EntityType] was found for the key class [VOs.CurriculumTree] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific <class>VOs.CurriculumTree</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element. 

當我從eclipse運行時,JPA正常工作。我已經在persistence.xml中定義的實體,像這樣:

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> 
    <persistence-unit name="NewAge-Test" transaction-type="RESOURCE_LOCAL"> 
     <class>VOs.CurriculumTree</class> 
     <properties> 
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/contentserver_development"/> 
      <property name="javax.persistence.jdbc.user" value="root"/> 
      <property name="javax.persistence.jdbc.password" value="quadfusion"/> 
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> 
     </properties> 
    </persistence-unit> 
</persistence> 

這裏是我的實體類:

@Entity 
@Table(name="curriculum_trees") 
public class CurriculumTree implements NodeInfo, Serializable { 
    private static final long serialVersionUID = 1L; 

    @Id 
    @GeneratedValue(strategy=GenerationType.IDENTITY) 
    private int id; 

    @LevelColumn 
    @Column(name="depth",updatable=false) 
    private int level; 

    @Lob 
    private String description; 

    @LeftColumn 
    @Column(updatable=false) 
    private int lft; 

    private String name; 

    @Column(name="node_type") 
    private String nodeType; 

    @Column(name="parent_id") 
    private int parentId; 

    private int position; 

    private boolean prassoTopicGroup; 

    @RightColumn 
    @Column(updatable=false) 
    private int rgt; 

    @RootColumn 
    private int rootId; 

    public CurriculumTree() { 
    } 

    public int getId() { 
     return this.id; 
    } 

    public void setId(int id) { 
     this.id = id; 
    } 

    public String getDescription() { 
     return this.description; 
    } 

    public void setDescription(String description) { 
     this.description = description; 
    } 

    public int getLft() { 
     return this.lft; 
    } 

    public void setLft(int lft) { 
     this.lft = lft; 
    } 

    public String getName() { 
     return this.name; 
    } 

    public void setName(String name) { 
     this.name = name; 
    } 

    public String getNodeType() { 
     return this.nodeType; 
    } 

    public void setNodeType(String nodeType) { 
     this.nodeType = nodeType; 
    } 

    public int getParentId() { 
     return this.parentId; 
    } 

    public void setParentId(int parentId) { 
     this.parentId = parentId; 
    } 

    public int getPosition() { 
     return this.position; 
    } 

    public void setPosition(int position) { 
     this.position = position; 
    } 

    public boolean getPrassoTopicGroup() { 
     return this.prassoTopicGroup; 
    } 

    public void setPrassoTopicGroup(boolean prassoTopicGroup) { 
     this.prassoTopicGroup = prassoTopicGroup; 
    } 

    public int getRgt() { 
     return this.rgt; 
    } 

    public void setRgt(int rgt) { 
     this.rgt = rgt; 
    } 

    @Override 
    public int getLeftValue() { 
     return getLft(); 
    } 

    @Override 
    public int getRightValue() { 
     return getRgt(); 
    } 

    @Override 
    public int getLevel() { 
     return this.level; 
    } 

    @Override 
    public int getRootValue() { 
     return 0; 
    } 

    @Override 
    public void setLeftValue(int value) { 
     setLft(value); 
    } 

    @Override 
    public void setRightValue(int value) { 
     setRgt(value); 
    } 

    @Override 
    public void setLevel(int level) { 
     this.level = level; 
    } 

    @Override 
    public void setRootValue(int value) { 
     // TODO Auto-generated method stub 
    } 

    @Override public String toString() { 
     return "[Curriculum Node: id=" + this.id + ", name=" + this.name + "-" + super.toString() + "]"; 
    } 

} 

我想這是包括在persistence.xml標籤<exclude-unlisted-classes>false</exclude-unlisted-classes>替代,但它沒」沒有任何好處。

回答

0

刪除提及<class>com.hm.newAge.VOs.CurriculumTree</class>

,並把財產<exclude-unlisted-classes>false</exclude-unlisted-classes>

+0

我試過了。我仍然遇到同樣的錯誤。 – jaykumarark

+0

你有與數據庫中的CurriculumTree實體對應的表嗎? – javadev

+0

當然存在表格。因爲代碼在從eclipse運行時工作。它在作爲服務部署在tomcat上時不起作用。 – jaykumarark

0

錯誤報告VOs.CurriculumTree但在你的持久XML有com.hm.newAge.VOs.CurriculumTree有一個包的問題。

+0

不是我的錯,從cmd提示符處複製錯誤時我沒有輸入完整的包名稱 – jaykumarark

0

如果您未使用託管持久性單元,請嘗試在使用後關閉實體管理器工廠。

+0

我可以知道爲什麼要關閉EMF?它不是一個輕量級的過程來關閉EMF以及如何完成?請添加解釋。 – Lucky

相關問題