Bugs item #504481, was opened at 2002-01-16 17:58
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=504481&group_id=22866

Category: JBossCMP
Group: v2.4 (stable)
Status: Closed
Resolution: Fixed
Priority: 9
Submitted By: Shravan (cskreddy74)
Assigned to: Bill Burke (patriot1burke)
Summary: INSERTING AN ALREADY EXISTING BEAN

Initial Comment:
Hi,

I get this error ehen I am trying to insert the 
record into the database form the bean, basically I 
deleted the record from the database manually and 
tried to insert it from the bean, I read the article 
from the previous postings, but could not figure out 
how it works......
please have a look at the smalll code of the CMP bean 
which is attached as .zip files and help me .....

javax.transaction.TransactionRolledbackException: 
INSERTING AN ALREADY EXISTING BEAN, ID = 1; nested 
exception is:
        java.lang.IllegalStateException: INSERTING AN 
ALREADY EXISTING BEAN, ID = 1



Thanks in advance
Shravan



----------------------------------------------------------------------

Comment By: Halil-C. G�rsoy (che---)
Date: 2002-08-20 16:56

Message:
Logged In: YES 
user_id=455149

i checked again the code and found this:

Yes, we try sometimes creating entitys with the same PK. In
this cases, a CreateException was thrown by create(), which
we've handled.

create() throws now (2.4.8.) a RemoteException instead of
the CreateExcpetion (2.4.4).

----------------------------------------------------------------------

Comment By: Sacha Labourey (slaboure)
Date: 2002-08-19 22:03

Message:
Logged In: YES 
user_id=95900

In fact, I cannot see the problem.

With commit option C, the container has no way to know if 
the bean already exists in the DB or not (because it cannot 
check in the cache if a bean with the same PK already 
exists). Consequently, it tries to do the insert, but Oracle 
barfs because a row with this PK *already exists* in the DB. 
=> the bean has *not* been removed previously.

Then, when you switch to commit option A, the same use 
case happens and as your bean has *not* been removed 
previously, it is the application server *directly* that is able to 
say: such a bean already exists.

I think you should check your code.



----------------------------------------------------------------------

Comment By: Halil-C. G�rsoy (che---)
Date: 2002-08-19 18:01

Message:
Logged In: YES 
user_id=455149

OK, here some stacktraces.
This is with commit option "A":

[13:04:52,592,STDOUT]
javax.transaction.TransactionRolledbackException: INSERTING
AN ALREADY EXISTING BEAN, ID = code=LH, flag=1, number3615,
line1, imported 2002-08-19 13:04:52.52; nested exception is:
        java.lang.IllegalStateException: INSERTING AN
ALREADY EXISTING BEAN, ID = code=LH, flag=1, number3615,
line1, imported 2002-08-19 13:04:52.52
[13:04:52,593,STDOUT]   at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:166)
[13:04:52,593,STDOUT]   at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:478)
[13:04:52,594,STDOUT]   at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
[13:04:52,595,STDOUT]   at
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:102)
[13:04:52,595,STDOUT]   at
org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:103)
[13:04:52,596,STDOUT]   at
org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:429)
[13:04:52,597,STDOUT]   at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:458)
[13:04:52,597,STDOUT]   at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invokeHome(HomeProxy.java:237)
[13:04:52,598,STDOUT]   at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:182)
[13:04:52,598,STDOUT]   at $Proxy59.create(Unknown Source)
[13:04:52,600,STDOUT]   at
com.xxx.xxx.fp.imp.ImportStatusBean.loadData(Unknown Source)
[13:04:52,601,STDOUT]   at
com.xxx.xxx.fp.imp.ImportStatusBean.importStatus(Unknown Source)
[13:04:52,602,STDOUT]   at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[13:04:52,603,STDOUT]   at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[13:04:52,603,STDOUT]   at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[13:04:52,604,STDOUT]   at
java.lang.reflect.Method.invoke(Method.java:324)
[13:04:52,604,STDOUT]   at
org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:542)
[13:04:52,605,STDOUT]   at
org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:299)
[13:04:52,616,STDOUT]   at
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:82)
[13:04:52,616,STDOUT]   at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
[13:04:52,617,STDOUT]   at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
[13:04:52,618,STDOUT]   at
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:286)
[13:04:52,618,STDOUT]   at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:506)
[13:04:52,619,STDOUT]   at
org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:335)
[13:04:52,620,STDOUT]   at
org.jboss.ejb.plugins.jrmp.interfaces.StatelessSessionProxy.invoke(StatelessSessionProxy.java
[13:04:52,620,STDOUT]   at
org.jboss.ejb.plugins.jrmp.interfaces.StatelessSessionProxy.invoke(StatelessSessionProxy.java:123)
[13:04:52,621,STDOUT]   at $Proxy20.importStatus(Unknown Source)
[13:04:52,621,STDOUT]   at
com.xxx.xxx.fpcontr.ImportScheduler.perform(Unknown Source)
[13:04:52,622,STDOUT]   at
com.fraport.b2c.utils.Scheduler6$Listener.handleNotification(Scheduler6.java:725)
[13:04:52,623,STDOUT]   at
com.sun.management.jmx.MBeanServerNotificationListener.handleNotification(MBeanServerNotificationListener.java:48)
[13:04:52,623,STDOUT]   at
javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:142)
[13:04:52,624,STDOUT]   at
javax.management.timer.Timer.sendNotification(Timer.java:1119)
[13:04:52,625,STDOUT]   at
javax.management.timer.Timer.notifyAlarmClock(Timer.java:1089)
[13:04:52,625,STDOUT]   at
javax.management.timer.TimerAlarmClock.run(Timer.java:1165)
[13:04:52,626,STDOUT] Caused by:
java.lang.IllegalStateException: INSERTING AN ALREADY
EXISTING BEAN, ID = airlineCode=LH, flag=1,
flightNumber3615, line1, imported 2002-08-19 13:04:52.52
[13:04:52,627,STDOUT]   at
org.jboss.ejb.plugins.AbstractInstanceCache.insert(AbstractInstanceCache.java:218)
[13:04:52,628,STDOUT]   at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:161

