5 Replies Latest reply on Dec 22, 2003 2:43 PM by naumankhanca

    CMP Deployment error in jboss3.2.1

    naumankhanca Newbie

      Hi,
      I wrote abstract class for entity bean and deploying it in jboss 3.2.1but it's throwing exception and warning during deployment such as

      quote:
      --------------------------------------------------------------------------------


      -3.2.1_tomcat-4.1.24/server/default/deploy/customer.jar
      22:04:29,897 WARN [verifier] EJB spec violation:
      Bean : CustomerBeanCMP
      Section: 9.2.2
      Warning: The entity bean class must not be defined as abstract.
      22:04:29,907 WARN [verifier] EJB spec violation:
      Bean : CustomerBeanCMP
      Section: 9.4.7.1
      Warning: The primkey-field element must name a public field in the bean implemen
      tation class.
      22:04:29,907 ERROR [MainDeployer] could not create deployment: file:/C:/jboss-3.
      2.1_tomcat-4.1.24/server/default/deploy/customer.jar
      org.jboss.deployment.DeploymentException: Verification of Enterprise Beans faile
      d, see above for error messages.
      at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:487)
      ..........so on



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

      Here is the code of my entity bean class


      quote:
      --------------------------------------------------------------------------------

      package customer;
      import javax.ejb.*;

      public abstract class CustomerBeanCMP implements EntityBean{

      private EntityContext context;

      public String ejbCreate(String last,String first,String addr){
      this.setLast(last);
      this.setFirst(last);
      this.setPK(makePK());
      this.setAddress(addr);
      return null;
      }

      public void ejbPostCreate(String last,String first,String addr){

      }

      public abstract String getLast();
      public abstract void setLast(String last);
      public abstract String getFirst();
      public abstract void setFirst(String first);
      public abstract String getCustAddress();
      public abstract void setCustAddress(String addr);
      public abstract String getPK();
      public abstract void setPK(String pk);

      public String getLastName(){

      return this.getLast();
      }

      public void setLastName(String name){

      this.setLast(name);
      }

      public String getFirstName(){

      return this.getFirst();
      }

      public void setFirstName(String name){

      this.setFirst(name);
      }

      public String getAddress(){

      return this.getCustAddress();
      }

      public void setAddress(String addr){

      this.setCustAddress(addr);
      }

      public void setEntityContext(EntityContext etx){

      context=etx;
      }


      public void unsetEntityContext(){}

      public void ejbLoad(){}
      public void ejbStore(){}
      public void ejbActivate(){}
      public void ejbPassivate(){}
      public void ejbRemove(){}

      private String makePK(){
      int rand=(int)(Math.random() * 42);
      return ""+rand;
      }


      }


      This is my 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>
      <enterprise-beans>

      <ejb-name>CustomerBeanCMP</ejb-name>
      customer.CustomerHome
      customer.Customer
      <ejb-class>customer.CustomerBeanCMP</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>CustomerSchema</abstract-schema-name>
      <cmp-field>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastname</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstname</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>address</field-name>
      </cmp-field>

      <query-method>
      <method-name>findByPrimaryKey</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      <![CDATA[SELECT OBJECT(a) FROM CustomerBeanCMP AS a WHERE id=?1]]>
      </ejb-ql>

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

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

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

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




      I will appreciate your input in this.

      Regards,
      Nauman

        • 1. Re: CMP Deployment error in jboss3.2.1
          Juha Lindfors Master

          You're deploying a CMP2.0 bean so your DTD must reflect this.

          • 2. Re: CMP Deployment error in jboss3.2.1
            naumankhanca Newbie

            Hi Juhu,
            Thanks for reply, I updated the dtd to 2_0 in my xml form like this

            <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"
            "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">

            But still I'm getting the same error as above I mention in my earlier post and unable to figure out the reason of this problem.
            Please help me to sort out this problem or you have any example to check CMP bean, please let me know.

            Regards,
            Nauman

            • 3. Re: CMP Deployment error in jboss3.2.1
              Juha Lindfors Master

              Try

              <!DOCTYPE ejb-jar PUBLIC
              "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
              "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

              instead.

              • 4. Re: CMP Deployment error in jboss3.2.1
                naumankhanca Newbie

                Thanks Juhu, That problem is solved as your advised solution but now I come across other problem which is NullPointerException

                15:18:19,699 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss
                -3.2.1_tomcat-4.1.24/server/default/deploy/customer.jar
                15:18:21,372 INFO [EjbModule] Creating
                15:18:21,382 INFO [EjbModule] Deploying CustomerBeanCMP
                15:18:21,612 INFO [EntityContainer] Creating
                15:18:21,622 INFO [EntityInstancePool] Creating
                15:18:21,622 INFO [EntityInstancePool] Created
                15:18:21,632 INFO [EntityContainer] Created
                15:18:21,632 INFO [EjbModule] Created
                15:18:21,632 INFO [EjbModule] Starting
                15:18:21,642 INFO [EntityContainer] Starting
                15:18:23,515 ERROR [EntityContainer] Starting failed
                org.jboss.deployment.DeploymentException: Couldn't create entity command: ; - ne
                sted throwable: (java.lang.NullPointerException)
                at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createCreateEntityC
                ommand(JDBCCommandFactory.java:137)
                at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDB
                CStoreManager.java:481)
                at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManage
                r.java:410)
                at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManag
                er.java:170)
                at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:339)
                at org.jboss.system.ServiceMBeanSupport.start

                .............................................

                I checked everything but I couldn't figure out the problem that's why i'm posting my files code
                This is the excerpt of standardjbosscmp-jdbc.xml which is in ejb-jar and also in conf directory

                <jbosscmp-jdbc>


                java:/MySqlDS
                <datasource-mapping>mySQL</datasource-mapping>

                <create-table>true</create-table>
                <remove-table>false</remove-table>
                <read-only>false</read-only>
                <read-time-out>300000</read-time-out>
                <row-locking>false</row-locking>
                <pk-constraint>true</pk-constraint>
                <fk-constraint>false</fk-constraint>
                <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
                <read-ahead>
                on-load
                <page-size>1000</page-size>
                <eager-load-group>*</eager-load-group>
                </read-ahead>
                <list-cache-max>1000</list-cache-max>

                <!-- <unknown-pk>-->
                <!-- <key-generator-factory>UUIDKeyGeneratorFactory</key-generator-factory>-->
                <!-- <unknown-pk-class>java.lang.String</unknown-pk-class>-->
                <!-- <jdbc-type>VARCHAR</jdbc-type>-->
                <!-- <sql-type>VARCHAR(32)</sql-type>-->
                <!-- </unknown-pk>-->

                <entity-command name="default"/>





                <enterprise-beans>

                <ejb-name>CustomerBeanCMP</ejb-name>
                <table-name>customer</table-name>
                <cmp-field>
                <field-name>id</field-name>
                <column-name>id</column-name>
                </cmp-field>
                <cmp-field>
                <field-name>lastname</field-name>
                <column-name>lastname</column-name>
                </cmp-field>
                <cmp-field>
                <field-name>firstname</field-name>
                <column-name>firstname</column-name>
                </cmp-field>
                <cmp-field>
                <field-name>address</field-name>
                <column-name>address</column-name>
                </cmp-field>

                </enterprise-beans>

                This is jboss.xml
                <?xml version='1.0' encoding='UTF-8' ?>
                <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN"
                "http://www.jboss.org/j2ee/dtd/jboss.dtd">

                <enterprise-beans>

                <ejb-name>CustomerBeanCMP</ejb-name>
                <jndi-name>ejb/CustomerBeanCMP</jndi-name>

                <resource-ref>
                <res-ref-name>jdbc/MySqlDS</res-ref-name>
                <jndi-name>java:/MySqlDS</jndi-name>
                </resource-ref>


                </enterprise-beans>


                This is standardjaws.xml in conf


                java:/MySqlDS
                <type-mapping>mySQL</type-mapping>
                false
                <default-entity>
                <create-table>true</create-table>
                <remove-table>false</remove-table>
                <tuned-updates>true</tuned-updates>
                <read-only>false</read-only>
                <time-out>300</time-out>
                <row-locking>false</row-locking>
                <read-ahead>false</read-ahead>
                </default-entity>

                <enterprise-beans>

                <ejb-name>CustomerBeanCMP</ejb-name>
                <table-name>customer</table-name>
                <cmp-field>
                <field-name>id</field-name>
                <column-name>id</column-name>
                </cmp-field>
                <cmp-field>
                <field-name>lastname</field-name>
                <column-name>lastname</column-name>
                </cmp-field>
                <cmp-field>
                <field-name>firstname</field-name>
                <column-name>firstname</column-name>
                </cmp-field>
                <cmp-field>
                <field-name>address</field-name>
                <column-name>address</column-name>
                </cmp-field>


                and in the last mysql-ds.xml which is in deploy directory

                <local-tx-datasource>
                <jndi-name>MySqlDS</jndi-name>
                <connection-url>jdbc:mysql://localhost:3306/nauman</connection-url>
                <driver-class>com.mysql.jdbc.Driver</driver-class>
                <user-name></user-name>

                </local-tx-datasource>



                I would really appreciate your help in this regard.
                Regards,
                Nauman


                • 5. Re: CMP Deployment error in jboss3.2.1
                  naumankhanca Newbie

                   

                  "naumankhanca" wrote:
                  Thanks Juhu, That problem is solved as your advised solution but now I come across other problem which is NullPointerException

                  15:18:19,699 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss
                  -3.2.1_tomcat-4.1.24/server/default/deploy/customer.jar
                  15:18:21,372 INFO [EjbModule] Creating
                  15:18:21,382 INFO [EjbModule] Deploying CustomerBeanCMP
                  15:18:21,612 INFO [EntityContainer] Creating
                  15:18:21,622 INFO [EntityInstancePool] Creating
                  15:18:21,622 INFO [EntityInstancePool] Created
                  15:18:21,632 INFO [EntityContainer] Created
                  15:18:21,632 INFO [EjbModule] Created
                  15:18:21,632 INFO [EjbModule] Starting
                  15:18:21,642 INFO [EntityContainer] Starting
                  15:18:23,515 ERROR [EntityContainer] Starting failed
                  org.jboss.deployment.DeploymentException: Couldn't create entity command: ; - ne
                  sted throwable: (java.lang.NullPointerException)
                  at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createCreateEntityC
                  ommand(JDBCCommandFactory.java:137)
                  at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.startStoreManager(JDB
                  CStoreManager.java:481)
                  at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManage
                  r.java:410)
                  at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManag
                  er.java:170)
                  at org.jboss.ejb.EntityContainer.startService(EntityContainer.java:339)
                  at org.jboss.system.ServiceMBeanSupport.start

                  .............................................

                  ... 55 more
                  15:33:11,762 INFO [EjbModule] Started
                  15:33:11,762 INFO [EJBDeployer] Deployed: file:/C:/jboss-3.2.1_tomcat-4.1.24/se
                  rver/default/deploy/customer.jar
                  15:33:11,772 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-
                  4.1.24/server/default/deploy/customer.jar
                  15:33:11,782 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean ope
                  ration 'checkIncompleteDeployments()'
                  Cause: Incomplete Deployment listing:
                  Packages waiting for a deployer:
                  <none>
                  Incompletely deployed packages:
                  <none>
                  MBeans waiting for classes:
                  <none>
                  MBeans waiting for other MBeans:
                  [ObjectName: jboss.j2ee:jndiName=ejb/CustomerBeanCMP,service=EJB
                  state: FAILED
                  I Depend On:
                  Depends On Me: org.jboss.deployment.DeploymentException: Couldn't create entity
                  command: ; - nested throwable: (java.lang.NullPointerException)]

                  ________________________________

                  I checked everything but I couldn't figure out the problem that's why i'm posting my files code
                  This is the excerpt of standardjbosscmp-jdbc.xml which is in ejb-jar and also in conf directory

                  <jbosscmp-jdbc>

                  <defaults>
                  <datasource>java:/MySqlDS</datasource>
                  <datasource-mapping>mySQL</datasource-mapping>

                  <create-table>true</create-table>
                  <remove-table>false</remove-table>
                  <read-only>false</read-only>
                  <read-time-out>300000</read-time-out>
                  <row-locking>false</row-locking>
                  <pk-constraint>true</pk-constraint>
                  <fk-constraint>false</fk-constraint>
                  <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
                  <read-ahead>
                  <strategy>on-load</strategy>
                  <page-size>1000</page-size>
                  <eager-load-group>*</eager-load-group>
                  </read-ahead>
                  <list-cache-max>1000</list-cache-max>

                  <!-- <unknown-pk>-->
                  <!-- <key-generator-factory>UUIDKeyGeneratorFactory</key-generator-factory>-->
                  <!-- <unknown-pk-class>java.lang.String</unknown-pk-class>-->
                  <!-- <jdbc-type>VARCHAR</jdbc-type>-->
                  <!-- <sql-type>VARCHAR(32)</sql-type>-->
                  <!-- </unknown-pk>-->

                  <entity-command name="default"/>



                  </defaults>

                  <enterprise-beans>
                  <entity>
                  <ejb-name>CustomerBeanCMP</ejb-name>
                  <table-name>customer</table-name>
                  <cmp-field>
                  <field-name>id</field-name>
                  <column-name>id</column-name>
                  </cmp-field>
                  <cmp-field>
                  <field-name>lastname</field-name>
                  <column-name>lastname</column-name>
                  </cmp-field>
                  <cmp-field>
                  <field-name>firstname</field-name>
                  <column-name>firstname</column-name>
                  </cmp-field>
                  <cmp-field>
                  <field-name>address</field-name>
                  <column-name>address</column-name>
                  </cmp-field>
                  </entity>
                  </enterprise-beans>

                  This is jboss.xml
                  <?xml version='1.0' encoding='UTF-8' ?>
                  <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN"
                  "http://www.jboss.org/j2ee/dtd/jboss.dtd">
                  <jboss>
                  <enterprise-beans>
                  <entity>
                  <ejb-name>CustomerBeanCMP</ejb-name>
                  <jndi-name>ejb/CustomerBeanCMP</jndi-name>

                  <resource-ref>
                  <res-ref-name>jdbc/MySqlDS</res-ref-name>
                  <jndi-name>java:/MySqlDS</jndi-name>
                  </resource-ref>
                  </entity>

                  </enterprise-beans>
                  </jboss>

                  This is standardjaws.xml in conf

                  <jaws>
                  <datasource>java:/MySqlDS</datasource>
                  <type-mapping>mySQL</type-mapping>
                  <debug>false</debug>
                  <default-entity>
                  <create-table>true</create-table>
                  <remove-table>false</remove-table>
                  <tuned-updates>true</tuned-updates>
                  <read-only>false</read-only>
                  <time-out>300</time-out>
                  <row-locking>false</row-locking>
                  <read-ahead>false</read-ahead>
                  </default-entity>

                  <enterprise-beans>
                  <entity>
                  <ejb-name>CustomerBeanCMP</ejb-name>
                  <table-name>customer</table-name>
                  <cmp-field>
                  <field-name>id</field-name>
                  <column-name>id</column-name>
                  </cmp-field>
                  <cmp-field>
                  <field-name>lastname</field-name>
                  <column-name>lastname</column-name>
                  </cmp-field>
                  <cmp-field>
                  <field-name>firstname</field-name>
                  <column-name>firstname</column-name>
                  </cmp-field>
                  <cmp-field>
                  <field-name>address</field-name>
                  <column-name>address</column-name>
                  </cmp-field>
                  </entity>

                  and in the last mysql-ds.xml which is in deploy directory
                  <datasources>
                  <local-tx-datasource>
                  <jndi-name>MySqlDS</jndi-name>
                  <connection-url>jdbc:mysql://localhost:3306/nauman</connection-url>
                  <driver-class>com.mysql.jdbc.Driver</driver-class>
                  <user-name></user-name>
                  <password></password>
                  </local-tx-datasource>

                  </datasources>

                  I would really appreciate your help in this regard.
                  Regards,
                  Nauman