Type ... is not defined as an entity (@Entity is missing) (error 302)

#1

Hello,

I am using ObjectDB 2.2.8_08 with eclipse 3.6 and Groovy objects.

I am attempting to persist an instance of CultureRqst in the project com.epimss.lab by using a Connection class imported from the project com.epimss.admin.

I can access the database OK, but attempting to persist the CultureRqst leads to the following exceptions:

[ObjectDB 2.2.8_08] javax.jdo.JDOUserException
Type com.epimss.lab.data.bacti.CultureRqst is not defined as an entity (@Entity is missing) (error 302)
at com.objectdb.jdo.PMImpl.makePersistent(PMImpl.java:232)
at javax.jdo.PersistenceManager$makePersistent.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.epimss.admin.db.Connection.store(Connection.groovy:579)
at com.epimss.admin.db.Connection$store.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.epimss.lab.ui.bacti.CultureRqstWizard.performFinish(CultureRqstWizard.groovy:176)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:811)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:430)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at com.epimss.lab.handlers.OpenCultureRqstWizardHandler.execute(OpenCultureRqstWizardHandler.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:47)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:208)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:185)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:101)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:135)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledMenuItemRenderer$1.widgetSelected(HandledMenuItemRenderer.java:150)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:713)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:633)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:106)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:127)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)

 

The CultureRqst is shown below:

package com.epimss.lab.data.bacti

import groovy.beans.Bindable

import javax.inject.Inject

import com.epimss.lab.data.misc.OtherRqst
import com.epimss.lab.data.misc.RequestDateAndNumber;
import com.epimss.lab.data.misc.SpecimenRqst;

import javax.jdo.annotations.PersistenceCapable

@Bindable
@PersistenceCapable
class CultureRqst
{
    // Common
    Boolean candS   = false
    Boolean gramStain            = false
    Boolean fungal               = false
    OtherRqst commonOtherRqsts   = new OtherRqst()
   
   
    // Bacteria (Fastidious)
    Boolean afb                  = false
    Boolean bPertussis           = false
    Boolean hPylori              = false
    OtherRqst bacteriaOtherRqsts = new OtherRqst()
   
   
    // Fungal (Specific)
    Boolean blastomycosis        = false
    Boolean coccidioidomycosis   = false
    Boolean histoplasmosis       = false
    OtherRqst fungalOtherRqsts   = new OtherRqst()
   
   
    // Viral
    Boolean cmv                  = false
    Boolean enterovirus          = false
    Boolean hsv                  = false
    OtherRqst viralOtherRqsts    = new OtherRqst()
   
   
    SpecimenRqst specimenRqst = new SpecimenRqst();
    RequestDateAndNumber requestDateAndNumber = new RequestDateAndNumber()
   
   
}   // end class Culture

 

I am using JDO, NOT JPA.

 

Thanks for any help.

#2

The class definition looks fine (@PersistenceCapable and @Entity are equivalent - but you may try adding also @Entity).

This might be a class loading issue - i.e. PersistenceCapable is available in the classpath more than once and loaded more than once (by different class loaders).

Please verify that all the relevant types for ObjectDB are available only in one Eclipse bundle.

 

 

ObjectDB Support
#3

Hello,

I think you are correct. But how do I overcome this with objectdb. I have to place the objectdb.jar in a libs directory on the root of the eclipse project and then add it to the classpath runtime for each project that I use objectdb in. Now objectdb is tied to its own JDO API by packaging. Hence if I use another JDO jar other problems arise.

 

I am not sure how I can overcome this with 15 projects to use objectdb. I tried placing objectdb as a variable and then all projects refer to this variable but then this does not work.

 

The only solution it seems is to:

1. Package objectdb as an OSGi bundle.

2. Seaparate ObjectDB from the JDO API, thus allowing us to use any JDO API.

 

Although the suggestion might be long term for you, I cannot progress with these issues and objectdb. If you have managed to use it in multiple OSGi (Eclipse) projects, please let me know. I would appreciate it.

 

Thanks

 

#4

Better OSGi support will be added in future versions of ObjectDB.

You may try removing the javax.jdo package from objectdb.jar.

In addition, you may try declaring persistence capable classes using XML instead of using annotations.

ObjectDB Support
#5

I'm having the save error building the helloworld exemple(http://www.objectdb.com/database/jdo/manual/chapter2#Hello_World), i'm using neatbeans 8.1 to build it

Exception in thread "main" [ObjectDB 2.6.4_07] javax.jdo.JDOUserException
Type java.util.ArrayList<java.lang.Object> is not defined as an entity (@Entity is missing) (error 302)
at com.objectdb.Utilities.bind(Utilities.java:205)
at helloworld.HelloWorld.main(HelloWorld.java:26)

#6

You are using an old ObjectDB 1.x example. Please follow the ObjectDB 2.x tutorial.

Starting ObjectDB 2.x first level persisted objects must be of entity types, so a list of strings can only be persisted as part of a containing entity.

ObjectDB Support

Reply