7 Replies Latest reply on Jun 21, 2002 5:42 PM by micahr

    Please help! Load failed

    banigreyling

      When I try to delete a record from the database, I do a lookup (findByPrimaryKey) and then call remoteInterface.remove(). This should work, but I get the following stack trace. Surely I am just missing something! Can someone give me a couple of things I can try to resolve this error in my code.

      [GenesisUserAccount] Activated bean GenesisUserAccount with id = GenesisUserAccount: PIETSAK , W10825
      [JAWS] Load command executing: SELECT dbo.GenesisUserAccount.userId,dbo.GenesisUserAccount.account
      No,dbo.GenesngType,dbo.GenesisUserAccount.authorisedDate,dbo.GenesisUser
      Account.corporateAccount,dbo.GenesisUserAccount.acsUserAccount.requestedDate FROM dbo.GenesisUserAccount
      WHERE userId=? AND accountNo=?
      [GenesisUserAccount] TRANSACTION ROLLBACK
      EXCEPTION:Load failed; nested exception is:
      java.lang.IllegalArgumentException: object is not an instance of declaring class; nested exception is:
      java.rmi.ServerException: Load failed; nested exception is:
      java.lang.IllegalArgumentException: object is not an instance of declaring class
      [GenesisUserAccount] java.rmi.ServerException: Load failed; nested exception is:
      [GenesisUserAccount] java.lang.IllegalArgumentException: object is not an instance of declaring class
      [GenesisUserAccount] java.lang.IllegalArgumentException: object is not an instance of declaring class
      [GenesisUserAccount] at java.lang.reflect.Field.get(Native Method)
      [GenesisUserAccount] at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.getPkFieldValue(JDBCCommand.java:663)
      [GenesisUserAccount] at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.setPrimaryKeyParameters(JDBCCommand.jav
      [GenesisUserAccount] at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.setParameters(JDBCLoadEntityC
      [GenesisUserAccount] at org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:159)
      [GenesisUserAccount] at org.jboss.ejb.plugins.jaws.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand
      [GenesisUserAccount] at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.loadEntity(JAWSPersistenceManager
      [GenesisUserAccount] at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:3
      [GenesisUserAccount] at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronization)
      [GenesisUserAccount] at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.ja
      [GenesisUserAccount] at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:271)
      [GenesisUserAccount] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:265)
      [GenesisUserAccount] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:61
      [GenesisUserAccount] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:197)
      [GenesisUserAccount] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
      [GenesisUserAccount] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
      [GenesisUserAccount] at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:427)
      [GenesisUserAccount] at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.
      [GenesisUserAccount] at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.jav
      [GenesisUserAccount] at org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:133)
      [GenesisUserAccount] at $Proxy74.remove(Unknown Source)

      The piece of code where the problem starts
      GenesisUserAccountRemote genesisUserAccountRemote = genesisUserAcctHome.
      findByPrimaryKey(
      new GenesisUserAccountPK(
      accountApplication.UserId,accountApplication.AccountNo));
      genesisUserAccountRemote.remove(); <--- This line throws exception


      I am running JBoss 2.4.3 against SQL Server2000

        • 1. Re: Please help! Load failed

          Since you have the home interface and the primary key (to do the lookup), why not just call remove on the home interface?

          David Sills

          • 2. Re: Please help! Load failed
            banigreyling

            OK, I tried your suggetion, but got the same Exception. Here is my code snippet.

            genesisUserAcctHome.remove(new GenesisUserAccountPK(
            accountApplication.UserId, accountApplication.AccountNo));

            When I do the following, the remove go through.

            GenesisUserAccountRemote genesisUserAccountRemote = genesisUserAcctHome.
            findByPrimaryKey(
            new GenesisUserAccountPK(
            accountApplication.UserId,accountApplication.AccountNo));
            genesisUserAccountRemote.getAccountNo(); <---- NOTE THIS LINE, Forces bean to be loaded into container
            Handle handle = genesisUserAccountRemote.getHandle();
            genesisUserAcctHome.remove(handle);

            Surely I must be able to remove a bean without it being fully loaded into the container, or am I stuck with this in-efficiency?

            Regards
            Bani

            • 3. Re: Please help! Load failed
              sachin

              Hi,
              Even i have the same problem with record deletion.
              Even i am following the calling of remove method using the remote interface. Am using Jboss 2.4.3 and Postgres db.
              I have looked at the posts around for the same topic and have not found a very specific solution. Somewhere it was posted to use B/C commit option. Somewhere it was for setting the transaction attribute.
              Somewhere it was for getting a new connection object before any database queries( i am using bmp).
              I have posted my question in the same forum with subject 'record deletion'.

              Sachin

              • 4. Load failed while calling remove()
                banigreyling

                Perhaps I should have named the topic differently...;)

                The problem, as I see it, have something to do with the entity instance not being instantiated/loaded yet because entity beans are lazily loaded by default. A work around could be to set read ahead flag to true (or maybe one of the solutions Sachin mentioned), but this will have unacceptable performance implications. I am convinced the container should be able to handle the removal of a uninstantiated/not loaded bean with a stock standard configuration.

                My current workaround is to call a getter method on one of the non-primary key fields as to force the container to load the bean before calling a delete. This is not an elegant solution, because it results in a select query against the database before you delete the exact same record you have just selected!

                Maybe I could find some time in the near future to trace this delete call through the container. The lead developers is (quite understandebly) much more helpful if you present them with patch rather than a problem...but this is only maybe, becuase I do not understand the internal workings of jboss all that well and this could take some unpresedented time...

                • 5. Re: Load failed while calling remove()
                  banigreyling

                  Anyone who wants to post to this thread, rather post to the thread topic "record deletion", because both topics is essentially about the same problem and the current description for this topic suck (I may say this because I named it like this ;))

                  • 6. Re: Load failed while calling remove()
                    sachin

                    Hi,
                    But do the things work fine with your workaround of calling a getter method before calling remove?
                    i tried it, but it did not solve my problem.

                    Sachin

                    • 7. Re: Load failed while calling remove()
                      micahr

                      I seem to be having a similar problem, however I am getting a very unusual error message.

                      I am using BMP for an entity bean on JBoss 2.4.4 with embedded Tomcat 4.0.1. Java Version 1.3.1_03 under Redhat 7.2

                      From a certain servlet if I call findByPrimaryKey and then call delete on what was returned, I get a ClassCastException in ejbLoad. I get this error when I get the primary key and cast it to the specific primary key for the bean. I have checked the class name and package of the primary key being returned by the context using .getClass().getName() and everything matches, so I do not know why it is throwing a ClassCastException. However, if I call a get method on the remote object before calling remove, the problem goes away. As I mentioned that only a certain servlet does this, I have other servlets that do the exact same thing and do not have a problem running on the same server for the same bean.