Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Object: is not a known entity type.
Object: is not a known entity type. [message #728937] Sat, 24 September 2011 08:50 Go to next message
Patrick Philips is currently offline Patrick Philips
Messages: 13
Registered: February 2011
Junior Member
Hi everyone,

I have a real problem where my entity to persist is not recognised. I have been banging my head against for several days now, and any help would be very much appreciated.

Eclipse Platform: Indigo Version: 3.7.0.v20110530

I have incorporated EclipseLink 2.3.0 JPA into my RCP project and am using the Apache Derby data base to persist data. No problems with installation and setting up data base in Eclipse. However when I try to persist data to the data base I get the following errors: (sorry for the long trace ... didn't want to leave out anything that was relevant!).

[EL Finest]: 2011-09-24 07:34:59.778--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--Begin predeploying Persistence Unit JPA1PU; session bundleresource://4.fwk511811991:1_JPA1PU; state Initial; factoryCount 0
[EL Finest]: 2011-09-24 07:34:59.809--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=eclipselink.orm.throw.exceptions; default value=true
[EL Finest]: 2011-09-24 07:34:59.809--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=eclipselink.multitenant.tenants-share-cache; default value=false
[EL Finest]: 2011-09-24 07:34:59.825--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=eclipselink.metadata-source; default value=null
[EL Finest]: 2011-09-24 07:34:59.825--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=eclipselink.jpa.uppercase-column-names; default value=false
[EL Finer]: 2011-09-24 07:34:59.825--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--Searching for default mapping file in bundleresource://4.fwk511811991:1
[EL Finer]: 2011-09-24 07:34:59.842--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--Searching for default mapping file in bundleresource://4.fwk511811991:1
[EL Finest]: 2011-09-24 07:34:59.888--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--End predeploying Persistence Unit JPA1PU; session bundleresource://4.fwk511811991:1_JPA1PU; state Predeployed; factoryCount 0
[EL Finer]: 2011-09-24 07:34:59.888--Thread(Thread[AWT-EventQueue-0,6,main])--JavaSECMPInitializer - transformer is null.
[EL Finest]: 2011-09-24 07:34:59.888--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--Begin predeploying Persistence Unit JPA1PU; session bundleresource://4.fwk511811991:1_JPA1PU; state Predeployed; factoryCount 0
[EL Finest]: 2011-09-24 07:34:59.888--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--End predeploying Persistence Unit JPA1PU; session bundleresource://4.fwk511811991:1_JPA1PU; state Predeployed; factoryCount 1
[EL Finest]: 2011-09-24 07:35:00.934--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--Begin deploying Persistence Unit JPA1PU; session bundleresource://4.fwk511811991:1_JPA1PU; state Predeployed; factoryCount 1
[EL Finer]: 2011-09-24 07:35:00.934--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--Could not initialize Validation Factory. Encountered following exception: java.lang.NoClassDefFoundError: javax/validation/Validation
[EL Finest]: 2011-09-24 07:35:00.934--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=eclipselink.logging.level; value=FINEST; translated value=FINEST
[EL Finest]: 2011-09-24 07:35:00.949--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=eclipselink.logging.level; value=FINEST; translated value=FINEST
[EL Finest]: 2011-09-24 07:35:00.949--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=javax.persistence.jdbc.user; value=Patrick
[EL Finest]: 2011-09-24 07:35:00.949--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=javax.persistence.jdbc.password; value=xxxxxx
[EL Finest]: 2011-09-24 07:35:23.211--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=eclipselink.target-database; value=Derby; translated value=org.eclipse.persistence.platform.database.DerbyPlatform
[EL Finest]: 2011-09-24 07:35:23.227--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=javax.persistence.jdbc.driver; value=org.apache.derby.jdbc.EmbeddedDriver
[EL Finest]: 2011-09-24 07:35:23.227--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--property=javax.persistence.jdbc.url; value=jdbc:derby:/Users/Patrick/MyDB;create=true
[EL Info]: 2011-09-24 07:35:23.227--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
[EL Config]: 2011-09-24 07:35:23.227--ServerSession(1136315517)--Connection(1700797952)--Thread(Thread[AWT-EventQueue-0,6,main])--connecting(DatabaseLogin(
platform=>DerbyPlatform
user name=> "Patrick"
datasource URL=> "jdbc:derby:/Users/Patrick/MyDB;create=true"
))
[EL Finer]: 2011-09-24 07:35:23.665--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--DriverManager connect failed, trying direct connect.
[EL Finer]: 2011-09-24 07:35:23.665--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--java.sql.SQLException: No suitable driver found for jdbc:derby:/Users/Patrick/MyDB;create=true
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:330)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:293)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:418)
at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:216)
at org.eclipse.persistence.sessions.server.ConnectionPool.startUp(ConnectionPool.java:504)
at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:484)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:630)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:208)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:472)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getMetamodel(EntityManagerFactoryDelegate.java:591)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getMetamodel(EntityManagerFactoryImpl.java:502)
at emdd.test.JPATest.init(JPATest.java:59)
at emdd.test.WBTestAddPanel$4.mouseClicked(WBTestAddPanel.java:86)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
at java.awt.Component.processMouseEvent(Component.java:6270)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6032)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4247)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

