EJBQLException, Entity Class, NetBeansv6, TopLink

Hello I'm new to java and having difficulty with Persistence EntityManager, within persistence.xml I've unselected the 'Include all entity classes' and added the entity class "ImageSpec" to the list provided, and the Entity Class is on the same class path but I still have the following exception. I've researched orm.xml but that looks like it's for deployment scinario's? and not required for development? Any help would be greatly appreciated thank you.
Exception
Caused by: Exception [TOPLINK-8034] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EJBQLException
Exception Description: Error compiling the query [select object(o) from Images o]. Unknown abstract schema type [Images].
        at oracle.toplink.essentials.exceptions.EJBQLException.unknownAbstractSchemaType(EJBQLException.java:494)
Entity Class
package org.comp.app.ds.ajax;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.json.JSONArray;
@Entity
@Table(name="Images")
public class ImageSpec implements Serializable {
  private Long imgId;
  private String imgDescription;
  private Long imgFileSize;    
  private String imgFilePath;
  private String imgFileType;
  public ImageSpec() { }
  public JSONArray toJSON() {
     JSONArray thisJSON = new JSONArray();
     thisJSON.put(this.getImgId());
     thisJSON.put(this.getImgDescription());
     thisJSON.put(this.getImgFileSize());
     thisJSON.put(this.getImgFilePath());
     thisJSON.put(this.getImgFileType());
     return thisJSON;
  @Id
  public Long getImgId() {
    return imgId;
  public String getImgDescription() {
    return imgDescription;
  public Long getImgFileSize() {
    return imgFileSize;
  public String getImgFilePath() {
    return imgFilePath;
  public String getImgFileType() {
    return imgFileType;
  public void setImgId(Long imgId) {
    this.imgId = imgId;
  public void setImgDescription(String imgDescription) {
    this.imgDescription = imgDescription;
  public void setImgFileSize(Long imgFileSize) {
    this.imgFileSize = imgFileSize;
  public void setImgFilePath(String imgFilePath) {
    this.imgFilePath = imgFilePath;
  public void setImgFileType(String imgFileType) {
    this.imgFileType = imgFileType;
persistence.xml
<persistence-unit name="AppPU" transaction-type="JTA">
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    <jta-data-source>jdbc/appDB</jta-data-source>
    <class>org.comp.app.ds.ajax.ImageSpec</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
    </properties>
  </persistence-unit>

By finding a resource on EJB QL, my Query syntax was wrong. Here's an explanation for anybody with the same problem.
SQL Query Example
SELECT * FROM TableName
EJB QL Example
SELECT OBJECT(i) FROM ImageSpec i
OBJECT = * (+Select All+)
i = A made up identifying character (Rule of thumb: use the first character of Entity Class Name)
ImageSpec = The Entity Class Name (+Not the Database Column Name+)
See the link URL below for more information:
http://edocs.bea.com/workshop/docs81/doc/en/core/index.html
Edited by: Jodda on Feb 22, 2008 7:41 AM - Marked as answered.

Similar Messages

  • Exception Description: Entity class [] has no primary key....

    Received the following error in jdeveloper - some info on how to fix would be greatly appreciated
    [EclipseLink/JPA Client] Adding Java options: -javaagent:C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.toplink_11.1.1\eclipselink.jar
    C:\Oracle\MiddlewareNew\jdk160_05\bin\javaw.exe -client -classpath C:\JDeveloper\mywork\APP_CM_AUTONUM_GEN\.adf;C:\JDeveloper\mywork\APP_CM_AUTONUM_GEN\SAM_CM_AUTONUM_GEN\classes;C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.toplink_11.1.1\toplink.jar;C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.toplink_11.1.1\antlr.jar;C:\oracle\MiddlewareNew\modules\com.bea.core.antlr.runtime_2.7.7.jar;C:\oracle\MiddlewareNew\modules\javax.persistence_1.0.0.0_1-0.jar;C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.toplink_11.1.1\eclipselink.jar;C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.xdk_11.1.1\xmlparserv2.jar;C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.xdk_11.1.1\xml.jar;C:\oracle\MiddlewareNew\modules\javax.jsf_1.2.0.0.jar;C:\oracle\MiddlewareNew\modules\javax.ejb_3.0.1.jar;C:\oracle\MiddlewareNew\modules\javax.enterprise.deploy_1.2.jar;C:\oracle\MiddlewareNew\modules\javax.interceptor_1.0.jar;C:\oracle\MiddlewareNew\modules\javax.jms_1.1.1.jar;C:\oracle\MiddlewareNew\modules\javax.jsp_1.1.0.0_2-1.jar;C:\oracle\MiddlewareNew\modules\javax.jws_2.0.jar;C:\oracle\MiddlewareNew\modules\javax.activation_1.1.0.0_1-1.jar;C:\oracle\MiddlewareNew\modules\javax.mail_1.1.0.0_1-1.jar;C:\oracle\MiddlewareNew\modules\javax.xml.soap_1.3.1.0.jar;C:\oracle\MiddlewareNew\modules\javax.xml.rpc_1.2.1.jar;C:\oracle\MiddlewareNew\modules\javax.xml.ws_2.1.1.jar;C:\oracle\MiddlewareNew\modules\javax.management.j2ee_1.0.jar;C:\oracle\MiddlewareNew\modules\javax.resource_1.5.1.jar;C:\oracle\MiddlewareNew\modules\javax.servlet_1.0.0.0_2-5.jar;C:\oracle\MiddlewareNew\modules\javax.transaction_1.0.0.0_1-1.jar;C:\oracle\MiddlewareNew\modules\javax.xml.stream_1.1.1.0.jar;C:\oracle\MiddlewareNew\modules\javax.security.jacc_1.0.0.0_1-1.jar;C:\oracle\MiddlewareNew\modules\javax.xml.registry_1.0.0.0_1-0.jar;C:\oracle\MiddlewareNew\wlserver_10.3\server\lib\weblogic.jar -javaagent:C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.toplink_11.1.1\eclipselink.jar SAM.CMAUTONUMGENClient
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
         at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializerAgent.initializeFromAgent(JavaSECMPInitializerAgent.java:45)
         at org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializerAgent.premain(JavaSECMPInitializerAgent.java:38)
         ... 6 more
    Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.EntityManagerSetupException
    Exception Description: Predeployment of PersistenceUnit [SAM_CM_AUTONUM_GEN] failed.
    Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.ValidationException
    Exception Description: Entity class [class oracle.SamCmAutonumGen] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then please make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
         at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:870)
         at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:101)
         at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.initPersistenceUnits(JPAInitializer.java:149)
         at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.initialize(JPAInitializer.java:135)
         at org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializer.initializeFromAgent(JavaSECMPInitializer.java:145)
         ... 12 more
    Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.EntityManagerSetupException
    Exception Description: Predeployment of PersistenceUnit [SAM_CM_AUTONUM_GEN] failed.
    Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.ValidationException
    Exception Description: Entity class [class oracle.SamCmAutonumGen] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then please make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
         at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210)
         ... 17 more
    Caused by: Exception [EclipseLink-7161] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.ValidationException
    Exception Description: Entity class [class oracle.SamCmAutonumGen] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then please make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
         at org.eclipse.persistence.exceptions.ValidationException.noPrimaryKeyAnnotationsFound(ValidationException.java:1245)
         at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.validatePrimaryKey(EntityAccessor.java:1173)
         at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:486)
         at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:443)
    FATAL ERROR in native method: processing of -javaagent failed
         at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:303)
         at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:830)
         ... 16 more
    Exception in thread "main" Process exited with exit code 1.

    Hi,
    you may want to try the J2EE forum here on OTN in case you don't get a sufficient answer to the problem.
    Frank

  • Updating the structure of an Entity class

    Hi,
    I'm a newbie to JPA, trying to learn it by writing my own application. I have defined an entity class with 3 fields, and I've used it to create and populate my database.
    Now I wish to add a 4th (optional) field to the original class, but I do not want to lose the data I've already saved in the database. Is there a way of doing this, or a setting somewhere, that will get toplink to do this for me, instead of me having to manually "alter" the database table?
    thanks

    There is currently no support within TopLink to track versions of your entity classes or compare the existing with the expected schema to be able to alter the database. You will need to do this manually or use a database tool that supports this. I believe Oracle's JDeveloper and SQL Developer both support incremental schema changes.
    Doug

  • Abstract Entity classes with Collections

    I trying to figure out a way to have a generics collection in a parent collection that can hold various entity types of the same super-class.
    One thing I've tried was the following:
    @Entity
    public class ParentEnt implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;
        @Column
        private String parentName;
        @OneToMany(mappedBy="parentEnt")
        private Collection<ChildAbs> children;
        /* Methods removed */
    @Entity
    public abstract class ChildAbs implements java.io.Serializable {
        protected static final long serialVersionUID = 1L;
        @Id
        protected Long id;
        @ManyToOne
        protected ParentEnt parentEnt;
        /* Methods removed */
    @Entity
    public class ChildEnt extends ChildAbs implements Serializable {
        @Column
        protected String childName;
    }but this is the error I get:
    Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
    Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@11b86e7
    Internal Exception: javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
    Exception Description: predeploy for PersistenceUnit [testPU] failed.
    Internal Exception: Exception [TOPLINK-7250] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: [class test.ParentEnt] uses a non-entity [class test.ChildAbs] as target entity in the relationship attribute [private java.util.Collection test.ParentEnt.children].So, it looks like there is no way to have a generics collection for an abstract entity class. Is there another way to accomplish what I want using a generics collection?
    Additionally, entity ChildEnt generates an error due to the abstract class' id property not carrying forward (see Abstract Entities: http://java.sun.com/javaee/5/docs/tutorial/doc/bnbqa.html#bnbqo)
    Exception Description: Entity class [class testprintservices.ChildEnt] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass.Any input would be appreciated.

    As far as my first question, I was trying to make my collection so it can hold various type of entity classes, but now that I think about it, it was a bad idea. For instance, being able to hold ChildEnt and ChildEnt2 in the same collection. If JPA did allow this, it might be possible to save the entities to the DB, but the reverse wouldn't be possible.
    Ok, regarding my 2nd question: I don't understand why having it as @Entity wouldn't. The links (mine and yours) clearly shows that @Id is carried forward in the example they provide. Anyway, since I can't use the superclass in the collection, this is pointless. I'll use the suggested annotation.
    Thanks.

  • Paint() method in an entity class

    Hi,
    I am trying to draw 2 shapes in a Canvas, one rectangle and a circle.
    However, I have an entity class for both the rectangle and the circle, something like:
    public class MyRectangle
    private int width, height;
    public MyRectangle() { ... }
    pulbic getWidth() { return width; }
    pulbic getHeight() { return Height; }
    I do not want to draw these 2 shape in the paint() method of the Canvas, I want my Rectangle class and my Circle to have their own paint method to draw themselves into the canvas, is it possible?
    If it is possible, can you tell me roughly how to do it?
    Do I have to extend the Component class?
    Thanks in advance.
    SK

    Hi,
    I tried to do what you mentioned as the following, but I cant get the circle display on the screen, do you know why? Thanks
    public class Ball extends Component
    private static final int diameter = 15;
    private int xPosition = 10, yPosition = 10;
    public Ball()
    public int getX() { return xPosition; }
    public int getY() { return yPosition; }
    public int getDiameter() { return diameter; }
    public void paint(Graphics g)
         super.paint(g);
    Graphics2D graphics2D = (Graphics2D)g;
    graphics2D.fillOval(xPosition, yPosition, diameter, diameter);
    public class MyFrame extends JFrame
    public MyFrame()
    // Set up the main frame
    super("Test");
    setPreferredSize(new Dimension(400, 300));
    Container contentPane = getContentPane();
         Ball aBall = new Ball();
         JPanel myPanel = new JPanel();
         myPanel.setBackground(Color.white);
         myPanel.setBorder(BorderFactory.createLineBorder(Color.black));
         myPanel.setOpaque(true);
    myPanel.add(aBall);
         contentPane.add(myPanel, BorderLayout.CENTER);     
    pack();
    /** The main method */
    public static void main(String[] args)
         MyFrame myFrame = new MyFrame();
    myFrame.setVisible(true);
    }

  • Howto find entity-classes in my application?

    I need to get hold of all entity-classes in my application. For now, I only use annotations(@Entity) but I may change to write XML-mapping files. :)
    Does some have a clue how I should get hold of my entities?

    What do you mean by "get hold of"?
    Wouldn't it be sufficient to grep your source code for "@entity" ?

  • Adf bc jar for base entity classes and extending them existing  project

    Hi,
    I am using jdev 11.1.1.0 and have created a base workspace/project and adf jar for my base entity classes.
    1. I can consume this base adf bc jar in a separate new consuming workspace and create VO based on base bc classes or create new EOs that extend base bc entity classes.
    2. Furthermore, for an existing consuming project that earlier included src/ of base entity (BC components), i can remove the dependency on bc source and bring in this new adf jar and everything including the view controller and the service/datacontrol works fine.
    The issue i am running into is as follows.
    - In the existing project (#2) above i try to create a couple of entities based on entities in my base jar; associations are automatically brought in. Note i am not overriding any attributes. My intent here is to generate .java and implement some code.
    - I then try to make my existing VOs based on the newly extended entity (VO overview->Entity Objects-> Shuttle NewEntity from Available to Selected)
    - I then try to remove the old EO from selected under VO overview->Entity Objects->Shuttle OldEntity from Selected back
    - I get a warning dialog box that says something to the effect that some viewlinks are dependent on these old EOs in this consuming project.
    - I tried to laboriously analyzed dependencies and it this dialog box does not make any sense as I have already extended EOs and the tooling should be able to let me use these
    My questions
    - Why I am not able to remove old entities from VO dependencies
    - Is it ok to leave the old EOs in "Selected" along with the newly extended EO ? What are the implications for this?
    - I also thought about extending base associations, but did not go anywhere.
    In general, I am ok with consuming an ADF BC jar that has entities etc. but not clear about removing dependencies of base EOs on VOs when entities are extended and consumed in a pre-existing project that used base entities.
    I can send a project if any PM is willing to take a look at it.
    Thanks,
    ps:
    I have already gone over the following info
    http://technology.amis.nl/blog/215/organization-of-bc4j-domain-eo-and-business-vo-package
    .. wants to create an enterprise data model in BC4J, reflecting the Enterprise Data Model set up in the RDBMS. All (or at least most) business rules will be implemented in the Middle Tier – to take the load of the database and also allow developers not comfortable with PL/SQL to define and maintain the business rules. It is clear that this means that all applications that need to access – and manipulate – the database, need to go through the BC4J foundation layer. Martijn wants to define the Entity Objects – and their business rules – only once and share that definition between different projects. Each projects can create its own ViewObjects on top of these shared Enterprise Entity Objects.
    http://radio-weblogs.com/0118231/2005/09/29.html
    I am currently working on a project for a partner where we will be using ADF BC as our model layer for a large application. In order to keep the footprint of each application module down to a reasonable size, we are intending to create a number of separate 'root' application modules for each functional area of the application. Within, these 'root' application modules we will then use nested application modules to further partition the application. All of the application modules will be accessing the same datasource and will need access to the same database objects.
    In order to separate our code between the development team and into function areas, our initial thoughts were that we would create an ADF BC model project containing Entity Objects for all of the database tables e.t.c. as these are common amongst all functional areas. We have configured all of the EOs for validation rules, defaulting values and extending doDML() as appropriate. Happy at this stage we then created a simple .jar file to deploy all of the definitions. Upon creating a new ADF BC project for each functional area we added the jar file as a library import into the new project. However when we the tried to create some new View Objects via the JDev Wizard we were unable to see the imported Entity Objects.
    Is the only way to share Entity Object definitions between different ADF BC projects to manually copy the source definition files into the new projects src directory? Since this would mean multiple copies of the same components, it could prove to be a maintenance nightmare.Is there a way of doing it without creating multiple copies of the same object definitions?
    The developer is spot on in their ideas of layering and reuse, and even has created a library for their reusable entities. This last step is not something everyone thinks to do. The missing step is known as "importing" components, so with that one extra bit of knowledge under his belt, he should be able to do exactly what he envisions. My little article called Difference Between Adding and Importing Business Components tries to explain the difference and gives the menu options to choose to perform the importing.
    Difference between adding and importing BC4J
    http://radio-weblogs.com/0118231/stories/2005/08/11/differenceBetweenAddingAndImportingBusinessComponents.html
    Working with Libraries of Reusable Business Components
    http://download.oracle.com/docs/cd/B32110_01/web.1013/b25947/bcadvgen.htm#CHEFECGD

    Hi,
    since you followed the OC4J developer guide I think this question might be better handled there as well
    OC4J
    So in case you don't get an answer here on the forum, try it on the OC4J forum
    Frank

  • How can you add autonumber feature in an entity class?

    Hi guys!
    Can you pls help me with this problem, I'm new to java EE. I've got an entity class and I want to implement an auto number feature using the following code:
    { *{color:#ff0000}private static final long serialVersionUID = 1L;*
    *{color}* *{color:#ff0000}@Id*
    * @GeneratedValue(strategy=GenerationType.AUTO)*
    *{color}* @Basic(optional = false)
    @Column(name = "CUST_ID")
    private Long custId;
    But this doesn't work, it gives me the following error: "java.sql.SQLSyntaxErrorException: Table/View 'SEQUENCE' does not exist.". Can you also briefly explain to me how the database will accept this with configuration(if it will accept).

    GenerationType.AUTO:
    Indicates that the persistence provider should pick an appropriate strategy for the particular database. The AUTO generation strategy may expect a database resource to exist, or it may attempt to create one. A vendor may provide documentation on how to create such resources in the event that it does not support schema generation or cannot create the schema resource at runtime.
    http://java.sun.com/javaee/5/docs/api/
    I use Hibernate as a provider and Oracle as ad DB and had to create a seuence called HIBERNATE_SEQUENCE
    m

  • ToString() and Comparable T on a JAXB generated entity class

    Hello,
    I'm trying to create a distributed system and therefore I have all my entity classes present in my Java EE app and hosted as a web service. The Swing frontend app autogenerate the entity classes for use in the presentation.
    I'm having some trouble using the Collections.sort() since a generated entity cannot implement an interface, does anyone have a hint to how i can solve this issue?
    Also, I need to override the toString() so that I can put an entity directly in a eg. JCombobox and it is presented with the return of my custom toString() but if I override the toString() in my original entity in my backend app, then this method is not generated in my frontend app.
    Thanks in advance!
    Nicklas

    Hello,
    I'm trying to create a distributed system and therefore I have all my entity classes present in my Java EE app and hosted as a web service. The Swing frontend app autogenerate the entity classes for use in the presentation.
    I'm having some trouble using the Collections.sort() since a generated entity cannot implement an interface, does anyone have a hint to how i can solve this issue?
    Also, I need to override the toString() so that I can put an entity directly in a eg. JCombobox and it is presented with the return of my custom toString() but if I override the toString() in my original entity in my backend app, then this method is not generated in my frontend app.
    Thanks in advance!
    Nicklas

  • JSF Pages from entity class

    I am new to NB5.5. However, when I create a 'web application' project then I get the option to create 'JSF Pages from entity class' in the persistence category but not while creating a 'visual web application' project. Is there a way of getting this option in visual web applications?
    Regards
    Rajeev

    Hi, may I know what you mean by Visual Web Application?
    Creating JSF Pages from Entity Classes is just a way to increase the speed of developing a web application (a database must already be existing, connected to netbeans for you to use this option).

  • Class could not be loaded or is not an entity class

    Hello,
    I am using Berkeley DB JE 3.3.75 in a web application. I have a class which extends a Persistent class.
    @Entity
    public class XMessageInMemoryAdapter extends XMessage implements Serializable {
    private static final long serialVersionUID = 1L;
    @SecondaryKey(relate=Relationship.MANY_TO_ONE)
    private int objectStatus;
    @Persistent
    public class XMessage extends YMessage implements Serializable {
    private static final long serialVersionUID = 1L;
    @SecondaryKey(relate=Relationship.MANY_TO_ONE)
    private String serviceVariant;
    @Persistent
    public abstract class YMessage implements Serializable {
    private static final long serialVersionUID = 42L;
    @PrimaryKey
    private String messageGroupId;
    But when I try to query the PrimaryKey, an IllegalArgumentException is thrown:
    java.lang.IllegalArgumentException: Class could not be loaded or is not an entity class: com.mycompany.common.model.XMessageInMemoryAdapter
    at com.sleepycat.persist.impl.Store.checkEntityClass(Store.java:1175)
    at com.sleepycat.persist.impl.Store.getPrimaryIndex(Store.java:313)
    at com.sleepycat.persist.EntityStore.getPrimaryIndex(EntityStore.java:257)
    at com.mycompany.common.memorydb.impl.StoreRefImpl.queryPrimaryIndex(StoreRefImpl.java:49)
    at com.mycompany.common.memorydb.dao.MessageDao.init(MessageDao.java:67)
    And here is the MessageDao ve StoreRefImpl ( I deleted irrelevant parts )
    public class MessageDao {
         protected void init() {
              primaryKey = this.store.queryPrimaryIndex(String.class, XMessageInMemoryAdapter.class);
    public class StoreRefImpl {
         public PK queryPrimaryIndex(Class<?> indexClass, Class<?> objectClass) {
              try {
                   PrimaryIndex index = this.store.getPrimaryIndex(indexClass, objectClass); // this is where the exception is thrown
                   return new PKImpl(index);
              } catch (DatabaseException e) {
                   throw new DBException(e);
    Everything working nice in my local machine but when we deploy the application on test server we keep getting this exception.
    Thank you for your help.

    Hi Yusuf,
    This sounds like a classpath problem on your test server. This exception will occur if the class cannot be loaded.
    Please make sure that the je-3.3.75.jar file and your app classes or jar are in the same classpath location, and that there are not multiple copies in different locations. For example, if you're deploying a servlet, be sure to place the JE jar and your app jar in the same lib directory.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Is there some caching of entity classes?

    We are analyzing a bug in our application which seems to be caused by some kind of jpa entity class cache in weblogic (or some other feature causing indirectly the same thing).
    The bug can't be reproduced every time, but it is happening very often after following steps:
    - Deploy application from Eclipse with OEPE in mode "Virtual application"
    - Use Redeploy or Clean feature of OEPE several times
    We are doing some jpa queries during initialization of our application and after several redeploys assigning of resulting entities of those queries triggers class cast exception. I have captured some diagnostics that confirmed that class of jpa query result entity has different classloader than current web app classloader. How is it possible and how can we clear that kind of cache that's causing this during redeploy? I'm not writing to OEPE forum because I think it uses standard facilities of Weblogic where this should never ever be possible regardles of what tool is using it. My diagnostic logs are:
    Expected class classloader: weblogic.utils.classloaders.ChangeAwareClassLoader@6ef4e946 finder: weblogic.utils.classloaders.CodeGenClassFinder@2e1a3d11 annotation: xxx
    Expected class source location (notice that this path is same in both cases): file:/C:/Users/.../FeblApplicationSettingsTuple.class
    Expected class protection domain: ProtectionDomain (file:/C:/Users/.../FeblApplicationSettingsTuple.class <no signer certificates>)
    weblogic.utils.classloaders.ChangeAwareClassLoader@6ef4e946 finder: weblogic.utils.classloaders.CodeGenClassFinder@2e1a3d11 annotation: xxx
    <no principals>
    java.security.Permissions@4ce3316a (
    ("java.net.SocketPermission" "localhost:1024-" "listen,resolve")
    ("java.lang.RuntimePermission" "stopThread")
    ("java.util.PropertyPermission" "line.separator" "read")
    ("java.util.PropertyPermission" "java.vm.version" "read")
    ("java.util.PropertyPermission" "java.vm.specification.version" "read")
    ("java.util.PropertyPermission" "java.vm.specification.vendor" "read")
    ("java.util.PropertyPermission" "java.vendor.url" "read")
    ("java.util.PropertyPermission" "java.vm.name" "read")
    ("java.util.PropertyPermission" "os.name" "read")
    ("java.util.PropertyPermission" "java.vm.vendor" "read")
    ("java.util.PropertyPermission" "path.separator" "read")
    ("java.util.PropertyPermission" "java.specification.name" "read")
    ("java.util.PropertyPermission" "os.version" "read")
    ("java.util.PropertyPermission" "os.arch" "read")
    ("java.util.PropertyPermission" "java.class.version" "read")
    ("java.util.PropertyPermission" "java.version" "read")
    ("java.util.PropertyPermission" "file.separator" "read")
    ("java.util.PropertyPermission" "java.vendor" "read")
    ("java.util.PropertyPermission" "java.vm.specification.name" "read")
    ("java.util.PropertyPermission" "java.specification.version" "read")
    ("java.util.PropertyPermission" "java.specification.vendor" "read")
    Actual class classloader: weblogic.utils.classloaders.ChangeAwareClassLoader@1b5f0c6 finder: weblogic.utils.classloaders.CodeGenClassFinder@20094d55 annotation: xxx
    Actual class source location: file:/C:/Users/.../FeblApplicationSettingsTuple.class
    Actual class protection domain: ProtectionDomain (file:/C:/Users/...n/FeblApplicationSettingsTuple.class <no signer certificates>)
    weblogic.utils.classloaders.ChangeAwareClassLoader@1b5f0c6 finder: weblogic.utils.classloaders.CodeGenClassFinder@20094d55 annotation: xxx
    <no principals>
    java.security.Permissions@57c14d95 (
    ("java.net.SocketPermission" "localhost:1024-" "listen,resolve")
    ("java.lang.RuntimePermission" "stopThread")
    ("java.util.PropertyPermission" "line.separator" "read")
    ("java.util.PropertyPermission" "java.vm.version" "read")
    ("java.util.PropertyPermission" "java.vm.specification.version" "read")
    ("java.util.PropertyPermission" "java.vm.specification.vendor" "read")
    ("java.util.PropertyPermission" "java.vendor.url" "read")
    ("java.util.PropertyPermission" "java.vm.name" "read")
    ("java.util.PropertyPermission" "os.name" "read")
    ("java.util.PropertyPermission" "java.vm.vendor" "read")
    ("java.util.PropertyPermission" "path.separator" "read")
    ("java.util.PropertyPermission" "java.specification.name" "read")
    ("java.util.PropertyPermission" "os.version" "read")
    ("java.util.PropertyPermission" "os.arch" "read")
    ("java.util.PropertyPermission" "java.class.version" "read")
    ("java.util.PropertyPermission" "java.version" "read")
    ("java.util.PropertyPermission" "file.separator" "read")
    ("java.util.PropertyPermission" "java.vendor" "read")
    ("java.util.PropertyPermission" "java.vm.specification.name" "read")
    ("java.util.PropertyPermission" "java.specification.version" "read")
    ("java.util.PropertyPermission" "java.specification.vendor" "read")
    )

    Hello,
    Can you post the code that runs into the exception, the exception itself, as well as how you are obtaining your EntityManager and EntityManagerFactory (if applicable)? If you are managing EntityManagerFactories in the application instead of allowing the container to manage them for you via injection, then you must also ensure that the application will close them when undeployed or some point before redeployment occurs. Otherwise, a similar error might occur dependent if garbage collection does not complete before the application next attempts to retrieve a factory.
    Best Regards,
    Chris

  • Field that is not persistent in Entity class

    Hi all,
    I have entity class "Author" it has OneToMany relationship with "Article" Entity.
    I want to create nbArticles in Author class, just is Long variable to get number of Articles created by this Author. That field is not persist just calculated from query, how can i define new field in Entity class without JPA manages persistance over it? Thanks.
    PD: sorry for my English, im from South America
    Best regards,

    Thanks a lot.
    Best regards,

  • Problem creating executing entity class program

    i am getting the following error if i try the tutorial which creates an entity class, servlet
    http://www.netbeans.org/kb/60/javaee/ejb30.html
    i have followed each and every step given in the same sequence also. kindly help me out.
    HTTP Status 500 -
    type Exception report
    message
    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: PWC1391: Servlet.init() for servlet ListNews threw exception
    root cause
    java.lang.RuntimeException: WEB5002: Exception in handleBeforeEvent.
    root cause
    com.sun.enterprise.InjectionException: Exception attempting to inject Resolved Ejb-Ref web.ListNews/newsEntityFacade@jndi: - > NewsEntityFacade into class web.ListNews
    root cause
    javax.naming.NameNotFoundException: No object bound to name java:comp/env/web.ListNews/newsEntityFacade
    note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1_02 logs.
    Sun Java System Application Server 9.1_02

    If you're wondering why you've had no response, it's because your question has precisely nothing to do with the topic of this forum.
    Locking this thread.

  • Tools for generating Entity Classes

    Hi ,
    I am new to EJB 3.0 Entity Beans .
    I am finding it hard to develop a Entity Class .
    Please let me know if there are there any Tools that will generate an ENtity class depending upon the database table ??

    Hi!
    Most IDEs like Netbeans and Eclipse can generate entities based on existing database schemas, but imho it's much more usefull to write the first few entities by yourself. It's a bit more difficult, but at least this way you will learn what each annotation does, where they can be placed and what attributes you can set on them.
    Once you have a good general foundation you can skip this process by autogenerating these classes. But that's just my opinion.
    Some examples:
    Eclipse
    Netbeans
    Btw. there are no entity beans in EJB 3.0. These are plain old java classes, thus they are called simply entities to avoid confusion with the entity beans used in previous ejb versions.

Maybe you are looking for