11 Replies Latest reply on Dec 2, 2002 1:06 PM by Elissandro

    FinderException on findByPrimaryKey

    Jonathan Weiss Newbie

      I'm fervently trying to port a J2EE app (EJB 1.1) over from WebLogic 6 to JBoss 3.0.0. Everything deployed well without too many alterations, but I get an interesting error at runtime: a FinderException (as suggested by the post title).

      Bascially, I am running a servlet that calls a session bean that in turn calls an entity bean. At runtime, the session bean gives an ObjectNotFoundException for a primary key that I know to be in storage (on a Postgres DB). What is interesting here, is that I when I run a command line client that requests a bean for the same primary key, it works fine. (I can also repeat these results with a servlet that directly invokes the bean.) In fact, after the bean has been loaded through my command line client, I am then able to access it through the servlet-to-session-bean-to-entity-bean mechanism.

      Amongst the stack trace, I get:

      $Proxy158.findByPrimaryKey(Unknown Source)

      though there doesn't seem to be a JNDI problem as I have a catch statement for that before it even gets to the findByPrimaryKey method.

      Anyway, I am quite at a loss and would appreciate any hints or suggestions.

      Thanks,
      jonathan

        • 1. Re: FinderException on findByPrimaryKey
          Jesper Thorhauge Newbie

          Hi

          I'm having the exact same problem and i think it might relate to this post http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ .... but in that post it is *not* solved - a suggestion made by davidjencks, but no reply on whether it works or not.
          What i found out is that when calling getPrimaryKey() within the EntityBean it returns null...

          So, basically, i'm also interested in some help on this problem :-)

          Regards

          • 2. Re: FinderException on findByPrimaryKey
            Dain Sundstrom Master

            > Amongst the stack trace, I get:
            >
            > $Proxy158.findByPrimaryKey(Unknown Source)

            This is normal. The proxy is the dynamically generated subclass of your abstract bean implementation class.

            What is the exception message? What is the top part of the stacktrace?

            • 3. Re: FinderException on findByPrimaryKey
              Martin Waardenburg Newbie

              I get the same problem. Here is the top of my stack trace:

              00:11:44,390 ERROR [LogInterceptor] TransactionRolledbackException, causedBy:
              java.lang.NullPointerException
              at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createBeanClassInstance(JDBCStoreManager.java:513)
              at org.jboss.ejb.plugins.CMPPersistenceManager.createBeanClassInstance(CMPPersistenceManager.java:165)
              at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createBeanClassInstance(CachedConnectionInterceptor.java:251)
              at org.jboss.ejb.EntityContainer.createBeanClassInstance(EntityContainer.java:294)
              at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:209)
              at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:76)
              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.Container.invoke(Container.java:729)
              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:198)
              at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
              at $Proxy181.findByPrimaryKey(Unknown Source)

              Thanks for any help...
              Martin

              • 4. Re: FinderException on findByPrimaryKey
                Martin Waardenburg Newbie

                I'm getting a similar problem:

                00:11:44,390 ERROR [LogInterceptor] TransactionRolledbackException, causedBy:
                java.lang.NullPointerException
                at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createBeanClassInstance(JDBCStoreManager.java:513)
                at org.jboss.ejb.plugins.CMPPersistenceManager.createBeanClassInstance(CMPPersistenceManager.java:165)
                at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createBeanClassInstance(CachedConnectionInterceptor.java:251)
                at org.jboss.ejb.EntityContainer.createBeanClassInstance(EntityContainer.java:294)
                at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:209)
                at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:76)
                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.Container.invoke(Container.java:729)
                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:198)
                at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
                at $Proxy181.findByPrimaryKey(Unknown Source)

                Thanks for any help,
                Martin

                • 5. Re: FinderException on findByPrimaryKey
                  David Li Newbie

                  Hi Dain,


                  Hi Dain, I got the same error too.
                  the error:
                  javax.ejb.ObjectNotFoundException: Object with primary key table1Key@4df1cf5b not found in storage

                  Note: I am using my own creat key class instead of the default types..
                  my ejb-jar.xml file under that particular
                  entity as:

                  .
                  .
                  <prim-key-class>table1Key</prim-key-class>
                  .
                  .


                  Do you know what I might do wrong?
                  David Li.

                  ps. thx for the comments on my other post, I am trying to read the docments on JBoss3.0.1 now. and in the progress of testing xdoclet to generate my ejb deployment scripts.

                  • 6. Re: FinderException on findByPrimaryKey
                    David Li Newbie

                    Hi Dain,
                    I got the same error too.
                    here is my stacktrace:
                    javax.ejb.ObjectNotFoundException: Object with primary userKey@4df1cf5b not found in storage

                    Note: I am using my own key class.

                    Thx for any help in advance.

                    David Li

                    • 7. Re: FinderException on findByPrimaryKey
                      David Li Newbie

                      Hi Dain,
                      I got the same error too.
                      here is my stacktrace:
                      javax.ejb.ObjectNotFoundException: Object with primary userKey@4df1cf5b not found in storage

                      Note: I am using my own key class.

                      Thx for any help in advance.

                      David Li

                      • 8. Re: FinderException on findByPrimaryKey
                        David Li Newbie

                        Hi Dain,
                        I got the same error too.
                        here is my stacktrace:
                        javax.ejb.ObjectNotFoundException: Object with primary userKey@4df1cf5b not found in storage

                        Note: I am using my own key class.

                        Thx for any help in advance.

                        David Li

                        • 9. Re: FinderException on findByPrimaryKey
                          Sandeep Dixit Newbie

                          I am having the same problem. Is there any solution posting?

                          Sandeep Dixit

                          • 10. Re: FinderException on findByPrimaryKey
                            Dain Sundstrom Master

                            Ya you all have the same problem. The system can not find your object in the datasotore. This is either because the object is not in the datastore, you are connecting to the wring datastore or most likely you have coded the custom pk wrong.

                            • 11. Re: FinderException on findByPrimaryKey
                              Elissandro Newbie

                              Dear all,

                              I'm having a similar problem.
                              My configuration is JBoss3.0.4+ SQLServer.
                              I'm trying to implement a many-to-one relationship in which one Role has many Users.

                              My stand-alone client must create the user and set its role via a RoleEntityLocal like below:
                              *************************************************
                              UserEntityHome userEntityHome = (UserEntityHome)lContext.lookup("ejb/uk/ac/essex/ueclaa/UserEntity");

                              RoleEntityLocalHome roleEntityLocalHome = (RoleEntityLocalHome)lContext.lookup("ejb/uk/ac/essex/ueclaa/RoleEntityLocalHome");

                              RoleEntityPK roleEntityPK= new RoleEntityPK("Administrator");

                              /*$Proxy2.findByPrimaryKey(Unknown Source)- ERROR IS HERE!!! */
                              RoleEntityLocal roleEntityLocal= roleEntityLocalHome.findByPrimaryKey(roleEntityPK);

                              UserEntityData userEntityData = new UserEntityData(new Integer(0),roleEntityLocal, "", "","","","","");

                              UserEntity userEntity= userEntityHome.create(userEntityData);

                              *************************************************
                              This is the error that I got:
                              Exception in thread "main" java.lang.NullPointerException
                              at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
                              at $Proxy2.findByPrimaryKey(Unknown Source)
                              at uk.ac.essex.ueclaa.client.TestClient.main(TestClient.java:45)

                              I've tried successfully to use remote interfaces like:
                              RoleEntityHome roleEntityHome = (RoleEntityHome)lContext.lookup("ejb/uk/ac/essex/ueclaa/RoleEntity");

                              RoleEntity roleEntity =roleEntityHome.findByPrimaryKey(roleEntityPK);

                              So my question is: Why remote calls for findByPrimaryKey method works and local ones not??

                              Many Thanks,

                              Sandro 2:)