facebook

EJB 3.0 Session Bean Not finding Entity Bean

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #274296 Reply

    Russ
    Member

    I have a simple Enterprise Application with a Web and EJB modules in it. In the Web module I have a servlet that calls an EJB in the EJB Module. While in the Web Module, I create the “detached” Entities for the EJB Module. The EJB Module is using JPA persistence. Next I call a method on the EJB and send the “detached” entities. The first thing the EJB Module does is it queries the database for any existing entities. If one record is not found, the EJB creates a new entity instance. After all the entities are checked, the EJB adds the new objects to the database. The application is running on Glassfish 1.0 and I am using JDK 1.6.0.02 and MyEclipse 6.0GA.

    What is happening is I am getting an error when I attempt to call the Servlet what kicks off the process.

    
    Caused by: Exception [TOPLINK-8006] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.EJBQLException
    Exception Description: A problem was encountered resolving the class name - The descriptor for [file_type] was not found.
    

    The distinction here is the file name is “FileType” while the table name is “file_type”.

    this is my declaration:

    
    @Entity
    @EntityListeners(ejb.bean.listener.MyAuditor.class)
    @NamedQueries({
        @NamedQuery(name="findFileTypeByExtension", 
                    query="SELECT ft FROM file_type ft " +
                          "WHERE :extension=?1"),
        @NamedQuery(name="findFileTypeByDescription", 
                    query="SELECT ft FROM file_type ft " +
                          "WHERE :description=?1")
    })
    @Table(name="FILE_TYPE")
    public class FileType implements Serializable{
    ......
    ......
    }
    

    Any assistance and insight would be greatly appreciated.

    Thank you for taking the time to read my post.

    Russ

    #274306

    Russ
    Member

    Some of my problem is my named query is not constructed properly. Once I corrected this, I was getting a similar error:

    
    @Entity
    @EntityListeners(ejb.bean.listener.MyAuditor.class)
    @NamedQueries({
        @NamedQuery(name="findDataTypeByDescription", 
                   query="SELECT dt FROM DataType dt " +
                            "WHERE dt.description= ?1"),
        @NamedQuery(name="findDataTypeByCode", 
                    query="SELECT dt FROM DateType dt " +
                          "WHERE dt.code=?1")
    })
    @Table(name="DATA_TYPE")
    public class DataType implements Serializable{
     
        private Long datatypeId;
        private Integer code;
        private String description;
        
    

    The error is:

    
    Caused by: Exception [TOPLINK-8006] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.EJBQLException
    Exception Description: A problem was encountered resolving the class name - The descriptor for [DateType] was not found.
    

    Using JPQL is Class and field specific and NOT Database and column specific.

    With this said, it is my opinioin MyEclipse is not packaging the entity/interface classes in the ear file correctly for Java EE 5 type of projects.

    See below article:
    http://weblogs.java.net/blog/ss141213/archive/2005/12/using_java_pers.html

    I hope this helps……..

    Russ

    #274323

    Riyad Kalla
    Member

    Russ is this set of projects something you could export to a single Archive and share with me so I had sometihng concrete to look at? In your first post I immediately noticed that your table/column refernces were wrong, but then as you pointed out you fixed that, and are still getting squirrely behavior.

    Do you have your EJBs annotated correctly as @Remote or @Local?

    #274338

    Russ
    Member

    For the good of the group……….

    EJBQLException means the JPQL Parser is having problems with parsing the query. The key point here to note is JPQL query is NOT parsed until the Entity is loaded in the EJB container. In my case, that happen when I called the entity bean. Lastly, the query is not checked so “DateType” is NOT the same as DataType.

    A key point is the JPQL is Class and field based while SQL is table and attribute based.

    Cheers!

    #274341

    Riyad Kalla
    Member

    I appreciate the clarification… I don’t see how this relates to MyEclipse though. If it were a packaging problem, you would be experiencing much more vanilla errors (ClassNotFound, incompatible APIs, module load errors, etc.)

    What it looks like is that TopLink isn’t parsing the query correctly or some other persistence-magic that is occuring.

    I’ve written the JPA, JPA-Spring and EJB3 tutorials and never run into the issue before where I was getting QL Exceptions… BUT I have absolutely fought my fair share of crapped our deployments on Glassfish 2 with the early nightly builds.

    Out of curiosity, would you be able to download Glassfish 2, build 58: https://glassfish.dev.java.net/downloads/v2-b58.html

    install it, then try and deploy the identical EAR to it, instead of Glassfish 1 and see if the result atleast differs?

    I’ve learned to get atleast two app-servers opinions on JPA issues before I declare something broken in my code… it’s all so new that there are no garuntees.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: EJB 3.0 Session Bean Not finding Entity Bean

You must be logged in to post in the forum log in