Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Object: is not a known entity type.(Entity Meta-Data is not recognised ?)
Object: is not a known entity type. [message #728933] Sat, 24 September 2011 12:50 Go to next message
Patrick Philips is currently offline Patrick PhilipsFriend
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: 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 #729703 is a reply to message #728933] Mon, 26 September 2011 19:40 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You seem to be having class loader issues. When running in an OSGi/RCP environment you need to use JPA in a different way.
Look at the OSGi examples,
http://wiki.eclipse.org/EclipseLink/Examples/OSGi

From you code, you class loader seems wrong, the JDBC driver class loader is not going to be able to see your classes.


James : Wiki : Book : Blog : Twitter
Re: Object: is not a known entity type. [message #730044 is a reply to message #729703] Tue, 27 September 2011 14:33 Go to previous messageGo to next message
Patrick Philips is currently offline Patrick PhilipsFriend
Messages: 13
Registered: February 2011
Junior Member
Hi James,
Thanks for your reply.

I thought about the class loader issue as well and actually tried a class loader from within the application which could see the entity classes; this had the same result as before.

Just to shed some more light on this I have a bit more information; 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."

Do you 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.

I also noticed that the entity I have created is not being registered with the metadata repository even though the class is defined in the persistence.xml file and has all the correct annotations .... "Entity" etc. to define it as a persistent entity.

Do you have any ideas as to what I am missing or doing wrong?

Thanks.

Patrick.

Re: Object: is not a known entity type. [message #730535 is a reply to message #730044] Wed, 28 September 2011 15:15 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I do not have much to add with working with OSGI. I believe the message you see in the log is a red-herring and has little to do with metadata-source properties. It is printed when the list of processed entities is empty, a symptom of the same problem causing the "org.persistence.Entity2@2dec3ffd is not a known entity type" later on.

If you are willing to debug, check the values in the PersistenceUnitInfo and see if the classes you listed in your persistence.xml are in the classes list (returned from the getManagedClassNames() method). The classloader is then used to load these classes in the buildClassSet method on PersistenceUnitProcessor or initPersistenceUnitClasses on MetadataProcessor during predeploy's metadata processing. If they are correct, you may want to see PersistenceUnitProcessor.getClassNamesFromURL to see what might be going wrong. If tney are not correct, there is a persistence.xml loading issue and you will want to check that the correct one is being found.

Best Regards,
Chris
Re: Object: is not a known entity type. [message #746987 is a reply to message #728933] Sun, 23 October 2011 21:16 Go to previous messageGo to next message
Klaus Meisl is currently offline Klaus MeislFriend
Messages: 90
Registered: July 2009
Member
any news on this one? i'm having exactly the same problem...

[Updated on: Sun, 23 October 2011 21:17]

Report message to a moderator

Re: Object: is not a known entity type. [message #757594 is a reply to message #746987] Sun, 20 November 2011 00:13 Go to previous messageGo to next message
Patrick Philips is currently offline Patrick PhilipsFriend
Messages: 13
Registered: February 2011
Junior Member
Klaus I just sent a reply but I'm not sure that it was delivered properly as the forum connection went down. Just in case you didn't receive it here again is my solution to your question :

I finally got things sorted out and it was partly associated with the class loader but also to do with some "quirks" of EclipseLink.
I am showing what I had to do below so that no-one else has to suffer the extreme frustration I have, which took me 2 weeks to solve.

Note: this applies to using EclipseLink in an RCP development project. I am using the Apache Derby Embedded data base and I cannot verify that what I describe below will be applicable to other data bases (although I suspect it is!).

1. In the persistence.xml file remove the reference for the Persistence Provider. (I know all on-line examples have this ... but mine would not work with it in!).

2. In the java file that creates the data base in the import section ensure you have the following imports:

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.persistence.jpa.osgi.PersistenceProvider;
import emdd.Activator;

3. Ensure that you DO NOT have the following imports:

import org.eclipse.persistence.jpa.osgi.*;
import org.eclipse.persistence.jpa.PersistenceProvider;

Many of the on-line examples you will come across will tell you to have these imports. DO NOT use them they seem to cause a conflict in the class loading which is not reported and which seems to stop the loading of the classes defined in the managed classes for the persistence unit defined, either in the persistence.xml file or programatically. This was the main source of my problems.

4. You seem to need to have an application Activator class and to set this as the class loader before creating the data base entity manager i.e.

String PERSISTENCE_UNIT_NAME = "myPersistenceUnit";

ClassLoader cL = Activator.class.getClassLoader();
properties.put(PersistenceUnitProperties.CLASSLOADER, cL);
properties.put(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_UNITS, PERSISTENCE_UNIT_NAME);

//create the data base ...
emFactory = new PersistenceProvider().createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
em = emFactory.createEntityManager();

So ensure your RCP project has an Activator class. I tried using the Application class (amongst others !) and it didn't work; I don't fully understand why and at this point I haven't the time to spend digging through the Eclipse code to find out.

At this point you should be able to create and use a data base entity manager to persist and retrieve data.
I have put this up here so hopefully anyone facing the same problems I did will have an easier time. Anyone reading this who has a web-site or blog for these types of problems please feel free to post it so that anyone suffering the same issues can hopefully find a solution.
Re: Object: is not a known entity type. [message #758006 is a reply to message #746987] Sun, 20 November 2011 00:13 Go to previous messageGo to next message
Patrick Philips is currently offline Patrick PhilipsFriend
Messages: 13
Registered: February 2011
Junior Member
Klaus I just sent a reply but I'm not sure that it was delivered properly as the forum connection went down. Just in case you didn't receive it here again is my solution to your question :

I finally got things sorted out and it was partly associated with the class loader but also to do with some "quirks" of EclipseLink.
I am showing what I had to do below so that no-one else has to suffer the extreme frustration I have, which took me 2 weeks to solve.

Note: this applies to using EclipseLink in an RCP development project. I am using the Apache Derby Embedded data base and I cannot verify that what I describe below will be applicable to other data bases (although I suspect it is!).

1. In the persistence.xml file remove the reference for the Persistence Provider. (I know all on-line examples have this ... but mine would not work with it in!).

2. In the java file that creates the data base in the import section ensure you have the following imports:

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.persistence.jpa.osgi.PersistenceProvider;
import emdd.Activator;

3. Ensure that you DO NOT have the following imports:

import org.eclipse.persistence.jpa.osgi.*;
import org.eclipse.persistence.jpa.PersistenceProvider;

Many of the on-line examples you will come across will tell you to have these imports. DO NOT use them they seem to cause a conflict in the class loading which is not reported and which seems to stop the loading of the classes defined in the managed classes for the persistence unit defined, either in the persistence.xml file or programatically. This was the main source of my problems.

4. You seem to need to have an application Activator class and to set this as the class loader before creating the data base entity manager i.e.

String PERSISTENCE_UNIT_NAME = "myPersistenceUnit";

ClassLoader cL = Activator.class.getClassLoader();
properties.put(PersistenceUnitProperties.CLASSLOADER, cL);
properties.put(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_UNITS, PERSISTENCE_UNIT_NAME);

//create the data base ...
emFactory = new PersistenceProvider().createEntityManagerFactory(PERSISTENCE_UNIT_NAME, properties);
em = emFactory.createEntityManager();

So ensure your RCP project has an Activator class. I tried using the Application class (amongst others !) and it didn't work; I don't fully understand why and at this point I haven't the time to spend digging through the Eclipse code to find out.

At this point you should be able to create and use a data base entity manager to persist and retrieve data.
I have put this up here so hopefully anyone facing the same problems I did will have an easier time. Anyone reading this who has a web-site or blog for these types of problems please feel free to post it so that anyone suffering the same issues can hopefully find a solution.
Re: Object: is not a known entity type. [message #1061544 is a reply to message #728933] Sun, 02 June 2013 16:54 Go to previous message
Rodrigo Soares de Almeida is currently offline Rodrigo Soares de AlmeidaFriend
Messages: 1
Registered: June 2013
Junior Member
Hello i'm not so good in English, but, i will try to help you.

This error is happening because you need to paste inside folder
"..\..\apache-tomcat-7.0.40\webapps\axis2\WEB-INF\classes" the the folder "...\bin\*.class" of eclipse project. So the error will be fixed.

Att
Rodrigo Almeida from Brazil.
Previous Topic:Unidirectional OneToMany Insert
Next Topic:Cascade Remove problem
Goto Forum:
  


Current Time: Thu Apr 18 02:14:13 GMT 2024

Powered by FUDForum. Page generated in 0.02087 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top