This is with commit option "C":

[16:06:54,386,JAWSPersistenceManager] java.sql.SQLException:
ORA-00001: unique constraint (DUMMY.BBBFP_LOCATIONS
_PK) violated
ORA-06512: at "DUMMY.BBBFP_LOCATIONS_VIEW_IIR", line 3
ORA-04088: error during execution of trigger
'DUMMY.BBBFP_LOCATIONS_VIEW_IIR'

[16:06:54,388,JAWSPersistenceManager] Could not create entity:
ORA-06512: at "DUMMY.BBBFP_LOCATIONS_VIEW_IIR", line 3
ORA-04088: error during execution of trigger
'DUMMY.BBBFP_LOCATIONS_VIEW_IIR'

        at
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
        at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
        at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
        at
oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
        at
oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
        at
oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1602)
        at
oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1527)
        at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2045)
        at
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:395)
        at
org.jboss.pool.jdbc.PreparedStatementInPool.executeUpdate(PreparedStatementInPool.java:82)
        at
org.jboss.ejb.plugins.jaws.jdbc.JDBCUpdateCommand.executeStatementAndHandleResult(JDBCUpdateCommand.java:49)
        at
org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand.jdbcExecute(JDBCCommand.java:156)
        at
org.jboss.ejb.plugins.jaws.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:143)
        at
org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.createEntity(JAWSPersistenceManager.java:129)
        at
org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:239)
        at
org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:640)
        at
sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:867)
        at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:234)
        at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:147)
        at
org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:97)
        at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:142)
        at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:142)
        at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:478)
        at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
        at
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:102)
        at
org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:103)
        at
org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:429)
        at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:458)
        at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invokeHome(HomeProxy.java:237)
        at
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:182)
        at $Proxy60.create(Unknown Source)
        at
com.xxx.xxx.fp.imp.ImportSchedulesBean.addLocalAirport(ImportSchedulesBean.java:370)
        at
com.xxx.xxx.fp.imp.ImportSchedulesBean.importSchedules(ImportSchedulesBean.java:541)
        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:542)
        at
org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:299)
        at
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:82)

        at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
        at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
        at
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:286)
        at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:506)
        at
org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:335)
        at
org.jboss.ejb.plugins.jrmp.interfaces.StatelessSessionProxy.invoke(StatelessSessionProxy.java:123)
        at $Proxy43.importSchedules(Unknown Source)
        at
com.xxx.xxx.zz.fp.StartImportAction.perform(StartImportAction.java:76)
        at
com.xxx.xxx.controller.AbstractControllerServlet.prozessAction(AbstractControllerServlet.java:31)
        at
com.xxx.xxx.controller.BasicAbstractControllerServlet.processRequest(BasicAbstractControllerServlet.java:

351)
        at
com.xxx.xxx.controller.BasicAbstractControllerServlet.doPost(BasicAbstractControllerServlet.java:411)
        at
com.xxx.xxx.controller.flightplanner.FlightplannerControllerServlet.doPost(FlightplannerControllerServlet

.java:84)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
        at
org.apache.tomcat.core.Handler.service(Handler.java:287)
        at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
        at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
        at
org.apache.tomcat.service.connector.Ajp13ConnectionHandler.processConnection(Ajp13ConnectionHandler.java:160)

        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
        at java.lang.Thread.run(Thread.java:536)

Also, we see a huge count of warnings like this:

[15:53:40,228,XAConnectionFactory] XAConnectionImpl:
org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@1fd6bea has
no current tx![15:53:47,795,XAConnectionFactory]
XAConnectionImpl:
org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@1fd6bea has
no current tx!
[15:53:54,234,XAConnectionFactory] XAConnectionImpl:
org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@1fd6bea has
no current tx!
[15:53:54,346,XAConnectionFactory] XAConnectionImpl:
org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@1fd6bea has
no current tx!

