2

I get the following in my axis2 web service after deploying into tomcat.

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.

The JPA works fine when I run from eclipse. I have defined the entity in the persistence.xml like so:

<?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>

Here is my entity class:

@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() + "]";
    }

}

I tried the alternate which is including the tag <exclude-unlisted-classes>false</exclude-unlisted-classes> in the persistence.xml but it didn't do any good.

jaykumarark
  • 2,359
  • 6
  • 35
  • 53

3 Answers3

0

Remove the reference to <class>com.hm.newAge.VOs.CurriculumTree</class>

and put the property <exclude-unlisted-classes>false</exclude-unlisted-classes>

javadev
  • 1,639
  • 2
  • 17
  • 35
  • Do you have the table corresponding to the CurriculumTree entity in your database? – javadev Apr 12 '13 at 13:24
  • Of course the table exists. Because the code works when its run from eclipse. It doesn't work when it deployed on tomcat as a service. – jaykumarark Apr 12 '13 at 13:33
  • Ok, be sure your persistence.xml is in your classpath and that you are referring to the right PU name (here for you it is : "NewAge-Test") – javadev Apr 12 '13 at 13:36
  • My persistence.xml file is located in `axis2/WEB-INF/classes/META-INF`. If I hadn't provided the right PU name I would have got an error saying "No Persistent Provider found for NewAge-Test. But that isn't the case. The code can locate the xml but I can't recognize the `` tag in the xml file. – jaykumarark Apr 12 '13 at 13:42
0

The error report VOs.CurriculumTree but in your persistence xml there is com.hm.newAge.VOs.CurriculumTree there is a package issue.

Alepac
  • 1,833
  • 13
  • 24
0

Try to close the entity manager factory after you use if you are not using managed persistence unit.

bob-cac
  • 1,272
  • 2
  • 17
  • 35
  • May I know Why to close the EMF? its not a light weight process to close the EMF and how it can be done? Please add an explanation. – Lucky Sep 02 '15 at 12:21