[JBossCache] - Re: Cache v2.0 Alpha2: Optimistic Locking + Explicit Version
by chasta
Yep, I meant explicit versioning, sorry about that...
What seems to happen (at least one case when this has occurred) is that a node gets added, causing an update of its father node. On that point (the put() ) the WorkspaceNode receives the correct version and the 'versioningImplicit' flag is correctly set to false.
However, on commit(), the same node is fetched, and while the version object remains the same (correct) one, the flag is reset to 'true'.
One simple example for a specific operation that causes this is adding a child node using Node.addChild() (to a node which happens to reside two levels under the root node). When working w/o an open transaction (e.g., in auto-transaction per operation mode), this operation fails with the following stack trace:
| 2007-01-17 09:25:53,579 1728 WARN [org.jboss.cache.interceptors.TxInterceptor] (main:) Commit failed. Clearing stale locks.
| 2007-01-17 09:25:53,582 1731 ERROR [org.jboss.cache.interceptors.OrderedSynchronizationHandler] (main:) failed calling afterCompletion() on TxInterceptor.LocalSynchronizationHandler(gtx=GlobalTransaction:<null>:9, tx=org.jboss.cache.transaction.DummyTransaction@27cd63)
| java.lang.RuntimeException: Commit failed.
| at org.jboss.cache.interceptors.TxInterceptor.runCommitPhase(TxInterceptor.java:712)
| at org.jboss.cache.interceptors.TxInterceptor$RemoteSynchronizationHandler.afterCompletion(TxInterceptor.java:996)
| at org.jboss.cache.interceptors.TxInterceptor$LocalSynchronizationHandler.afterCompletion(TxInterceptor.java:1092)
| at org.jboss.cache.interceptors.OrderedSynchronizationHandler.afterCompletion(OrderedSynchronizationHandler.java:82)
| at org.jboss.cache.transaction.DummyTransaction.notifyAfterCompletion(DummyTransaction.java:285)
| at org.jboss.cache.transaction.DummyTransaction.commit(DummyTransaction.java:75)
| at org.jboss.cache.transaction.DummyBaseTransactionManager.commit(DummyBaseTransactionManager.java:78)
| at org.jboss.cache.interceptors.TxInterceptor.handleNonTxMethod(TxInterceptor.java:292)
| at org.jboss.cache.interceptors.TxInterceptor.invoke(TxInterceptor.java:126)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:75)
| at org.jboss.cache.interceptors.CacheMgmtInterceptor.invoke(CacheMgmtInterceptor.java:151)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:75)
| at org.jboss.cache.interceptors.InvocationContextInterceptor.invoke(InvocationContextInterceptor.java:66)
| at org.jboss.cache.CacheImpl.invokeMethod(CacheImpl.java:3750)
| at org.jboss.cache.CacheImpl.put(CacheImpl.java:1521)
| at org.jboss.cache.UnversionedNode.addChild(UnversionedNode.java:372)
| at com.mazeppa.yph.tests.CustomVersionTest.phaseIn(CustomVersionTest.java:31)
| Caused by: java.lang.ClassCastException: com.mazeppa.yph.tests.CustomVersion cannot be cast to org.jboss.cache.optimistic.DefaultDataVersion
| at org.jboss.cache.interceptors.OptimisticValidatorInterceptor.commit(OptimisticValidatorInterceptor.java:212)
| at org.jboss.cache.interceptors.OptimisticValidatorInterceptor.invoke(OptimisticValidatorInterceptor.java:68)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:75)
| at org.jboss.cache.interceptors.OptimisticLockingInterceptor.invoke(OptimisticLockingInterceptor.java:105)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:75)
| at org.jboss.cache.interceptors.NotificationInterceptor.invoke(NotificationInterceptor.java:22)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:75)
| at org.jboss.cache.interceptors.TxInterceptor.handleCommitRollback(TxInterceptor.java:655)
| at org.jboss.cache.interceptors.TxInterceptor.runCommitPhase(TxInterceptor.java:698)
| ... 35 more
| 2007-01-17 09:25:53,588 1737 WARN [org.jboss.cache.interceptors.TxInterceptor] (main:) Commit failed. Clearing stale locks.
| 2007-01-17 09:25:53,589 1738 ERROR [org.jboss.cache.interceptors.OrderedSynchronizationHandler] (main:) failed calling afterCompletion() on TxInterceptor.LocalSynchronizationHandler(gtx=GlobalTransaction:<null>:11, tx=org.jboss.cache.transaction.DummyTransaction@4298e)
| java.lang.RuntimeException: Commit failed.
| at org.jboss.cache.interceptors.TxInterceptor.runCommitPhase(TxInterceptor.java:712)
| at org.jboss.cache.interceptors.TxInterceptor$RemoteSynchronizationHandler.afterCompletion(TxInterceptor.java:996)
| at org.jboss.cache.interceptors.TxInterceptor$LocalSynchronizationHandler.afterCompletion(TxInterceptor.java:1092)
| at org.jboss.cache.interceptors.OrderedSynchronizationHandler.afterCompletion(OrderedSynchronizationHandler.java:82)
| at org.jboss.cache.transaction.DummyTransaction.notifyAfterCompletion(DummyTransaction.java:285)
| at org.jboss.cache.transaction.DummyTransaction.commit(DummyTransaction.java:75)
| at org.jboss.cache.transaction.DummyBaseTransactionManager.commit(DummyBaseTransactionManager.java:78)
| at org.jboss.cache.interceptors.TxInterceptor.handleNonTxMethod(TxInterceptor.java:292)
| at org.jboss.cache.interceptors.TxInterceptor.invoke(TxInterceptor.java:126)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:75)
| at org.jboss.cache.interceptors.CacheMgmtInterceptor.invoke(CacheMgmtInterceptor.java:151)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:75)
| at org.jboss.cache.interceptors.InvocationContextInterceptor.invoke(InvocationContextInterceptor.java:66)
| at org.jboss.cache.CacheImpl.invokeMethod(CacheImpl.java:3750)
| at org.jboss.cache.CacheImpl.put(CacheImpl.java:1521)
| at org.jboss.cache.UnversionedNode.addChild(UnversionedNode.java:372)
| at com.mazeppa.yph.tests.CustomVersionTest.phaseIn(CustomVersionTest.java:31)
| Caused by: java.lang.ClassCastException: com.mazeppa.yph.tests.CustomVersion cannot be cast to org.jboss.cache.optimistic.DefaultDataVersion
| at org.jboss.cache.interceptors.OptimisticValidatorInterceptor.commit(OptimisticValidatorInterceptor.java:212)
| at org.jboss.cache.interceptors.OptimisticValidatorInterceptor.invoke(OptimisticValidatorInterceptor.java:68)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:75)
| at org.jboss.cache.interceptors.OptimisticLockingInterceptor.invoke(OptimisticLockingInterceptor.java:105)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:75)
| at org.jboss.cache.interceptors.NotificationInterceptor.invoke(NotificationInterceptor.java:22)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:75)
| at org.jboss.cache.interceptors.TxInterceptor.handleCommitRollback(TxInterceptor.java:655)
| at org.jboss.cache.interceptors.TxInterceptor.runCommitPhase(TxInterceptor.java:698)
| ... 35 more
|
|
However, we've observed this on other cases as well, cases which involve transactions and are more difficult to reproduce.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002658#4002658
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002658
19 years, 3 months
[JBoss Seam] - Re: Seam selectItems ignores label tag
by hubaer
Ok, I tried it and it works. But it wasn't exact that what I really had in mind.
I try to explain it a little more:
With your example I can only lookup for message keys that has the same name as the value of the attribute.
If I have languages with the iso codes 'EN', 'DE' or 'FR' the EL expression will look for messages keys with the names of the codes. So the keys have to be the value of the attribute:
DE = german
| EN = english
| FR = french
But if I have also countries like 'DE' or 'FR', the message key referres for this both also to the language name.
So I would put a prefix to the message keys and access them from the UI component. Here an snip of a resource bundle:
| languagename.DE = german
| languagename.EN = english
| languagename.FR = french
| country.DE = Germany
| country.FR = France
| country.UK = United Kingdom
|
So I would write something like 'languagename.' + language.isocode or 'country.' + country.isocode in a tag.
Is this possible?
Regards
Marco
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002651#4002651
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002651
19 years, 3 months
[JBoss Seam] - The persistence manager doesnt find EJB3 entities when testc
by littlewing1112
Hello,
I http://jira.jboss.org/jira/browse/JBSEAM-570 but gavin said this is not a bug so, that s my problem:
The samples bundled (expecially BookingUnitTest) with the distribution work but not in my environment:
1- I splitted the sample in order to "be mavenized" (I added the dependencies bundled in the release of seam in my repository (eg. jboss-third-party)
2- I changed the database to postgreSQL
3- add one more table
4- move queries to namedqueries
Maven separates classes build directory and test build directory.
I have this directory layout:
target/classes --> EJB builds
target/test-classes
/ejb-container
testcases classes built
/micro-container
/resources files
When I start a test which seems like BookingTest (in sample booking) everything works fine, but when I start BookingUnitTest, the persistencemanager doesnt find the entity
I have this error:
| javax.persistence.PersistenceException: org.hibernate.hql.ast.QuerySyntaxException: Hotel is not map
| ped [from Hotel]
| at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.
| java:567)
| at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:79)
| at org.jboss.seam.example.booking.test.BookingUnitTest.testHotelBooking(BookingUnitTest.java:61)
| Caused by: org.hibernate.hql.ast.QuerySyntaxException: Hotel is not mapped [from Hotel]
| at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:
| 158)
| at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
| at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
| at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:267)
| at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3049)
| at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)
| at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
| at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
| at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
|
You http://jira.jboss.org/jira/secure/attachment/12313130/booking.tgz
Thanks for your help!!
Regards,
Alexandre Touret
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002649#4002649
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002649
19 years, 3 months
[EJB 3.0] - Stateful Bean and the database commit
by konstantin.ermakov
Hi!
I have the following stateful bean:
|
| public class MyStatefulBean implements MyStatefulBeanI, SessionSynchronization {
|
| @PersistenceUnit(unitName = "db")
| public EntityManagerFactory factory;
|
| public MyEntity getObject( int id ) throws Exception {
| EntityManager m = factory.createEntityManager();
| return m.find(MyEntity.class, id);
| }
|
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public MyEntity update( MyEntity newEntity ) throws Exception {
| EntityManager m = factory.createEntityManager();
| oldEntity e = m.find(MyEntity.class, id);
|
| e.setAttribute1( newEntity.getAttribute1() );
| ...
| ...
| m.flush();
| m.clear();
| m.close();
| }
|
| public void afterCompletion(boolean flag) throws EJBException, RemoteException {
| if( flag == true ) {
| sendJMSMessage()
| }
| }
|
| .....
|
| }
|
|
As far as I understood, after update() it is not guaranteed, that the data is in database and commit event already happened. So, as I have the fat clients it can be the case, that after update() was called, getObject() still returns the old entity.
My question is - is it guarateed, that after the afterCompletion() method the database commit already happened, and it is safe to call getObject() to receive the new data?
Thank you,
Konstantin
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002646#4002646
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002646
19 years, 3 months
[JBoss Seam] - Combining EntityHome and session beans
by lightbulb432
If there's CRUD functionality for which I'd like to use EntityHome, but the user functionality has more complex validation than simply getting the #{person.firstName} and #{person.lastName} fields as entered in a form and doing a #{personHome.persist} (as in the the example given in ch. 14 of the Seam documentation), how would I do this?
Would the complex validation and other things be included in EntityHome, or would it be a separate session bean? If the latter, how would you get the session bean and EntityHome to work together to accomplish this?
An example is below:
<div>First name: <h:inputText value="#{person.firstName}"/></div>
| <div>Last name: <h:inputText value="#{person.lastName}"/></div>
|
| <h:commandButton value="Create Person" action="#{myPersonBean.persistPerson}"/>
|
|
(where "person" is a factory on the EntityHome)
If the persistPerson() method has several validation and other things going on within the session bean, and you can't simply do a personHome.persist in its place, is EntityHome still useful? What's the best way to approach a situation like this? Should everything be done in the EntityHome, or should nothing be done? Or if both session beans and EntityHome are to be used, how would you divide up the responsibilities between the two?
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002635#4002635
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002635
19 years, 3 months