Error using JPA: Entity is not a known entity type
<p>I'm getting this this errors when i try to run my java enterprise application, developed using Netbeans 8.1 and GlassFishServer 4</p>

<pre><code>java.lang.IllegalArgumentException: Object: entity.NewTable[ a=7 ] is not a known entity type.
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4222)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:496)
at SessBeanPack.provaBean.persist(provaBean.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy.$Proxy307.persist(Unknown Source)
at SessBeanPack.__EJB31_Generated__provaBean__Intf____Bean__.persist(Unknown Source)
at managedbeans.Neo4jMBean.createUser(Neo4jMBean.java:122)
at managedbeans.UserMBean.createUser(UserMBean.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at javax.el.ELUtil.invokeMethod(ELUtil.java:326)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:536)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
at com.sun.el.parser.AstValue.invoke(AstValue.java:269)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:745)
</code></pre>

<p>This is the code of the Entity NewTable</p>

<pre><code>    package entity;
    import java.io.Serializable;
    import javax.persistence.Basic;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.Table;
    import javax.validation.constraints.NotNull;
    import javax.validation.constraints.Size;
    import javax.xml.bind.annotation.XmlRootElement;
    @Entity
    @Table(name = "new_table")
    @XmlRootElement
    @NamedQueries({
@NamedQuery(name = "NewTable.findAll", query = "SELECT n FROM NewTable n"),
@NamedQuery(name = "NewTable.findByA", query = "SELECT n FROM NewTable n WHERE n.a = :a"),
@NamedQuery(name = "NewTable.findByB", query = "SELECT n FROM NewTable n WHERE n.b = :b")})

public class NewTable implements Serializable {

private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "a")
private Integer a;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 45)
@Column(name = "b")
private String b;

public NewTable() {
}

public NewTable(Integer a) {
    this.a = a;
}

public NewTable(Integer a, String b) {
    this.a = a;
    this.b = b;
}

public Integer getA() {
    return a;
}

public void setA(Integer a) {
    this.a = a;
}

public String getB() {
    return b;
}

public void setB(String b) {
    this.b = b;
}

@Override
public int hashCode() {
    int hash = 0;
    hash += (a != null ? a.hashCode() : 0);
    return hash;
}

@Override
public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof NewTable)) {
        return false;
    }
    NewTable other = (NewTable) object;
    if ((this.a == null &amp;&amp; other.a != null) || (this.a != null &amp;&amp; !this.a.equals(other.a))) {
        return false;
    }
    return true;
}

@Override
public String toString() {
    return "entity.NewTable[ a=" + a + " ]";
}}
</code></pre>

<p>This is the code of the session bean which manages the entity NewTable</p>

<pre><code>    package SessBeanPack;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.ejb.Stateless;
    import javax.ejb.LocalBean;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
    @Stateless
    @LocalBean
    public class provaBean {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("EnterpriseApplication2-ejbPU");
public void persist(Object object) {
    EntityManager em = emf.createEntityManager();
    try {
        em.getTransaction().begin();
        em.persist(object);
        em.getTransaction().commit();
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", e);
        em.getTransaction().rollback();
    } finally {
        em.close();
    }
}}
</code></pre>

<p>I get that sequence of errors when i call the method persist() of the Session Bean provaBean</p>

<pre><code>    NewTable N=new NewTable(7, password);
    provaBean.persist(N);
</code></pre>

<p>I haven't found yet a solution for fixing this problem, because most of the times people suggest to modify the persistence.xml file, because it's not written correctly probably.
My case is different because, as you can see below, the persistence.xml is filled as it should be (the class NewTable is declared as suggested by many users --->  &lt; class > NameOfTheClass &lt; / class > )</p>

<pre><code>&lt;persistence version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
 &lt;persistence-unit name="EnterpriseApplication2-ejbPU" transaction-type="RESOURCE_LOCAL"&gt;
  &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt;&lt;non-jta-data-source&gt;RDBforTes&lt;/non-jta-data-source&gt;
  &lt;class&gt;entity.Autore&lt;/class&gt;
  &lt;class&gt;entity.CanzoneUtente&lt;/class&gt;
  &lt;class&gt;entity.Utente&lt;/class&gt;
  &lt;class&gt;entity.TagCanzone&lt;/class&gt;
  &lt;class&gt;entity.TagAlbum&lt;/class&gt;
  &lt;class&gt;entity.Album&lt;/class&gt;
  &lt;class&gt;entity.TagAutore&lt;/class&gt;
  &lt;class&gt;entity.Tag&lt;/class&gt;
  &lt;class&gt;entity.Canzone&lt;/class&gt;
  &lt;class&gt;entity.NewTable&lt;/class&gt;
  &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
  &lt;properties&gt;
   &lt;property name="javax.persistence.jdbc.url" value="jdbc:mysql://127.0.0.1:3306/tesinatbd"/&gt;
   &lt;property name="javax.persistence.jdbc.password" value="mypassword"/&gt;
   &lt;property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/&gt;
   &lt;property name="javax.persistence.jdbc.user" value="root"/&gt;
  &lt;/properties&gt;
 &lt;/persistence-unit&gt;
&lt;/persistence&gt;    
</code></pre>

<p>I really don't know how to solve this problem; i tried some solutions suggested by users, founded here on stackoverflow, but i haven't found a working one.</p>

<p>So i created a new question, and i hope someone will help me.</p>

<p>Thanks for the answer</p>