javax.ejb.RemoveException: Could not remove null
kristof Oct 18, 2001 10:56 AMHi,
I recently noticed an annoying problem while testing my application
and still got the same error when I test a trivial bean.
I'm using JBoss 2.4.1 and let XDoclet generate the ejb-related classes.
TestBean is just a simple CMP bean with one primary key field and one other persistent field.
When I insert an item that I've previously removed, I can't remove that item anymore.
The client can find the remote object for that item, but when ejbRemote() is invoked,
the primary key object seems to be reset to null.
I can still call the "get" and "set" methods on this item.
Here's the bean's ejbRemove method:
public void ejbRemove() throws RemoveException {
try {
System.out.println( "[Test] PK : " + entityContext.getPrimaryKey().toString() );
}
catch( Exception e ) {
System.out.println( "[Test] PK : " + e );
}
System.out.println( "[Test] ejbRemove()" );
}
The logfile shows that the resently removed items still get passivated:
2001-10-18 16:47:46,438 [Default] [TestServlet] adding new value...
2001-10-18 16:47:46,478 [Default] [Test] setEntityContext()
2001-10-18 16:47:46,478 [Default] [Test] ejbCreate()
2001-10-18 16:47:46,488 [Default] [Test] ejbStore()
2001-10-18 16:47:46,488 [Test] Scheduled passivation of bean Test with id = [.key.]
2001-10-18 16:47:46,488 [Default] [Test] ejbPassivate()
2001-10-18 16:47:46,488 [Container factory] Passivated bean Test with id = [.key.]
2001-10-18 16:47:49,012 [Default] [TestServlet] removing item [.key.]...
2001-10-18 16:47:49,022 [Default] [Test] setEntityContext()
2001-10-18 16:47:49,032 [Default] [Test] setEntityContext()
2001-10-18 16:47:49,032 [Default] [Test] ejbActivate()
2001-10-18 16:47:49,032 [Test] Activated bean Test with id = [.key.]
2001-10-18 16:47:49,042 [Default] [Test] ejbLoad()
2001-10-18 16:47:49,042 [Default] [Test] PK : [.key.]
2001-10-18 16:47:49,042 [Default] [Test] ejbRemove()
2001-10-18 16:47:49,052 [Test] Scheduled passivation of bean Test with id = [.key.]
2001-10-18 16:47:56,192 [Default] [TestServlet] adding new value...
2001-10-18 16:47:56,202 [Default] [Test] setEntityContext()
2001-10-18 16:47:56,202 [Default] [Test] ejbCreate()
2001-10-18 16:47:56,202 [Default] [Test] ejbStore()
2001-10-18 16:47:56,212 [Test] Scheduled passivation of bean Test with id = [.key.]
2001-10-18 16:47:59,076 [Default] [TestServlet] removing item [.key.]...
2001-10-18 16:47:59,096 [Default] [Test] setEntityContext()
2001-10-18 16:47:59,096 [Default] [Test] PK : java.lang.NullPointerException
2001-10-18 16:47:59,096 [Default] [Test] ejbRemove()
2001-10-18 16:47:59,106 [Test] Scheduled passivation of bean Test with id = [.key.]
2001-10-18 16:47:59,106 [Default] [TestServlet] remove : javax.ejb.RemoveException: Could not remove null
This is what happens in Hypersonic during that test:
INSERT INTO TEST VALUES('key','first insert')
DELETE FROM TEST WHERE KEY='key' AND CONTENT='first insert'
INSERT INTO TEST VALUES('key','first insert')
COMMIT
COMMIT
DELETE FROM TEST WHERE KEY='key' AND CONTENT='first insert'
COMMIT
INSERT INTO TEST VALUES('key','second insert')
DELETE FROM TEST WHERE KEY='key' AND CONTENT='second insert'
INSERT INTO TEST VALUES('key','second insert')
COMMIT
COMMIT
COMMIT
Is this maybe a silly problem that somebody can fix
or can anybody give me a clue about what the problem might be ...
Thanks,
Kristof