1 2 Previous Next 16 Replies Latest reply on Mar 5, 2003 5:59 PM by cstach

    Attempt to remove a lock for a null object

    pcollet

      I am trying to create an entity bean from a session bean and right after the create call get its primary key. I get a lock error. Any idea of what could be wrong?

      15:14:22,928 ERROR [LogInterceptor] TransactionRolledbackLocalException, causedBy:

      java.lang.IllegalArgumentException: Attempt to remove a lock for a null object

      at org.jboss.ejb.BeanLockManager.removeLockRef(BeanLockManager.java:103)

      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:124)

      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)

      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)

      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)

      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)

      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)

      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)

      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)

      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:301)

      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)

      at $Proxy173.getPrimaryKey(Unknown Source)

        • 1. Re: Attempt to remove a lock for a null object
          vvarimo

          Hi!

          I'm having this problem also with JBoss 3.0.4 and Oracle 9.2.0.1 with thin JDBC drivers. If I try with JBoss 3.0.2, problem does not occur.

          Any thoughts?

          • 2. Re: Attempt to remove a lock for a null object

            You have a problem with your primary key.
            Either it is not coded correctly, or it is not
            being filled with a value in ejbCreate()

            3.0.2 didn't check for null keys, I've already fixed
            3.0.5 so that it reports against trying to get the
            lock.
            3.0.4 really reports it when trying to get the lock,
            then tries to remove the lock and reports the
            error you see :-(

            Regards,
            Adrian

            • 3. Re: Attempt to remove a lock for a null object
              vvarimo

              Hi,

              I'm using now JBoss 3.0.5 RC2 built from CVS sources in this morning. Everything worked fine for a while, I didn't
              get any errors, but then for some unknown reason server started to halt on this error:

              ----

              2002-12-27 17:37:45,701 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException, causedBy:
              java.lang.IllegalArgumentException: Attempt to get a lock for a null object
              at org.jboss.ejb.BeanLockManager.getLock(BeanLockManager.java:80)
              at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:99)
              at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)

              ----

              The primary keys of entity beans are integers and I'm sure that they are not null. This problem occures when I'm trying to add 1:n relationship between them.

              Please add some null checks, this is really exhausting problem.



              Thanks,

              -Vesa-

              • 4. Re: Attempt to remove a lock for a null object
                vvarimo

                Hi,

                I'm using now JBoss 3.0.5 RC2 built from CVS sources in this morning. Everything worked fine for a while, I didn't
                get any errors, but then for some unknown reason server started to halt on this
                error:

                ----

                2002-12-27 17:37:45,701 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException, causedBy:
                java.lang.IllegalArgumentException: Attempt to get a lock for a null object
                at org.jboss.ejb.BeanLockManager.getLock(BeanLockManager.java:80)
                at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:99)
                at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)

                ----

                The primary keys of entity beans are integers and I'm sure that they are not null. This problem occures when I'm trying to add 1:n relationship between them.

                Please add some null checks, this is really exhausting problem.



                Thanks,

                -Vesa-

                • 5. Re: Attempt to remove a lock for a null object

                  Can you post a simple example that reproduces
                  the problem.
                  Or at least show the code and deployment descriptors.

                  Regards,
                  Adrian

                  • 6. Re: Attempt to remove a lock for a null object
                    pcollet

                    I'm using automatic generated key (from MySQL) so why would I have to set a value in ejbCreate()?

                    • 7. Re: Attempt to remove a lock for a null object

                      That is only supported in jboss3.2
                      It won't work with 3.0.x

                      Regards,
                      Adrian

                      • 8. Re: Attempt to remove a lock for a null object
                        shogun1234

                        > I am trying to create an entity bean from a session
                        > bean and right after the create call get its primary
                        > key. I get a lock error. Any idea of what could be
                        > wrong?
                        >
                        did you solve your problem?
                        becuase i encounter the same one in which i simply hope to get a record/row represented a column, which is also its primary key (as read only view) without modifying any data in the table, however, the error report are the same as yours, even though endeavoring to set its primary key as not null after invoking create(String pk) method in session bean.
                        (the session bean, in which a method "inquiry" is invoked, when callin' entity bean after create() through remote interface, also has one method named delegate() in preforming the logic of runnin' entity bean.)

                        the env my ap running on is jboss3.0.4 with tomcat4.1.12, j2sdk1.4.1_01
                        i appreciate any suggestions,
                        thank you very much,

                        ============
                        error message:
                        11:41:54,328 INFO [STDOUT] [PrefixSessionBean]delegate ...BEG
                        11:41:54,328 INFO [STDOUT] [PrefixSessionBean]delegate:PREFIX_NO:090097093
                        11:41:54,343 INFO [STDOUT] [PrefixSessionBean]context:lookup
                        11:41:54,343 INFO [STDOUT] [PrefixSessionBean]delegate:create
                        11:41:54,359 INFO [STDOUT] prefixHome:ejb/PrefixHome
                        11:41:54,359 INFO [STDOUT] [PrefixBean]ejbCreate ...BEG
                        11:41:54,359 INFO [STDOUT] [PrefixBean]ejbCreate ...END
                        11:41:54,359 INFO [STDOUT] [PrefixSessionBean]delegate:inquiry
                        11:41:54,375 ERROR [LogInterceptor] TransactionRolledbackException, causedBy:
                        java.lang.IllegalArgumentException: Attempt to remove a lock for a null object

                        • 9. Re: Attempt to remove a lock for a null object
                          pcollet

                          No I didn't resolve my problem. I've tried to use 3.2 but got into some problems with JBuilder and its wizard and got distracted into doing other stuffs...

                          I'm planning to get back to this problem soon...

                          • 10. Re: Attempt to remove a lock for a null object
                            cstach

                            I have the same problem. I'm using JBoss 3.0.4 with MySQL 3.23.54a-3.73 (RedHat) and mysql-connector-java-3.0.6-stable.

                            Table schema:

                            CREATE TABLE data_version (
                            id INT NOT NULL AUTO_INCREMENT,
                            PRIMARY KEY (id)
                            );

                            CREATE TABLE data (
                            id INT NOT NULL AUTO_INCREMENT,
                            data_version_id INT,
                            PRIMARY KEY (id)
                            );

                            Descriptor:


                            <ejb-name>DataEJB</ejb-name>
                            <prim-key-class>java.lang.Long</prim-key-class>
                            <primkey-field>id</primkey-field>

                            false
                            <cmp-version>2.x</cmp-version>
                            <abstract-schema-name>data</abstract-schema-name>

                            <cmp-field>
                            <field-name>id</field-name>
                            </cmp-field>



                            <ejb-name>DataVersionEJB</ejb-name>

                            <prim-key-class>java.lang.Long</prim-key-class>
                            <primkey-field>id</primkey-field>

                            false
                            <cmp-version>2.x</cmp-version>
                            <abstract-schema-name>data_version</abstract-schema-name>

                            <cmp-field>
                            <field-name>id</field-name>
                            </cmp-field>


                            <ejb-relation>
                            <ejb-relation-name>Data-Data Version</ejb-relation-name>

                            <ejb-relationship-role>
                            <ejb-relationship-role-name>version-used-by-data</ejb-relationship-role-name>
                            One
                            <relationship-role-source>
                            <ejb-name>DataVersionEJB</ejb-name>
                            </relationship-role-source>
                            <cmr-field>
                            <cmr-field-name>data</cmr-field-name>
                            <cmr-field-type>java.util.Collection</cmr-field-type>
                            </cmr-field>
                            </ejb-relationship-role>

                            <ejb-relationship-role>
                            <ejb-relationship-role-name>data-is-version</ejb-relationship-role-name>
                            Many
                            <relationship-role-source>
                            <ejb-name>DataEJB</ejb-name>
                            </relationship-role-source>
                            <cmr-field>
                            <cmr-field-name>dataVersion</cmr-field-name>
                            </cmr-field>
                            </ejb-relationship-role>
                            </ejb-relation>

                            JBossCMP:


                            <ejb-name>DataEJB</ejb-name>
                            <table-name>data</table-name>

                            <cmp-field>
                            <field-name>id</field-name>
                            <column-name>id</column-name>
                            <jdbc-type>INTEGER</jdbc-type>
                            <sql-type>INT</sql-type>
                            <not-null/>
                            </cmp-field>



                            <ejb-name>DataVersionEJB</ejb-name>
                            <table-name>data_version</table-name>

                            <cmp-field>
                            <field-name>id</field-name>
                            <column-name>id</column-name>
                            <jdbc-type>INTEGER</jdbc-type>
                            <sql-type>INT</sql-type>
                            <not-null/>
                            </cmp-field>


                            <ejb-relation>
                            <ejb-relation-name>Data-Data Version</ejb-relation-name>

                            <read-only>false</read-only>

                            <foreign-key-mapping/>

                            <ejb-relationship-role>
                            <ejb-relationship-role-name>version-used-by-data</ejb-relationship-role-name>

                            <fk-constraint>true</fk-constraint>

                            <key-fields>
                            <key-field>
                            <field-name>id</field-name>
                            <column-name>data_version_id</column-name>
                            </key-field>
                            </key-fields>

                            <read-ahead>
                            on-load
                            </read-ahead>
                            </ejb-relationship-role>

                            <ejb-relationship-role>
                            <ejb-relationship-role-name>data-is-version</ejb-relationship-role-name>

                            <fk-constraint>true</fk-constraint>

                            <key-fields/>

                            <read-ahead>
                            on-load
                            </read-ahead>
                            </ejb-relationship-role>
                            </ejb-relation>

                            Code sample:

                            DataVersionHome dataVersionHome = EJBUtil.getDataVersionHome();

                            DataVersion dataVersion;

                            try {
                            dataVersion = dataVersionHome.findBySomething(val);
                            } catch (FinderException e) {
                            try {
                            dataVersion = dataVersionHome.create(someData);
                            } catch (CreateException e2) {
                            e2.printStackTrace();
                            }
                            }

                            DataHome dataHome = EJBUtil.getDataHome();

                            try {
                            Data data = dataHome.create(someData);

                            // This throws following exception at getId()
                            System.err.println("XXX INERTED NEW DATA id=" + data.getId());

                            // This also throws following exception at setDataVersion() if I don't call getId above.
                            data.setDataVersion(dataVersion);
                            } catch (CreateException e) {
                            e.printStackTrace();
                            }

                            Stack Trace:

                            2003-02-21 15:01:16,969 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException, causedBy:
                            java.lang.IllegalArgumentException: Attempt to remove a lock for a null object
                            at org.jboss.ejb.BeanLockManager.removeLockRef(BeanLockManager.java:103)
                            at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:124)
                            at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
                            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
                            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
                            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
                            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
                            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
                            at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
                            at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:301)
                            at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
                            at $Proxy77.getId(Unknown Source)
                            at com.lds.controller.ejb.AgentControllerEJB.submitAgentModuleData(AgentControllerEJB.java:285)
                            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.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)
                            at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
                            at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
                            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
                            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
                            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
                            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
                            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
                            at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
                            at org.jboss.ejb.Container.invoke(Container.java:712)
                            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
                            at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
                            at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                            at java.lang.reflect.Method.invoke(Method.java:324)
                            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
                            at sun.rmi.transport.Transport$1.run(Transport.java:148)
                            at java.security.AccessController.doPrivileged(Native Method)
                            at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                            at java.lang.Thread.run(Thread.java:536)

                            • 11. Re: Attempt to remove a lock for a null object

                              Again, auto increment isn't supported until 3.2

                              Regards,
                              Adrian

                              • 12. Re: Attempt to remove a lock for a null object
                                cstach

                                I have upgraded to 3.2.0RC2 and I get a similar exception. Here is the stack trace now.

                                2003-02-22 19:34:10,222 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException, causedBy:
                                java.lang.IllegalArgumentException: Attempt to get lock ref with a null object
                                at org.jboss.ejb.BeanLockManager.getLock(BeanLockManager.java:80)
                                at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:99)
                                at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
                                at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:108)
                                at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
                                at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
                                at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
                                at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
                                at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:154)
                                at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:483)
                                at org.jboss.ejb.Container.invoke(Container.java:652)
                                at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:353)
                                at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
                                at $Proxy84.getId(Unknown Source)
                                at com.lds.controller.ejb.AgentControllerEJB.submitAgentModuleData(AgentControllerEJB.java:285)
                                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.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:629)
                                at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
                                at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
                                at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:108)
                                at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
                                at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
                                at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
                                at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
                                at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:154)
                                at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
                                at org.jboss.ejb.Container.invoke(Container.java:652)
                                at sun.reflect.GeneratedMethodAccessor69.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:549)
                                at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:338)
                                at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                at java.lang.reflect.Method.invoke(Method.java:324)
                                at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
                                at sun.rmi.transport.Transport$1.run(Transport.java:148)
                                at java.security.AccessController.doPrivileged(Native Method)
                                at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                                at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                                at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                                at java.lang.Thread.run(Thread.java:536)

                                • 13. Re: Attempt to remove a lock for a null object
                                  • 14. Re: Attempt to remove a lock for a null object
                                    cstach

                                    That seems to have cleared up that problem. Thanks!

                                    1 2 Previous Next