13 Replies Latest reply on Sep 9, 2002 5:42 PM by Dain Sundstrom

    Why CMP is not deploying properly .........

    Vicky Kak Master

      Hi,
      Can you guys explain me the steps which I have to do to make the CMP storing data in the Oracle DataBase?I have created the files but feel they assembly is going wrong.I am using jboss3.0.0 with embedded catalina.
      What I am trying to achieve is to create the Entity for the table with three fields having the first field as primary Key.Now this table has to present in the Oracle DB.This is the thing which I want to achieve,My files are as .................
      Roles.java
      ################
      package project.entity.roles;
      import java.rmi.RemoteException;
      import javax.ejb.*;

      public interface Roles extends EJBObject
      {
      public int getRoleId() throws RemoteException;

      public String getRoleName() throws RemoteException;

      public void setRoleName(String value) throws RemoteException;

      public String getRoleDescription() throws RemoteException;

      public void setRoleDescription(String value) throws RemoteException;

      }

      ################
      RolesHome.java
      ################
      package project.entity.roles;
      import java.util.Collection;
      import javax.ejb.*;
      import java.rmi.RemoteException;

      public interface RolesHome extends EJBHome
      {
      public Roles create(int id) throws CreateException, RemoteException;

      public Roles findByPrimaryKey(int key) throws RemoteException, FinderException;
      public Collection findAll() throws RemoteException, FinderException;
      }

      ################
      RolesEJB
      ################
      package project.entity.roles;
      import javax.ejb.*;

      public class RolesEJB implements EntityBean
      {
      protected EntityContext context;

      public int id;
      public String name;
      public String description;

      public int getRoleId()
      {
      return id;
      }

      public String getRoleName()
      {
      return name;
      }

      public void setRoleName(String value)
      {
      this.name = value;
      }

      public String getRoleDescription()
      {
      return description;
      }

      public void setRoleDescription(String value)
      {
      this.description = value;
      }

      public void ejbLoad()
      {
      }

      public void ejbStore()
      {
      }

      public void ejbActivate()
      {
      }

      public void ejbPassivate()
      {
      }

      public void ejbRemove()
      {
      }

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

      public void unsetEntityContext()
      {
      this.context = null;
      }

      public java.lang.Integer ejbCreate(int id) throws CreateException
      {
      this.id = id;
      return null; // Return null when using CMP
      }

      public void ejbPostCreate(int id)
      {
      }
      }

      ################
      ejb-jar.xml and jbosscmp-jdbc.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>Roles</ejb-name>
      project.entity.roles.RolesHome
      project.entity.roles.Roles
      <ejb-class>project.entity.roles.RolesEJB</ejb-class>
      <prim-key-class>java.lang.Integer</prim-key-class>
      True
      <persistence-type>Container</persistence-type>
      <cmp-field><field-name>id</field-name></cmp-field>
      <cmp-field><field-name>name</field-name></cmp-field>
      <cmp-field><field-name>description</field-name></cmp-field>
      <!-- If I dont place these fields I get error
      org.jboss.deployment.DeploymentException: Bean Roles has PK of type java.lang.In
      teger, so it should have a cmp-field named MIN_VALUE.I can't understand this
      -->
      <!-- cmp-field><field-name>MIN_VALUE</field-name></cmp-field>
      <cmp-field><field-name>MAX_VALUE</field-name></cmp-field>
      <cmp-field><field-name>TYPE</field-name></cmp-field -->
      <prim-key-field>id</prim-key-field>

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

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

      <trans-attribute>NotSupported</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>
      _____________________________________________
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC
      "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN"
      "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">
      <jbosscmp-jdbc>
      <enterprise-beans>

      <ejb-name>RolesEJB</ejb-name>
      <table-name>IT_SYSROLES</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>SRL_ID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>name</field-name>
      <column-name>SRL_NAME</column-name>
      <not-null/>
      </cmp-field>
      <cmp-field>
      <field-name>description</field-name>
      <column-name>SRL_DESC</column-name>
      </cmp-field>

      </enterprise-beans>
      ################
      I require this very urgently..
      If possible please deploy on your system.....
      regards
      Vicky