1 Reply Latest reply on Dec 28, 2001 1:22 PM by glm

    CMP Entity Bean Deployment Problems

    glm Newbie

      I am on a Windows 2000 system with MS SQL Server with JBoss-2.4.3_Tomcat-3.2.3. I am trying to deploy two Entity Beans (Client and Employee). In the db tables Client has a field, clientid, that is an int and is its primary key. In Employee the primary key fiedl is employeeid but it also has a clientid associating it with the Client table. When I hot deploy the jar containing the two beans I get the following error:

      [Container factory] Deploying JBossUtilAutoNumber
      [Container factory] Deploying Client
      [Container factory] Deploying Employee
      [Container factory] org.jboss.ejb.DeploymentException: Bean Client has PK of type com.paye.payroll.ClientPK, so it should have a cmp-field named clien
      tid
      [Container factory] at org.jboss.ejb.plugins.jaws.metadata.JawsEntityMetaData.(JawsEntityMetaData.java:155)
      [Container factory] at org.jboss.ejb.plugins.jaws.metadata.JawsApplicationMetaData.(JawsApplicationMetaData.java:89)
      [Container factory] at org.jboss.ejb.plugins.jaws.metadata.JawsXmlFileLoader.load(JawsXmlFileLoader.java:53)
      [Container factory] at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommandFactory.(JDBCCommandFactory.java:133)
      [Container factory] at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.init(JAWSPersistenceManager.java:83)
      [Container factory] at org.jboss.ejb.plugins.CMPPersistenceManager.init(CMPPersistenceManager.java:110)
      [Container factory] at org.jboss.ejb.EntityContainer.init(EntityContainer.java:291)
      [Container factory] at org.jboss.ejb.Application.init(Application.java:202)
      [Container factory] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:372)
      [Container factory] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:304)
      [Container factory] at java.lang.reflect.Method.invoke(Native Method)
      [Container factory] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      [Container factory] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      [Container factory] at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:494)
      [Container factory] at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:468)
      [Container factory] at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:208)
      [Container factory] at java.lang.reflect.Method.invoke(Native Method)
      [Container factory] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      [Container factory] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      [Container factory] at org.jboss.ejb.AutoDeployer.deploy(AutoDeployer.java:379)
      [Container factory] at org.jboss.ejb.AutoDeployer.run(AutoDeployer.java:217)
      [Container factory] at java.lang.Thread.run(Thread.java:484)
      [J2EE Deployer Default] Starting Paye_Payroll-20011227.jar failed!
      [Default] org.jboss.ejb.DeploymentException: Could not deploy file:/D:/JBoss-2.4.3_Tomcat-3.2.3/jboss/tmp/deploy/Default/Paye_Payroll-20011227.jar, Ca
      use:org.jboss.ejb.DeploymentException: Bean Client has PK of type com.paye.payroll.ClientPK, so it should have a cmp-field named clientid
      [Default] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:401)
      [Default]
      [Default] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:304)
      [Default]
      [Default] at java.lang.reflect.Method.invoke(Native Method)
      [Default]
      [Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      [Default]
      [Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      [Default]
      [Default] at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:494)
      [Default]
      [Default] at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:468)
      [Default]
      [Default] at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:208)
      [Default]
      [Default] at java.lang.reflect.Method.invoke(Native Method)
      [Default]
      [Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      [Default]
      [Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      [Default]
      [Default] at org.jboss.ejb.AutoDeployer.deploy(AutoDeployer.java:379)
      [Default]
      [Default] at org.jboss.ejb.AutoDeployer.run(AutoDeployer.java:217)
      [Default]
      [Default] at java.lang.Thread.run(Thread.java:484)
      [Default]
      [J2EE Deployer Default] Module Paye_Payroll-20011227.jar is not running
      [J2EE Deployer Default] Destroying application Paye_Payroll-20011227.jar
      [AutoDeployer] Deployment failed:file:/D:/JBoss-2.4.3_Tomcat-3.2.3/jboss/deploy/Paye_Payroll-20011227.jar
      [AutoDeployer] org.jboss.deployment.J2eeDeploymentException: Error while starting Paye_Payroll-20011227.jar: Could not deploy file:/D:/JBoss-2.4.3_Tom
      cat-3.2.3/jboss/tmp/deploy/Default/Paye_Payroll-20011227.jar, Cause: org.jboss.ejb.DeploymentException: Could not deploy file:/D:/JBoss-2.4.3_Tomcat-3
      .2.3/jboss/tmp/deploy/Default/Paye_Payroll-20011227.jar, Cause:org.jboss.ejb.DeploymentException: Bean Client has PK of type com.paye.payroll.ClientPK
      , so it should have a cmp-field named clientid
      [AutoDeployer] at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:519)
      [AutoDeployer] at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:468)
      [AutoDeployer] at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:208)
      [AutoDeployer] at java.lang.reflect.Method.invoke(Native Method)
      [AutoDeployer] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      [AutoDeployer] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      [AutoDeployer] at org.jboss.ejb.AutoDeployer.deploy(AutoDeployer.java:379)
      [AutoDeployer] at org.jboss.ejb.AutoDeployer.run(AutoDeployer.java:217)
      [AutoDeployer] at java.lang.Thread.run(Thread.java:484)

      -------------------------------------
      My ejb-jar.xml looks like this:

      <?xml version="1.0" encoding="Cp1252"?>

      <!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>
      Deployment descriptor for the Paye Payroll EJB Deployment
      <display-name>PayePayroll</display-name>
      <enterprise-beans>
      <!-- autogenerate number for primary keys in database tables -->

      <ejb-name>JBossUtilAutoNumber</ejb-name>
      org.jboss.util.AutoNumberHome
      org.jboss.util.AutoNumber
      <ejb-class>org.jboss.util.AutoNumberEJB</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      True
      <cmp-field><field-name>name</field-name></cmp-field>
      <cmp-field><field-name>value</field-name></cmp-field>
      <primkey-field>name</primkey-field>


      Client Entity Bean
      <ejb-name>Client</ejb-name>
      com.paye.payroll.ClientHome
      com.paye.payroll.Client
      <ejb-class>com.paye.payroll.ClientBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>com.paye.payroll.ClientPK</prim-key-class>
      False
      <ejb-ref>
      <ejb-ref-name>ClientEJB</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      com.paye.payroll.EmployeeHome
      com.paye.payroll.Employee
      <ejb-link>Employee</ejb-link>
      </ejb-ref>


      Employee Entity Bean
      <ejb-name>Employee</ejb-name>
      com.paye.payroll.EmployeeHome
      com.paye.payroll.Employee
      <ejb-class>com.paye.payroll.EmployeeBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>com.paye.payroll.EmployeePK</prim-key-class>
      False
      <ejb-ref>
      <ejb-ref-name>EmployeeEJB</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      com.paye.payroll.ClientHome
      com.paye.payroll.Client
      <ejb-link>Client</ejb-link>
      </ejb-ref>

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

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


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

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      <ejb-client-jar>Paye.jar</ejb-client-jar>
      </ejb-jar>

      -------------------
      my jaws.xml looks like this:::


      SQLServerPool
      <type-mapping>MS SQLSERVER2000</type-mapping>
      <default-entity>
      <remove-table>false</remove-table>
      </default-entity>

      <type-mappings>
      <type-mapping>
      MS SQLSERVER2000
      .
      .
      .
      </type-mapping>
      </type-mappings>

      <enterprise-beans>

      <ejb-name>Client</ejb-name>
      <table-name>CLIENT</table-name>
      <remove-table>false</remove-table>
      <cmp-field>
      <field-name>clientid</field-name>
      <column-name>clientid</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>int identity</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>name</field-name>
      <column-name>NAME</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(50)</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>address</field-name>
      <column-name>ADDRESS</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(30)</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>city</field-name>
      <column-name>CITY</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(30)</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>state</field-name>
      <column-name>STATE</column-name>
      <jdbc-type>CHAR</jdbc-type>
      <sql-type>char</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>zip</field-name>
      <column-name>ZIP</column-name>
      <jdbc-type>CHAR</jdbc-type>
      <sql-type>char</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>taxId</field-name>
      <column-name>TAXID</column-name>
      <jdbc-type>CHAR</jdbc-type>
      <sql-type>char</sql-type>
      </cmp-field>


      findByEmployeeIdAndClientId
      employeeId = {0} AND clientId = {1}
      employeeId DESC
      <read-ahead>true</read-ahead>





      <ejb-name>Employee</ejb-name>
      <cmp-field>
      <field-name>employeeid</field-name>
      <column-name>EMPLOYEEID</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>int identity</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>name</field-name>
      <column-name>NAME</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(30)</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>clientid</field-name>
      <column-name>CLIENTID</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>int</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>dob</field-name>
      <column-name>DOB</column-name>
      <jdbc-type>SMALLINT</jdbc-type>
      <sql-type>smallint</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>ssn</field-name>
      <column-name>SSN</column-name>
      <jdbc-type>CHAR</jdbc-type>
      <sql-type>char</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>hourlyRate</field-name>
      <column-name>HOURLYRATE</column-name>
      <jdbc-type>DECIMAL</jdbc-type>
      <sql-type>money</sql-type>
      </cmp-field>
      <cmp-field>
      <field-name>sex</field-name>
      <column-name>SEX</column-name>
      <jdbc-type>CHAR</jdbc-type>
      <sql-type>char</sql-type>
      </cmp-field>




      <ejb-name>JBossUtilAutoNumber</ejb-name>
      <table-name>JBossUtilAutoNumberEJBTable</table-name>
      <create-table>true</create-table>
      <remove-table>false</remove-table>
      <tuned-update>true</tuned-update>
      <read-only>false</read-only>
      <time-out>300</time-out>
      <cmp-field>
      <field-name>name</field-name>
      <column-name>name</column-name>
      <sql-type>VARCHAR(30)</sql-type>
      <jdbc-type>VARCHAR</jdbc-type>
      </cmp-field>
      <cmp-field>
      <field-name>value</field-name>
      <column-name>value</column-name>
      </cmp-field>

      </enterprise-beans>



      Can someone tell me why I get this error message?

      Gary

        • 1. Re: CMP Entity Bean Deployment Problems
          glm Newbie

          Found the problem. Needed to add the following to the ejb-jar.xml for the Client entity:

          <cmp-field><field-name>clientId</field-name></cmp-field>

          and added the following for the Employee entity :

          <cmp-field><field-name>employeeId</field-name></cmp-field>