[EL Config]: 2011-09-24 07:35:24.117--ServerSession(1136315517)--Connection(534738380)--Thread(Thread[AWT-EventQueue-0,6,main])--Connected: jdbc:derby:/Users/Patrick/MyDB
User: Patrick
Database: Apache Derby Version: 10.8.1.2 - (1095077)
Driver: Apache Derby Embedded JDBC Driver Version: 10.8.1.2 - (1095077)
[EL Finest]: 2011-09-24 07:35:24.117--ServerSession(1136315517)--Connection(534738380)--Thread(Thread[AWT-EventQueue-0,6,main])--Connection acquired from connection pool [default].
[EL Finest]: 2011-09-24 07:35:24.133--ServerSession(1136315517)--Connection(534738380)--Thread(Thread[AWT-EventQueue-0,6,main])--Connection released to connection pool [default].
[EL Info]: 2011-09-24 07:35:24.133--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--bundleresource://4.fwk511811991:1_JPA1PU login successful
[EL Warning]: 2011-09-24 07:35:24.164--Thread(Thread[AWT-EventQueue-0,6,main])--The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element
[EL Finer]: 2011-09-24 07:35:24.164--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element
[EL Finest]: 2011-09-24 07:35:24.164--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--End deploying Persistence Unit JPA1PU; session bundleresource://4.fwk511811991:1_JPA1PU; state Deployed; factoryCount 1
MetaModel: MetamodelImpl@11975273 [ 0 Types: , 0 ManagedTypes: , 0 EntityTypes: , 0 MappedSuperclassTypes: , 0 EmbeddableTypes: ]
[EL Finer]: 2011-09-24 07:36:40.495--ServerSession(1136315517)--Thread(Thread[AWT-EventQueue-0,6,main])--client acquired: 592489859
[EL Finer]: 2011-09-24 07:36:40.511--ClientSession(592489859)--Thread(Thread[AWT-EventQueue-0,6,main])--acquire unit of work: 2018338552
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Object: mailto:org.persistence.Entity2@2dec3ffd is not a known entity type.
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4158)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:440)
at emdd.test.JPATest.init(JPATest.java:73)
at emdd.test.WBTestAddPanel$4.mouseClicked(WBTestAddPanel.java:86)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
at java.awt.Component.processMouseEvent(Component.java:6270)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6032)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4247)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

My persistence.xml file is:
<?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="JPA1PU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.persistence.Entity2</class>
<class>org.persistence.Entity1</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="eclipselink.target-database" value="Derby"/>
<property name="javax.persistence.jdbc.user" value="Patrick"/>
<property name="eclipselink.logging.level" value="FINEST"/>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:/Users/Patrick/MyDB;create=true"/>
<property name="javax.persistence.jdbc.password" value="xxxxxx"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
</properties>

</persistence-unit>
</persistence>

