1 Reply Latest reply on Jun 9, 2004 4:50 AM by aloubyansky

    error while using compund primary key in CMP

    nischalsharma

      hi
      friends


      i have made cmp and where i am using compound primary key .for that
      i made one primary key file .but i am getting this error when i deploy
      my cmp on jboss-3.2.3.

      error is due to these lines:
      Bean : CandidatePassport
      Method : public PassportPK ejbCreate(Long, Long) throws CreateException
      Section: 10.6.5
      Warning: For each ejbCreate(...) method, the entity bean class must define a matching ejbPostCreate(...) method.


      But wht is the solution??




      message shown on jboss console:
      -----------------------------------------

      09:06:21,750 INFO [EARDeployer] Init J2EE application: file:/C:/jboss-3.2.3/server/default/deploy/deployEJBs.ear
      09:06:22,703 WARN [verifier] EJB spec violation:
      Bean : CandidatePassport
      Method : public PassportPK ejbCreate(Long, Long) throws CreateException
      Section: 10.6.5
      Warning: For each ejbCreate(...) method, the entity bean class must define a matching ejbPostCreate(...) method.

      09:06:23,515 ERROR [MainDeployer] could not create deployment: file:/C:/jboss-3.2.3/server/default/tmp/deploy/tmp11644deployEJBs.ear-content
      org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
      at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:491)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:786)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:778)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:641)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy6.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:274)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
      at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:394)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy4.start(Unknown Source)
      at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
      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.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy5.deploy(Unknown Source)
      at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
      at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
      at org.jboss.Main.boot(Main.java:150)
      at org.jboss.Main$1.run(Main.java:395)
      at java.lang.Thread.run(Thread.java:536)
      09:06:23,734 ERROR [MainDeployer] could not create deployment: file:/C:/jboss-3.2.3/server/default/deploy/deployEJBs.ear
      org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
      at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:491)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:786)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:778)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:641)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy6.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:274)
      at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
      at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:394)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy4.start(Unknown Source)
      at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
      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.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy5.deploy(Unknown Source)
      at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
      at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
      at org.jboss.Main.boot(Main.java:150)
      at org.jboss.Main$1.run(Main.java:395)
      at java.lang.Thread.run(Thread.java:536)
      09:06:23,953 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean operation 'checkIncompleteDeployments()'
      Cause: Incomplete Deployment listing:
      Packages waiting for a deployer:

      Incompletely deployed packages:
      [org.jboss.deployment.DeploymentInfo@c3445f80 { url=file:/C:/jboss-3.2.3/server/default/deploy/deployEJBs.ear }
      deployer: org.jboss.deployment.EARDeployer@11d2572
      status: Deployment FAILED reason: Verification of Enterprise Beans failed, see above for error messages.
      state: FAILED
      watch: file:/C:/jboss-3.2.3/server/default/deploy/deployEJBs.ear
      lastDeployed: 1086752181875
      lastModified: 1086752182000
      mbeans:
      ]MBeans waiting for classes:

      MBeans waiting for other MBeans:


      09:06:24,062 INFO [URLDeploymentScanner] Started jboss.deployment:type=DeploymentScanner,flavor=URL
      09:06:24,218 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.3/server/default/conf/jboss-service.xml
      09:06:24,218 INFO [Server] JBoss (MX MicroKernel) [3.2.3 (build: CVSTag=JBoss_3_2_3 date=200311301445)] Started in 1m:5s:375ms

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


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


      package com.hill_assoc.esp.CMP;
      import java.io.Serializable;

      public class PassportPK implements Serializable
      {
      public Long candidateId;
      public Long passSeq;

      public PassportPK() {
      }



      public PassportPK(Long candidateId,Long passSeq )
      {
      this.candidateId = candidateId;
      this.passSeq = passSeq;
      }

      public Long getcandidateId()
      {
      return candidateId;
      }

      public Long getpassSeq()
      {
      return passSeq;
      }

      public boolean equals(Object other)
      {
      if (other instanceof PassportPK)
      {
      final PassportPK otherPassportPK = (PassportPK)other;

      boolean areEqual = true;

      return areEqual;
      }

      return false;
      }

      public int hashCode()
      {
      return candidateId.hashCode()^passSeq.hashCode();
      }

      public String toString()
      {
      return candidateId+""+passSeq;
      }
      }
      -------------------------------

      package com.hill_assoc.esp.CMP;
      import javax.ejb.EJBLocalObject;
      import java.sql.Timestamp;
      import java.sql.Date;

      public interface CandidatePassportLocal extends EJBLocalObject
      {
      Long getCountryId();

      void setCountryId(Long countryId);

      String getPassportNo();

      void setPassportNo(String passportNo);

      Date getPassIssDate();

      void setPassIssDate(Date passIssDate);

      Date getPassExpDate();

      void setPassExpDate(Date passExpDate);

      Long getPassSeq();

      void setPassSeq(Long passSeq);



      }


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

      package com.hill_assoc.esp.CMP;
      import javax.ejb.EJBLocalHome;
      import javax.ejb.CreateException;
      import javax.ejb.FinderException;
      import java.util.Collection;

      public interface CandidatePassportLocalHome extends EJBLocalHome
      {
      public CandidatePassportLocal create(Long candidateId,Long passSeq) throws CreateException;

      public CandidatePassportLocal findByPrimaryKey(PassportPK primaryKey) throws FinderException;

      public Collection findAll() throws FinderException;
      }

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

      package com.hill_assoc.esp.CMP;
      import javax.ejb.EntityBean;
      import javax.ejb.EntityContext;
      import javax.ejb.CreateException;
      import java.sql.Timestamp;
      import java.sql.Date;

      public abstract class CandidatePassportBean implements EntityBean
      {
      private EntityContext context;

      public PassportPK ejbCreate(Long id,Long passSeq) throws CreateException
      {
      setCandidateId(id);
      setPassSeq(passSeq);
      return null;
      }

      public void ejbPostCreate(Long id,Long passSeq)
      {
      }

      public void ejbActivate()
      {
      }

      public void ejbLoad()
      {
      }

      public void ejbPassivate()
      {
      }

      public void ejbRemove()
      {
      }

      public void ejbStore()
      {
      }

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

      ejb-jar.xml ( cmp part from deployment descriptor)
      ---------------

      Entity Bean ( CMP )
      <display-name>CandidatePassport</display-name>
      <ejb-name>CandidatePassport</ejb-name>
      <local-home>com.hill_assoc.esp.CMP.CandidatePassportLocalHome</local-home>
      com.hill_assoc.esp.CMP.CandidatePassportLocal
      <ejb-class>com.hill_assoc.esp.CMP.CandidatePassportBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>com.hill_assoc.esp.CMP.PassportPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>CandidatePassport</abstract-schema-name>
      <cmp-field>
      <field-name>candidateId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>countryId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>passportNo</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>passIssDate</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>passExpDate</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>passSeq</field-name>
      </cmp-field>

      <query-method>
      <method-name>findAll</method-name>
      <method-params/>
      </query-method>
      <ejb-ql>select object(o) from CandidatePassport o</ejb-ql>




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

      my approach is right or not


      if any one knows bout this then please help me

      with regards
      nischal