1 Reply Latest reply on Sep 16, 2002 4:17 AM by kyungins

    javax.ejb.ObjectNotFoundException: Object with primary key R

    Jaya Selvan Newbie

      Hello all,
      I'm facing the problem

      javax.ejb.ObjectNotFoundException: Object with primary key RecDel.testPK@4e not found in storage

      When i use the findByPrimaryKey(PKClass pk).The following lines list out the PKClass

      package RecDel;

      public class testPK implements java.io.Serializable {

      public Integer no;
      public String name;

      public testPK() { };

      public testPK(Integer no){this.no=no;}

      public String getname() {

      return name;
      }

      public Integer getno() {

      return no;
      }

      public boolean equals(Object other) {

      if (other instanceof testPK) {
      return (no.equals(
      ((testPK)other).no) &&
      name.equals(
      ((testPK)other).name));
      }
      return false;
      }

      public int hashCode() {

      return no.hashCode();
      }

      }

      I did the column mapping in jaws.xml,worked with the commit option settings to B,C,D.But still getting the same error.Can anyone help me out to overcome this problem.

      Thanks in advance.

      rgds
      selvan

        • 1. Re: javax.ejb.ObjectNotFoundException: Object with primary k
          kyungins Newbie

          =======================================================================================
          Deploy message (Successful)
          =======================================================================================
          14:31:06,093 INFO [MainDeployer] Starting deployment of package: file:/C:/java/
          jboss-3.0.0_tomcat-4.0.3/server/default/deploy/PGCMP_G3.wlar
          14:31:11,561 INFO [MainDeployer] Successfully completed deployment of package:
          file:/C:/java/jboss-3.0.0_tomcat-4.0.3/server/default/deploy/PGCMP_G3.wlar
          14:31:16,577 INFO [MainDeployer] Starting deployment of package: file:/C:/java/
          jboss-3.0.0_tomcat-4.0.3/server/default/deploy/PGCMP_G3.jar
          14:31:16,764 INFO [EjbModule] Creating
          14:31:16,780 INFO [EjbModule] Deploying ZIPCode
          14:31:17,171 INFO [EjbModule] Deploying PGKey
          14:31:17,186 INFO [EjbModule] Deploying Operator
          14:31:17,202 INFO [EjbModule] Deploying AccessList
          14:31:17,202 INFO [EjbModule] Deploying OPPage
          14:31:17,218 INFO [EjbModule] Deploying GAccessList
          14:31:17,718 INFO [JDBCInitCommand] Created table 'OPPage' successfully.
          14:31:17,796 INFO [JDBCInitCommand] Created table 'AccessList' successfully.
          14:31:17,811 INFO [JDBCInitCommand] Created table 'Operator' successfully.
          14:31:17,827 INFO [JDBCInitCommand] Created table 'PGKey' successfully.
          14:31:17,843 INFO [JDBCInitCommand] Created table 'GAccessList' successfully.
          14:31:17,858 INFO [JDBCInitCommand] Created table 'ZIPCode' successfully.
          14:31:17,858 INFO [EjbModule] Created
          14:31:17,858 INFO [EjbModule] Starting
          14:31:18,124 INFO [EjbModule] Started
          14:31:18,124 INFO [MainDeployer] Successfully completed deployment of package:
          file:/C:/java/jboss-3.0.0_tomcat-4.0.3/server/default/deploy/PGCMP_G3.jar

          =======================================================================================
          http://localhost:8082
          =======================================================================================
          jboss.j2ee
          service=EARDeployer
          service=EJB,jndiName=AccessList
          service=EJB,jndiName=GAccessList
          service=EJB,jndiName=OPPage
          service=EJB,jndiName=Operator
          service=EJB,jndiName=PGKey
          service=EJB,jndiName=ZIPCode
          service=EJB,jndiName=ejb/jmx/ejb/Adaptor
          service=EJB,jndiName=ejb/mgmt/MEJB
          service=EjbModule,url=file%/C%/java/jboss-3.0.0_tomcat-4.0.3/server/default/deploy/PGCMP_G3.jar
          service=EjbModule,url=file%/C%/java/jboss-3.0.0_tomcat-4.0.3/server/default/deploy/ejb-management.jar
          service=EjbModule,url=file%/C%/java/jboss-3.0.0_tomcat-4.0.3/server/default/deploy/jmx-ejb-adaptor.jar

          =======================================================================================
          http://localhost:8080/test/entity.jsp
          =======================================================================================
          ...
          Object objref = ctx.lookup("Operator");
          OperatorHome oHome = (OperatorHome) PortableRemoteObject.narrow(objref, OperatorHome.class);


          OperatorPK oppk = new OperatorPK();
          oppk.opid = "aaa";

          Operator op = oHome.findByPrimaryKey(oppk);
          ...

          =======================================================================================
          (ERROR Message)
          =======================================================================================
          javax.ejb.ObjectNotFoundException: Object with primary key tgcorp.pg.ejb.entity.OperatorPK@cbcc4c9d not found in storage
          at org.jboss.ejb.plugins.jaws.jdbc.JDBCFindEntityCommand.execute(JDBCFindEntityCommand.java:85)
          at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.findEntity(JAWSPersistenceManager.java:263)
          at org.jboss.ejb.plugins.CMPPersistenceManager.findEntity(CMPPersistenceManager.java:336)
          at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntity(CachedConnectionInterceptor.java:301)
          at org.jboss.ejb.EntityContainer.find(EntityContainer.java:687)
          at java.lang.reflect.Method.invoke(Native Method)
          at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1116)
          at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:257)
          at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:215)
          at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:134)
          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:98)
          at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
          at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
          at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:104)
          at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:109)
          at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
          at org.jboss.ejb.Container.invoke(Container.java:726)
          at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
          at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:98)
          at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
          at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:73)
          at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:76)
          at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:185)
          at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
          at $Proxy34.findByPrimaryKey(Unknown Source)
          at org.apache.jsp.entity$jsp._jspService(entity$jsp.java:145)
          at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
          at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
          at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
          at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
          at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
          at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
          at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
          at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
          at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
          at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
          at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
          at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
          at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
          at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
          at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
          at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
          at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
          at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
          at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
          at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
          at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
          at java.lang.Thread.run(Thread.java:479)


          =======================================================================================
          ObjectNotFoundException
          =======================================================================================
          The throws clause may include the javax.ejb.FinderException and exceptions that are specific to your application.
          If a finder method returns a single primary key and the requested entity does not exist,
          the method should throw the javax.ejb.ObjectNotFoundException (a subclass of FinderException).
          If a finder method returns a collection of primary keys and it does not find any objects,
          it should return an empty collection.

          =======================================================================================
          TEST version
          =======================================================================================
          jboss-3.0.1RC1_tomcat-4.0.4
          jboss-3.0.0_tomcat-4.0.3
          jboss-3.0.0 (with jetty)
          jboss-3.0.2 (with jetty)

          =======================================================================================
          I Wonder about ...
          =======================================================================================
          I have got your same ERROR.

          1) I confirmed message "Successfully completed deployment of package".
          2) I found primary key value in the database by using sqlplus.
          3) I printed out data corresponded to the primary key on the web browser by using oracle connection pool (oracle-service.xml).

          like this...

          String dbName = "java:/OracleDS";
          DataSource ds = (DataSource) ctx.lookup(dbName);

          Connection conn2 = ds.getConnection();
          Statement stmt2 = conn2.createStatement();

          String qstr2 = "select count(*) from tab";
          ResultSet rs2 = stmt2.executeQuery(qstr2);

          while(rs2.next()) {
          out.println ("connectionpool=> " + rs2.getInt(1) + "");
          }

          BUT!!!
          Still getting the ObjectNotFoundException. =(
          What's wrong?