1 Reply Latest reply on Sep 10, 2002 11:54 AM by juha

    No abstract accessors - error msg

      I am trying to deploy my first entity bean and keep getting a:
      No abstract accessors for field name 'userId' found in entity class com.schedulestar.revolution.ejb.UserBean

      I've checked my code time and time again but I must be missing something. Could someone help me out?

      Here is my Remote Interface:
      package com.schedulestar.revolution.ejb;

      import java.rmi.RemoteException;

      public interface User
      extends javax.ejb.EJBObject
      {
      public abstract String getFirstName()
      throws RemoteException;

      public abstract String getLastName()
      throws RemoteException;

      public abstract Integer getUserId()
      throws RemoteException;

      public abstract void setFirstName(String aStr)
      throws RemoteException;

      public abstract void setLastName(String aStr)
      throws RemoteException;

      public abstract void setUserId(Integer aInt)
      throws RemoteException;

      }

      My Home interface:
      package com.schedulestar.revolution.ejb;

      import java.rmi.RemoteException;
      import javax.ejb.CreateException;
      import javax.ejb.FinderException;

      import java.util.Collection;

      public interface UserHome
      extends javax.ejb.EJBHome
      {
      public User create(Integer aId)
      throws CreateException, RemoteException;

      public Collection findAll()
      throws FinderException, RemoteException;

      public User findByPrimaryKey(UserPK aPk)
      throws FinderException, RemoteException;

      public User findByEmail(String aStr)
      throws FinderException, RemoteException;
      }

      My Bean:
      package com.schedulestar.revolution.ejb;

      import javax.ejb.EntityContext;
      import javax.ejb.CreateException;

      public abstract class UserBean
      implements javax.ejb.EntityBean
      {
      transient private EntityContext ctx;

      public Integer userId;
      public String fName;
      public String lName;

      public void ejbActivate() {}

      public Integer ejbCreate(Integer aId)
      throws CreateException
      {
      this.userId = aId;
      return userId;
      }

      public void ejbLoad() {}

      public void ejbPassivate() {}

      public void ejbPostCreate(Integer aId) {
      }

      public void ejbRemove() {}

      public void ejbStore() {}

      public String getFirstName() {
      return fName;
      }

      public String getLastName() {
      return lName;
      }

      public Integer getUserId() {
      return userId;
      }

      public void setEntityContext(EntityContext aCtx) {
      this.ctx = aCtx;
      }

      public void setFirstName(String aStr) {
      fName = aStr;
      }

      public void setLastName(String aStr) {
      lName = aStr;
      }

      public void setUserId(Integer aInt) {
      userId = aInt;
      }

      public void unsetEntityContext() {
      ctx = null;
      }
      }

      My PK:
      package com.schedulestar.revolution.ejb;

      public class UserPK
      implements java.io.Serializable
      {
      public Integer userId;
      }

      My ejb-jar.xml:
      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE ejb-jar PUBLIC
      "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
      "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar>
      <display-name>User Jar</display-name>

      <enterprise-beans>

      <display-name>User Entity Bean</display-name>
      User Entity Bean
      <ejb-name>UserEJB</ejb-name>
      com.schedulestar.revolution.ejb.UserHome
      com.schedulestar.revolution.ejb.User
      <ejb-class>com.schedulestar.revolution.ejb.UserBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-field><field-name>userId</field-name></cmp-field>
      <cmp-field><field-name>firstName</field-name></cmp-field>
      <cmp-field><field-name>lastName</field-name></cmp-field>
      <primkey-field>userId</primkey-field>

      </enterprise-beans>
      </ejb-jar>

      And my jboss.xml:
      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE jboss PUBLIC
      "-//JBoss//DTD JBOSS 3.0//EN"
      "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">



      <enterprise-beans>

      <ejb-name>UserEJB</ejb-name>
      <jndi-name>revolution/User</jndi-name>

      </enterprise-beans>


      Any help would be greatly appreciated.

      Thanks!

        • 1. Re: No abstract accessors - error msg

          you need to declare abstract getters and setters in your bean implementation when you are using CMP 2.0. You must not implement these methods yourself (what you're doing not). Also you do not need to declare public fields for the CMP fields.

          Your entity looks like its CMP 1.1 entity.

          Remove public fields such as userID, remove your implementation of getUserId() and setUserId() and declare these two methods as abstract (the CMP 2.0 engine will generate the implementation for these methods for you).

          Your entity would probably work unchanged if you change the DTD declaration in the ejb-jar.xml to point to the 1.1 schema.