0 Replies Latest reply on May 5, 2003 11:00 AM by sys user

    Not able to Create an Entity Bean (CMR)

    sys user Master

      I am executing the same in the techtip in the following URL:

      http://developer.java.sun.com/developer/EJTechTips/2002/tt1210.html#1

      THe techtip involves 3 Beans-Person,Phone and Address and user CMR 2.0. THe information for the bean is read from a Datafile whose contents are below:

      Person:0:TIMOTHY:WALTER:HARRIS:5/3/1981:M

      # Add addresses to people
      Address:0:H:336 BROWN WAY: :TWIN FALLS:ID:41307

      # Phone numbers
      Phone:0:535:555-7544: :Home

      While Person entity is created successfully, I always get the following exception while creating Address or Phone bean:


      2003-05-05 10:06:58,200 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.AddressBean] Error checking if entity exists
      interbase.interclient.SQLException: [interclient][interbase] Dynamic SQL Error
      SQL error code = -104
      Unexpected end of command

      at interbase.interclient.RecvMessage.createSQLException(interbase/interclient/RecvMessage.java:694)
      at interbase.interclient.RecvMessage.makeSQLException(interbase/interclient/RecvMessage.java:593)
      at interbase.interclient.RecvMessage.get_EXCEPTIONS(interbase/interclient/RecvMessage.java:554)
      at interbase.interclient.PreparedStatement.remote_PREPARE_STATEMENT(interbase/interclient/PreparedStatement.java:133)
      at interbase.interclient.PreparedStatement.(interbase/interclient/PreparedStatement.java:112)
      at interbase.interclient.Connection.prepareStatement(interbase/interclient/Connection.java:530)
      at org.jboss.resource.adapter.jdbc.local.LocalConnection.prepareStatement(LocalConnection.java:191)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.entityExists(JDBCCreateEntityCommand.java:148)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:127)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:527)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:253)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:270)
      at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:580)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1119)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:206)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:215)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:73)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:90)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:111)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:105)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129)
      at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invokeHome(BaseLocalContainerInvoker.java:230)
      at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
      at $Proxy28.create(Unknown Source)
      at AddressBean.ejbHomeLoad(Unknown Source)

      Here are the contents of my ejb-jar.xml and jbosscmp-jdbc.xml:

      <ejb-jar>
      <display-name>PersonJAR</display-name>
      <enterprise-beans>

      <display-name>AddressBean</display-name>
      <ejb-name>AddressBean</ejb-name>
      <local-home>AddressLocalHome</local-home>
      AddressLocal
      <ejb-class>AddressBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Object</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Address</abstract-schema-name>
      <cmp-field>
      postalcode
      <field-name>postalcode</field-name>
      </cmp-field>
      <cmp-field>
      street2
      <field-name>street2</field-name>
      </cmp-field>
      <cmp-field>
      street1
      <field-name>street1</field-name>
      </cmp-field>
      <cmp-field>
      region
      <field-name>region</field-name>
      </cmp-field>
      <cmp-field>
      city
      <field-name>city</field-name>
      </cmp-field>
      <ejb-local-ref>
      <ejb-ref-name>ejb/local/Person</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>PersonLocalHome</local-home>
      PersonLocal
      <ejb-link>personcmp.jar#PersonBean</ejb-link>
      </ejb-local-ref>
      <security-identity>

      <use-caller-identity></use-caller-identity>
      </security-identity>
      <resource-ref>
      <res-ref-name>jdbc/PK</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>




      <display-name>PersonBean</display-name>
      <ejb-name>PersonBean</ejb-name>
      <local-home>PersonLocalHome</local-home>
      PersonLocal
      <ejb-class>PersonBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Person</abstract-schema-name>
      <cmp-field>
      Person's date of birth
      <field-name>birthdate</field-name>
      </cmp-field>
      <cmp-field>
      Person's gender
      <field-name>gender</field-name>
      </cmp-field>
      <cmp-field>
      Person's last name
      <field-name>lastname</field-name>
      </cmp-field>
      <cmp-field>
      Person's middle name
      <field-name>middlename</field-name>
      </cmp-field>
      <cmp-field>
      Person's first name
      <field-name>firstname</field-name>
      </cmp-field>
      <cmp-field>
      Person's id
      <field-name>id</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>
      <security-identity>

      <use-caller-identity></use-caller-identity>
      </security-identity>
      <resource-ref>
      <res-ref-name>jdbc/PK</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>




      <display-name>PhoneBean</display-name>
      <ejb-name>PhoneBean</ejb-name>
      <local-home>PhoneLocalHome</local-home>
      PhoneLocal
      <ejb-class>PhoneBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Object</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Phone</abstract-schema-name>
      <cmp-field>
      type
      <field-name>type</field-name>
      </cmp-field>
      <cmp-field>
      areacode
      <field-name>areacode</field-name>
      </cmp-field>
      <cmp-field>
      number
      <field-name>number</field-name>
      </cmp-field>
      <cmp-field>
      extension
      <field-name>extension</field-name>
      </cmp-field>
      <ejb-local-ref>
      <ejb-ref-name>ejb/local/Person</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>PersonLocalHome</local-home>
      PersonLocal
      <ejb-link>personcmp.jar#PersonBean</ejb-link>
      </ejb-local-ref>
      <security-identity>

      <use-caller-identity></use-caller-identity>
      </security-identity>
      <resource-ref>
      <res-ref-name>jdbc/PK</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      </enterprise-beans>



      Home Address of Person

      <ejb-relation>
      Phone numbers of Person
      <ejb-relation-name>Person-Phone</ejb-relation-name>

      <ejb-relationship-role>
      <ejb-relationship-role-name>Person-has-phones</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>PersonBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>phones</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>Phone-belongs-to-Person</ejb-relationship-role-name>
      Many
      <cascade-delete />
      <relationship-role-source>
      <ejb-name>PhoneBean</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>

      </ejb-relation>

      <ejb-relation>
      Work Address of Person
      <ejb-relation-name>Person-WorkAddress</ejb-relation-name>

      <ejb-relationship-role>
      <ejb-relationship-role-name>Person-has-workAddress</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>PersonBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>workAddress</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>workAddress-belongs-to-Person</ejb-relationship-role-name>
      One
      <cascade-delete />
      <relationship-role-source>
      <ejb-name>AddressBean</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      <ejb-relation>
      Home Address of Person
      <ejb-relation-name>Person-HomeAddress</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Person-has-homeAddress</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>PersonBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>homeAddress</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>homeAddress-belongs-to-Person</ejb-relationship-role-name>
      One
      <cascade-delete />
      <relationship-role-source>
      <ejb-name>AddressBean</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>


      <assembly-descriptor>
      <method-permission>



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


      </method-permission>

      <method-permission>



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


      </method-permission>

      <method-permission>



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


      </method-permission>

      <container-transaction>

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

      <trans-attribute>Required</trans-attribute>
      </container-transaction>

      <container-transaction>

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

      <trans-attribute>Required</trans-attribute>
      </container-transaction>

      <container-transaction>

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

      <trans-attribute>Required</trans-attribute>
      </container-transaction>

      </assembly-descriptor>

      </ejb-jar>

      -------------------------------------------------------------

      <jbosscmp-jdbc>


      java:/dec2002
      <datasource-mapping>InterBase</datasource-mapping>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <read-only>false</read-only>
      <read-ahead>
      on-load
      <page-size>1000</page-size>
      <eager-load-group>*</eager-load-group>
      </read-ahead>
      <list-cache-max>1000</list-cache-max>




      <ejb-name>AddressBean</ejb-name>
      <table-name>ADDRESSBEAN</table-name>
      <cmp-field>
      <field-name>postalcode</field-name>
      <column-name>CODE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>street2</field-name>
      <column-name>STREET2</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>street1</field-name>
      <column-name>STREET1</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>region</field-name>
      <column-name>REGION</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>city</field-name>
      <column-name>CITY</column-name>
      </cmp-field>




      <ejb-name>PersonBean</ejb-name>
      <table-name>PERSONBEAN</table-name>
      <cmp-field>
      <field-name>birthdate</field-name>
      <column-name>BIRTHDATE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>gender</field-name>
      <column-name>GENDER</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastname</field-name>
      <column-name>LASTNAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>middlename</field-name>
      <column-name>MIDDLENAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstname</field-name>
      <column-name>FIRSTNAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>ID</column-name>
      </cmp-field>



      <ejb-name>PhoneBean</ejb-name>
      <table-name>PHONEBEAN</table-name>
      <cmp-field>
      <field-name>type</field-name>
      <column-name>TYPE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>areacode</field-name>
      <column-name>AREACODE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>number</field-name>
      <column-name>NUMBER</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>extension</field-name>
      <column-name>EXTENSION</column-name>
      </cmp-field>








      <ejb-relation>
      <ejb-relation-name>Person-Phone</ejb-relation-name>
      <foreign-key-mapping />
      <read-only>false</read-only>
      <read-time-out>300</read-time-out>

      <ejb-relationship-role>
      <ejb-relationship-role-name>Person-has-phones</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields>
      <key-field>
      <field-name>id</field-name>
      <column-name>id</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>


      <ejb-relationship-role>
      <ejb-relationship-role-name>Phone-belongs-to-Person</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields/>
      </ejb-relationship-role>


      </ejb-relation>

      <ejb-relation>
      <ejb-relation-name>Person-WorkAddress</ejb-relation-name>
      <foreign-key-mapping />
      <read-only>false</read-only>
      <read-time-out>300</read-time-out>

      <ejb-relationship-role>
      <ejb-relationship-role-name>Person-has-workAddress</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields>
      <key-field>
      <field-name>id</field-name>
      <column-name>id</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>


      <ejb-relationship-role>
      <ejb-relationship-role-name>workAddress-belongs-to-Person</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields/>
      </ejb-relationship-role>


      </ejb-relation>

      <ejb-relation>
      <ejb-relation-name>Person-HomeAddress</ejb-relation-name>
      <read-only>false</read-only>
      <read-time-out>300</read-time-out>

      <ejb-relationship-role>
      <ejb-relationship-role-name>Person-has-homeAddress</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields>
      <key-field>
      <field-name>id</field-name>
      <column-name>id</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>


      <ejb-relationship-role>
      <ejb-relationship-role-name>homeAddress-belongs-to-Person</ejb-relationship-role-name>
      <fk-constraint>true</fk-constraint>
      <key-fields/>
      </ejb-relationship-role>


      </ejb-relation>




      </jbosscmp-jdbc>



      Any help will be appreciated.