5 Replies Latest reply on Jan 9, 2004 1:35 PM by davelilley

    Create exception

    arnaud74130

      hi,

      I can't create my EJB 1.1 with JBoss 2.4.1 / Tomcat
      i just have a simple Entity:


      when i call the create method, i still have

      " javax.ejb.CreateException: Could not create entity:java.lang.NullPointerException
      at org.jboss.ejb.plugins.jaws.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:139)"

      i try different create method (with parameters ect..)
      but each time i have the same error.

      My Datasource is ok, and the tables are automatically created by JBoss, so it is "JUST" an entity creation problem,

      please help.

      <<<<<<<<< >>>>>>>>>>>>>>
      -- jaws.xml --
      <?xml version="1.0" encoding="US-ASCII"?>

      mySQLDS
      <type-mapping></type-mapping>
      <type-mappings/>
      <default-entity>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <tuned-updates>true</tuned-updates>
      <read-only>false</read-only>
      <time-out>300</time-out>
      </default-entity>
      <enterprise-beans>

      <ejb-name>InternautesBean</ejb-name>
      <table-name>Internautes</table-name>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <tuned-updates>false</tuned-updates>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <cmp-field>
      <field-name>internaute_id</field-name>
      <column-name>internaute_id</column-name>
      </cmp-field>
      <cmp-field>
      ....
      <<<<<<<<< >>>>>>>>>>>>>>
      --- ejbjar.xml ---
      <?xml version="1.0"?>
      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
      <ejb-jar>
      <enterprise-beans>

      <ejb-name>InternautesBean</ejb-name>
      com.seariver.integration.InternautesHome
      com.seariver.integration.Internautes
      <ejb-class>com.seariver.integration.InternautesBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>com.seariver.integration.InternautesPK</prim-key-class>
      False
      <cmp-field>
      <field-name>internaute_id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>email</field-name>
      </cmp-field>
      ....


      this is the bean code:
      public class InternautesBean implements EntityBean {
      private EntityContext ctx;

      public int internaute_id;
      public String email;

      public String firstname;

      public String lastname;
      public String login;
      public String password;

      public String locale;
      public int friend_id;


      public void setEntityContext(EntityContext context) throws RemoteException, EJBException {
      ctx = context;
      }

      public void unsetEntityContext() throws RemoteException, EJBException {
      ctx = null;
      }

      public void ejbActivate() throws RemoteException, EJBException {
      }

      public void ejbPassivate() throws RemoteException, EJBException {
      }

      public void ejbRemove() throws RemoteException, EJBException {
      }

      public void ejbStore() throws RemoteException, EJBException {
      }

      public void ejbLoad() throws RemoteException, EJBException {
      }

      public InternautesPK ejbCreate() throws CreateException, EJBException, RemoteException, SQLException {
      // Write your code here
      return null;
      }

      public void ejbPostCreate() throws CreateException, EJBException, RemoteException, SQLException {
      // Write your code here
      }

      public int getInternaute_id(){ return internaute_id; }

      public void setInternaute_id(int param){ this.internaute_id = param; }

      public String getEmail(){ return email; }

      public void setEmail(String param){ this.email = param; }

      public String getFirstname(){ return firstname; }

      public void setFirstname(String param){ this.firstname = param; }

      public String getLastname(){ return lastname; }

      public void setLastname(String param){ this.lastname = param; }

      public String getLogin(){ return login; }

      public void setLogin(String param){ this.login = param; }

      public String getPassword(){ return password; }

      public void setPassword(String param){ this.password = param; }

      public String getLocale(){ return locale; }

      public void setLocale(String param){ this.locale = param; }

      public int getFriend_id(){ return friend_id; }

      public void setFriend_id(int param){ this.friend_id = param; }

      private InternauteVO createInternauteVO(){
      com.seariver.vo.InternauteVO valueObj = new com.seariver.vo.InternauteVO();
      valueObj.internaute_id = internaute_id;
      valueObj.email = email;
      valueObj.firstname = firstname;
      valueObj.lastname = lastname;
      valueObj.login = login;
      valueObj.password = password;
      valueObj.locale = locale;
      valueObj.friend_id = friend_id;
      return valueObj;
      }

      public InternauteVO getInternauteVO(){
      return createInternauteVO();
      }

      private void mergeInternauteVO(InternauteVO valueObj){
      internaute_id = valueObj.internaute_id;
      email = valueObj.email;
      firstname = valueObj.firstname;
      lastname = valueObj.lastname;
      login = valueObj.login;
      password = valueObj.password;
      locale = valueObj.locale;
      friend_id = valueObj.friend_id;
      }

      public void setInternauteVO(InternauteVO param){
      mergeInternauteVO(param);
      }
      }