[JBoss Seam] - transactions all I try seems to fail
by dreuzel
I'm trying to follow advise and running nowhere
trying to set up a manual JTA transaction
All advice from the forums seems not to work or to fail (I probably attack it from the wrong angle )
I define JTA eplicitely in the persistence.xml
| <persistence-unit name="httpscan" transaction-type="JTA">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <!-- <jta-data-source>java:/httpscanDatasource</jta-data-source> -->
| <jta-data-source>java:/DevelopmentDS</jta-data-source>
| <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
| <property name="hibernate.jdbc.batch_size" value="20"/>
|
| <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
| <!-- use a file system based index -->
|
|
from the manual :
You could manage your transactions manually using the JTA UserTransaction (you could even implement your own declarative transaction management in a Seam interceptor). But most applications will use Seam managed transactions...
but all I do seems to fail.
| <core:init debug="@debug@" jndi-pattern="@jndiPattern@" transaction-management-enabled="false" />
| conversation-timeout="12000000" -->
| <core:manager concurrent-request-timeout="5000000"
| conversation-timeout="200000000"
| conversation-id-parameter="cid"/>
|
| <persistence:managed-persistence-context name="entityManager"
|
where and how do I get the Transaction Context ????
| try{
| iniCtx= new InitialContext();
| tx=(UserTransaction) iniCtx.lookup("java:comp/UserTransaction");
| } catch (Exception er )
| {errcod=er;
| String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
| log.error(env+" starting transaction failed "+ errmsg);
| }
|
Does not work since the Class Cast Fails and probaly
i can not correctly set java:comp/UserTransaction....
trying to use Seam fails as well
| tx=Transaction.instance();
| if (tx.getStatus()== Status.STATUS_ACTIVE) tx.commit();//commit a first transaction
| } catch (Exception er )
| {errcod=er;
| String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
| log.error(env+" starting transaction failed "+ errmsg);
| }
|
|
does not allow the transaction to begin
Tx.begin() Unupported error
I tried JPA but afer 1000 or so operations it fails on begin as well
can someone
pass me some example code
a) the Impors used to ensure I've the right TRANSACTION definitions
b) get the transaction context
c) the related tx.begin()
d) em.flush()
e) tx.comit()
f) ...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120094#4120094
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120094
18 years, 5 months
[JBossCache] - Re: Query related to jboss cache transaction
by arif.mohammed1@wipro.com
Hi manik,
Iam newbie to jboss cache, Please clarify me regarding my understanding.
I am using the POJO cache in clustered environment as follows.
public class POJO{
private int count;
private setCount(int count){
this.count = count;
}
private int getCount(){
return count;
}
}
A POJO object will be created and attached to the cache through a servlet in instance1 as follows
POJO obj = new POJO();
cache = PojoCacheFactory.createCache("replSync-service.xml", true);
cache.attach("monitor", obj); // I hope "/monitor" will be the FQN under which obj will be stored
Now 2 transactions t1,t2 will be trying to increment the value of count from instance2,instance3 respectively as follows
cache = PojoCacheFactory.createCache("replSync-service.xml", true);
POJO obj = (POJO) cache.find("monitor");
tx.begin();
int currentValue = obj.getCount();
currentValue++;
obj.setCount(currentValue);
tx.commit();
Now how can i guarantee that the count value is not over written by t2 which was written by t3
Can i acquire explicit lock on "/monitor" before starting a transaction so that no other transaction in other instance should be able to read/write on "/monitor" ?
Iam expecting that if isolation level "SERIALIZABLE" is used i don't need to bother about the above problem and repeat the statements in between begin,commit untill it succeeds. Am i right ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120091#4120091
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120091
18 years, 5 months