0 Replies Latest reply on Apr 23, 2002 6:26 PM by Richard Bottoms

    cmp code & app xml problems

    Richard Bottoms Newbie

      I modified the CD example to match my database setup. I get deployment errors that mean I'm doing something wrong.

      Here's the code, followed by ejb-jar.xml, jboss.xml, jaws.xml:

      ************
      the bean
      ************
      package ejb.linuxsoft.jobsearch.admin.bean;

      import javax.ejb.EntityBean;
      import javax.ejb.EntityContext;
      import java.rmi.RemoteException;
      import javax.naming.Context;
      import javax.ejb.FinderException;
      import javax.ejb.RemoveException;
      import javax.ejb.CreateException;
      import javax.ejb.EJBException;
      import javax.naming.InitialContext;
      import javax.rmi.PortableRemoteObject;
      import java.util.*;

      public class UserBean implements EntityBean {

      public Integer Id;
      public String Username;
      public String Password;
      public Integer Permission_Level;

      public Integer ejbCreate(Integer _Id) throws CreateException, RemoteException {
      System.out.println("ejbCreate() called");
      Id = _Id;
      return null;
      }

      public void ejbPostCreate(Integer Id) {}

      public String getUsername() throws RemoteException {
      System.out.println("getUsername called.");
      return Username;
      }

      public void setEntityContext(EntityContext ctx) throws RemoteException {
      System.out.println("setEntityContext called");
      this.ctx = ctx;
      }

      public void unsetEntityContext() throws RemoteException {
      System.out.println("unsetEntityContext called");
      ctx = null;
      }

      public void ejbActivate() throws RemoteException {
      System.out.println("ejbActivate() called");
      }

      public void ejbPassivate() throws RemoteException {
      System.out.println("ejbPassivate() called");
      }

      public void ejbLoad() throws RemoteException {
      System.out.println("ejbLoad() called");
      }

      public void ejbStore() throws RemoteException {
      System.out.println("ejbStore() called");
      }

      public void ejbRemove() throws RemoteException {
      System.out.println("ejbRemove() called");
      }

      }

      }


      ********
      remote
      ********
      package ejb.linuxsoft.jobsearch.admin.interfaces;

      import javax.ejb.EJBObject;
      import java.rmi.RemoteException;

      public interface User extends EJBObject {

      public Integer getId() throws RemoteException;
      public String getUsername() throws RemoteException;


      }


      ********
      home
      ********
      package ejb.linuxsoft.jobsearch.admin.interfaces;

      import java.rmi.RemoteException;
      import javax.ejb.CreateException;
      import javax.ejb.FinderException;
      import javax.ejb.EJBHome;
      import java.util.Collection;
      import java.util.Enumeration;

      public interface UserHome extends EJBHome {

      public User create(Integer Id) throws RemoteException, CreateException;
      public User findByPrimaryKey (Integer Id) throws RemoteException, FinderException;
      public Collection findAll() throws RemoteException, FinderException;

      }

      *********
      jboss.xml
      *********
      <?xml version="1.0" encoding="Cp1252"?>


      false
      <container-configurations />
      <resource-managers />
      <enterprise-beans>

      <ejb-name>UserBean</ejb-name>
      <jndi-name>admin/User</jndi-name>
      <configuration-name></configuration-name>

      </enterprise-beans>


      ********
      jaws.xml
      ********
      <?xml version="1.0" encoding="ISO-8859-1"?>

      OracleDB
      <type-mapping>Oracle8</type-mapping>
      true

      <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>
      <select-for-update>false</select-for-update>
      </default-entity>
      <enterprise-beans>

      <ejb-name>UserBean</ejb-name>
      <table-name>users</table-name>
      <cmp-field>
      <field-name>Id</field-name>
      <column-name>Id</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>int</<sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>Username</field-name>
      <column-name>Username</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(15)</<sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>Password</field-name>
      <column-name>Password</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(15)</<sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>Permission_Level</field-name>
      <column-name>Permission_Level</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>int</<sql-type>
      </cmp-field>

      <enterprise-beans>



      ***********
      ejb-jar.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>
      <display-name>User</display-name>
      <enterprise-beans>

      Models a Linuxsoft User
      <ejb-name>UserBean</ejb-name>
      ejb.linuxsoft.jobsearch.admin.interfaces.UserHome
      ejb.linuxsoft.jobsearch.admin.interfaces.User
      <ejb-class>ejb.linuxsoft.jobsearch.admin.bean.UserBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-field>
      <field-name>Id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>Username</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>Password</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>Permission_Level</field-name>
      </cmp-field>
      <primkey-field>Id</primkey-field>

      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>

      <ejb-name>UserBean</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Supports</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>


      BTW, wheres the code for the CDCollectionBean?


      Thanks,
      r.b.