views:

370

answers:

1

In Weblogic 10.3, the JAR containing the EJB below along with the persistence file, is deployed. But Weblogic deploys it as Type "Library" instead of an "EJB", which is not what I want.

package com.sajee;
import javax.persistence.*;

@Entity
@Table(name="REGISTRAR")

public class Registrar implements java.io.Serializable
{
    private int courseId, registered;
    public Registrar ( ) { }

    @Id
    @Column(name="courseId")
    public int getCourseId( ) { return courseId; }
    public void setCourseId(int pk) { courseId = pk; }

    @Column(name="number_students_registered")
    public int getRegistered( ) { return registered; }
    public void setRegistered(int reg) {registered = reg; }

}

<persistence>
<persistence-unit name="SRS" transaction-type="JTA">
    <jta-data-source>myDataSource</jta-data-source> 
    <non-jta-data-source>myDataSource</non-jta-data-source> 
    <properties>
     <property name="openjpa.jdbc.DBDictionary" value="derby" /> 
    </properties>
 </persistence-unit>
</persistence>

Any ideas on what I'm doing wrong? How would I troubleshoot this?

+1  A: 

The above class is not really an EJB, no EJB annotation or descriptor. It's different from an Entity Bean in EJB 2.x.

You could have a stateless EJB to manage the JPA entity with the stateless annotation or the XML descriptor.

anonymous
I was under the assumption that the annotations were sufficient. What more do I need to add to the class above to make it a EJB 3 entity bean?
Sajee
There's no equivalent to Entity Beans of EJB 2.X in EJB 3. If you want to have an EJB, you can create a stateless bean to manage the JPA entity as I said previously, using the @Stateless annotation, it would act like a DAO without the interface unless you want to specify it...
anonymous
Thanks. I see where I went wrong. I expected the Weblogic Admin console to flag a JAR that contains entities with type "EJB", which it doesn't. I incorrectly assumed something was wrong with my code. Thanks for the clarification.
Sajee