The same ear, the same DB, but with JBoss 2.4.4 runs fine!
We use the same jboss.jcml, the same config, the same
JDBC-Driver etc. 




----------------------------------------------------------------------

Comment By: Sacha Labourey (slaboure)
Date: 2002-08-19 16:41

Message:
Logged In: YES 
user_id=95900

I really don't think the problem you see is not related to this 
bug. The error message is by no mean a JBoss message but 
an Oracle message (ORA-00001, etc.). Consequently, your 
application seems to violate constraint defined in your Oracle 
schema.

If you really think your problem is related to this bug, please 
provide detailed informations, stack traces, etc.

----------------------------------------------------------------------

Comment By: Halil-C. G�rsoy (che---)
Date: 2002-08-19 16:31

Message:
Logged In: YES 
user_id=455149

Under 2.4.8 we encounter this problem.

Then we use commit option "C", we become other exceptions:

[16:06:54,076,STDOUT] INFO 2002.08.19 16:06:54
ImportSchedulesBean.importSchedules: Data loaded.
[16:06:54,386,JAWSPersistenceManager] java.sql.SQLException:
ORA-00001: unique constraint (xyz.zzz_PK) violated
ORA-06512: at "xyz.zzz_VIEW_IIR", line 3
ORA-04088: error during execution of trigger 'xyz.zzz_VIEW_IIR'

Starting the same application under 2.4.4 we dont see these
problems!


----------------------------------------------------------------------

Comment By: Sacha Labourey (slaboure)
Date: 2002-07-30 17:28

Message:
Logged In: YES 
user_id=95900

Fixed in Branch_2_4 i.e. JBoss > 2.4.7

----------------------------------------------------------------------

Comment By: Sacha Labourey (slaboure)
Date: 2002-07-29 20:04

Message:
Logged In: YES 
user_id=95900

A bug does exist (even when using commit option C.)

In commit option C, when you call home.create, 
EntityInstanceInterceptor.invokeHome adds the bean to the 
cache (container.getInstanceCache().insert(ctx);). Correct. 
Then, when reaching 
EntitySynchronizationInterceptor.invokeHome (after the 
getNext().invokeHome(mi) call), the context, through a 
callback wrapper, is registered with the current transaction.
Thus, when InstanceSynchronization.afterCompletion is 
called by the TM, the bean is correctly removed from the 
cache (because we are in commit option C). Correct.

But if you then do a call *without* a transaction (typical for 
read-only calls, I know we should always use transaction), 
such as:
 home.findByPrimaryKey(myId).getData();

EntityInstanceInterceptor will add the bean to the cache but, 
as no transaction is available, no InstanceSynchronization 
can/is be registered with the transaction. Consequently, the 
cache-cleaning code is never ran.

Now, if you delete your bean directly in the DB (through 
SQL), and then try to re-create the bean by using 
home.create, the bean is found in the cache and you receive 
the "INSERTING AN ALREADY EXISTING BEAN" message.

Consequently, the "cache-cleaning" code must be also 
executed in one of these two interceptors directly after the 
invoke/invokeHome calls (and not in a callback object) when 
there is no transaction associated with the call and using 
commit option C.


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2002-03-13 18:07

Message:
Logged In: NO 

It's correct: deleting manually it shouldn't work.
But it happens to me using the remove() and after a create
() on a BMP entitybean, so all the create/remove is done by 
the EJB. 

I posted my problem at http://main.jboss.org/thread.jsp?
forum=47&thread=10642

Thanks & regards,
Luigi.


----------------------------------------------------------------------

Comment By: Christian Riege (lqd)
Date: 2002-01-17 16:15

Message:
Logged In: YES 
user_id=176671

this is not a bug, CLOSING INVALID. Using commit-option C
does the job.

----------------------------------------------------------------------

Comment By: Bill Burke (patriot1burke)
Date: 2002-01-17 16:04

Message:
Logged In: YES 
user_id=176497

I think using commit option 'C' will work.  Look in 
standardjboss.xml for commit-option  it is 'A' by default.  
Commit option 'C' will passivate the Entity Bean at the end 
of every transaction.

----------------------------------------------------------------------

Comment By: Shravan (cskreddy74)
Date: 2002-01-17 15:38

Message:
Logged In: YES 
user_id=260502

hi patriot1burke, 

I have a scenario wherein my database is accessed from an 
legacy system or from an other no-java application which 
is updating hte database constantly and when data is 
changed in database how do I make to reflect in the jboss 
server automatically... I mean atleast how to reduce teh 
cache time or how to disable the caching etc.....




----------------------------------------------------------------------

Comment By: Bill Burke (patriot1burke)
Date: 2002-01-16 21:49

Message:
Logged In: YES 
user_id=176497

If you create a bean through EJB, then delete it manually 
from the database, then try to create it again you will 
fail in this way because JBoss still has the bean in cache.

I'm closing this bug.  It is not a bug.  You are using it 
incorrectly.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=504481&group_id=22866


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to