Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA EclipseLink unknown entity type issue(Unable to identify the entity as the know entity.)
JPA EclipseLink unknown entity type issue [message #704219] Thu, 28 July 2011 07:53 Go to next message
RameshDasari  is currently offline RameshDasari
Messages: 4
Registered: July 2011
Junior Member
Hi,

I am working with spring 3.0.3, JPA 2.0, EclipseLink 2.0 and JBOSS 6.0.

Stack Trace

exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Object: User [id=0, userName=, email=] is not a known entity type.; nested exception is java.lang.IllegalArgumentException: Object: User [id=0, userName=, email=] is not a known entity type.
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
root cause

org.springframework.dao.InvalidDataAccessApiUsageException: Object: User [id=0, userName=, email=] is not a known entity type.; nested exception is java.lang.IllegalArgumentException: Object: User [id=0, userName=, email=] is not a known entity type.
org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:286)
org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:120)
org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
org.springframework.orm.jpa.JpaAccessor.translateIfNecessary(JpaAccessor.java:152)
org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:188)
org.springframework.orm.jpa.JpaTemplate.persist(JpaTemplate.java:262)
com.chrysler.cvp.dao.impl.UserDAOImpl.addUser(UserDAOImpl.java:42)
com.chrysler.cvp.rdu.web.controller.VehicleListController.processMyUserForm(VehicleListController.java:92)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:175)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:421)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:409)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:774)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
root cause

java.lang.IllegalArgumentException: Object: User [id=0, userName=, email=] is not a known entity type.
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4147)
org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:368)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
$Proxy180.persist(Unknown Source)
org.springframework.orm.jpa.JpaTemplate$5.doInJpa(JpaTemplate.java:264)
org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:183)
org.springframework.orm.jpa.JpaTemplate.persist(JpaTemplate.java:262)
com.chrysler.cvp.dao.impl.UserDAOImpl.addUser(UserDAOImpl.java:42)
com.chrysler.cvp.rdu.web.controller.VehicleListController.processMyUserForm(VehicleListController.java:92)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:175)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:421)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:409)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:774)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

Entity class

package com.chrysler.cvp.dao.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="data")
public class User implements Serializable{

private static final long serialVersionUID = 1L;

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

@Column(name="USER_NAME")
private String userName;

@Column(name="EMAIL")
private String email;


public int getId() {
return id;
}

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

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}


@Override
public String toString() {
return "User [id=" + id + ", userName=" + userName + ", email=" + email
+ "]";
}

}

Persistence.xml

<persistence-unit name="Sample" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>java:/MySqlDS</non-jta-data-source>
<class>com.chrysler.cvp.dao.entity.User</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="url" />
<property name="javax.persistence.jdbc.user" value="as" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="eclipselink.dialect"
value="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />

</properties>

</persistence-unit>

</persistence>

pom.xml

<repositories>
<repository>
<id>EclipseLink Repo</id>
<!-- note that ampersands in this URL are escaped because this is in an
xml file - un-escape them to use in browser -->
<url>&amp;nf=1&amp;file=/rt/eclipselink/maven.repo</url>
<!-- use this for javax.persistence <snapshots> <enabled>true</enabled>
</snapshots> -->
</repository>
</repositories>

<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.0.0</version>
</dependency>


Due to conflict problem i am removing the above jar files from my war file. And i kept those two in JBOSS_HOME/server/default/lib.

I am able to hit the database by passing JPA queries through JpaTemplate methods. When i am dealing with entity object i am getting this error. Please help me out.

Regards
Ramesh Dasari
Re: JPA EclipseLink unknown entity type issue [message #704356 is a reply to message #704219] Thu, 28 July 2011 10:30 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Seems to be a class loader issue. You somehow have the same class on the classpath twice (two different class loaders).

Ensure the jar is only loaded through one class loader.


James : Wiki : Book : Blog : Twitter
(no subject) [message #704368 is a reply to message #704219] Thu, 28 July 2011 10:30 Go to previous messageGo to next message
James is currently offline James
Messages: 272
Registered: July 2009
Senior Member
Seems to be a class loader issue. You somehow have the same class on the classpath twice (two different class loaders).

Ensure the jar is only loaded through one class loader.

--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Re: (no subject) [message #704880 is a reply to message #704356] Fri, 29 July 2011 03:02 Go to previous message
RameshDasari  is currently offline RameshDasari
Messages: 4
Registered: July 2011
Junior Member
Hi James,

Thanks for your reply. Some of my jars are there in my war file and in JBOSS lib folder. May be this is causing problem. How can i restrict the execution of JBOSS jars(especially the hibernate-jpa-2.0-api.jar from jboss ) over my jars.

Regards
Ramesh
Previous Topic:Can't find Eclipselink Maven Repository- Error 404
Next Topic:Addtional Foreign Kry
Goto Forum:
  


Current Time: Thu Jul 31 17:40:40 EDT 2014

Powered by FUDForum. Page generated in 0.01622 seconds