which includes references to the <class> elements and <exclude-unlisted-classes>false</exclude-unlisted-classes> so I don't see the problem in the persistence.xml file.

The test code I am using to exercise the connection and persist some test data is:
public ClassLoader getJPAClassLoader() {
//return this.getClass().getClassLoader();
return org.apache.derby.jdbc.EmbeddedDriver.class.getClassLoader();
}

public void init(){
HashMap properties = new HashMap();
ClassLoader cL = getJPAClassLoader();
properties.put(PersistenceUnitProperties.CLASSLOADER, cL);



emFactory = new org.eclipse.persistence.jpa.PersistenceProvider().createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
System.out.println("MetaModel: " + emFactory.getMetamodel());
em = emFactory.createEntityManager();

em.getTransaction().begin();
Entity1 ent1 = new Entity1();
Entity2 ent2 = new org.persistence.Entity2();

ent1.setADDRESS("My Address1");
ent2.setAddress("My Addresss2");
ent1.setSTREET("My Street1");
em.persist(ent2);
em.persist(ent1);
em.getTransaction().commit();

em.close();

}

My entity file Entity2 is as follows:

package org.persistence;

import java.io.Serializable;
import java.lang.String;
import javax.persistence.*;

/**
* Entity implementation class for Entity: Entity2
*
*/
@Entity

public class Entity2 implements Serializable {


@Id
private long Id;
private String Address;
private static final long serialVersionUID = 1L;

public Entity2() {
super();
}
public long getId() {
return this.Id;
}

public void setId(long Id) {
this.Id = Id;
}
public String getAddress() {
return this.Address;
}

public void setAddress(String Address) {
this.Address = Address;
}

}

Any help would really be appreciated as I have exhausted my web-site search options hoping to find an answer to this one.

Thanks in advance.

Patrick.
Re: Object: is not a known entity type. [message #729232 is a reply to message #728937] Sun, 25 September 2011 10:23 Go to previous message
Patrick Philips is currently offline Patrick Philips
Messages: 13
Registered: February 2011
Junior Member
I have a bit more information for anyone out there who reads this and might be able to help; after stepping through every line of Eclipse code I finally got to "org.eclipse.persistence.internal.jpa.entityManagerSetupImpl" in here it checks for the value of eclipselink.metadata-source. This value is null, which is returned up the calling stack and eventually I get the log message ...

-The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element

This seems to be the problem as there is no entity in the list and hence the error message "Object: org.persistence.Entity1@1644cd9a is not a known entity type."

Does anyone know what I should setting the eclipselink.metadata-source value to?
I have pulled numerous articles off the net and nothing tells me explicitly what I should be pointing this to in order to register my entities.

One other thing ... this is an RCP application and is not running in the EE container, so many of the inherant services of the container are not available.

Thanks for any help anyone can offer.

Patrick.
Re: Object: is not a known entity type. [message #729235 is a reply to message #728937] Sun, 25 September 2011 10:23 Go to previous message
Patrick Philips is currently offline Patrick Philips
Messages: 13
Registered: February 2011
Junior Member
I have a bit more information for anyone out there who reads this and might be able to help; after stepping through every line of Eclipse code I finally got to "org.eclipse.persistence.internal.jpa.entityManagerSetupImpl" in here it checks for the value of eclipselink.metadata-source. This value is null, which is returned up the calling stack and eventually I get the log message ...

-The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element

This seems to be the problem as there is no entity in the list and hence the error message "Object: mailto:org.persistence.Entity1@1644cd9a is not a known entity type."

Does anyone know what I should setting the eclipselink.metadata-source value to?
I have pulled numerous articles off the net and nothing tells me explicitly what I should be pointing this to in order to register my entities.

One other thing ... this is an RCP application and is not running in the EE container, so many of the inherant services of the container are not available.

Thanks for any help anyone can offer.

Patrick.
Previous Topic:EclipseLink and Log4j
Next Topic:Sybase Connection logs in as guest in case of Connection communication failure
Goto Forum:
  


Current Time: Wed Jul 30 23:26:00 EDT 2014

Powered by FUDForum. Page generated in 0.10358 seconds