[JBoss Seam] - pass seam component to external ejb call causes exception [u
by leezard
Hi all again,
My next seam problem is: I have an external ejb, I call to perform some operations. I have also set of classes delivered in separate jar. One of those classes was marked as seam component I couldn't do it via annotation so I added:
<component name="request" class="com.jboss.seam.test.TestTransactionRequest" auto-create="true" scope="CONVERSATION"/>
Now my bean code is:
| @Stateful
| @Name("processTransactionRevoke")
| @Scope(ScopeType.CONVERSATION)
| public class ProcessTransactionRevokeBean implements ProcessTransactionRevoke {
|
| private boolean revokeSuccesful;
|
| @Logger
| private Log logger;
|
| @RequestParameter
| String transactionId;
|
| @In
| TestTransactionRequest request;
|
| @EJB
| TransactionRevokeService service;
|
| @Begin(pageflow="transactionRevoke")
| public void begin() {
| logger.info("Begin called");
| request.setParentTransaction(transactionId);
| logger.info("Parent trid: " + request.getParentTransaction());
| }
|
| public void revokeTransaction() {
| logger.info("processing");
| try {
| logger.info("Parent trid: " + request.getParentTransaction());
| revokeService.revokeTransaction(revokeRequest, false);
| revokeSuccesful = true;
| logger.info("succeed");
| } catch(Exception e) {
| logger.info("failed");
| e.printStackTrace();
| revokeSuccesful = false;
| }
| }
|
| public boolean isRevokeSuccesful() {
| return revokeSuccesful;
| }
|
| @Remove @Destroy
| public void destroy() {}
| }
|
Logs say that request is initialized and has parentTransaction set properly, but when I pass request to service.revokeTransaction method I get an exception saying:
| 22:44:03,952 ERROR [STDERR] javax.ejb.EJBTransactionRolledbackException
| 22:44:03,952 ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 22:44:03,952 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| 22:44:03,952 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 22:44:03,952 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 22:44:03,952 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 22:44:03,952 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
| 22:44:03,952 ERROR [STDERR] at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:79)
| 22:44:03,952 ERROR [STDERR] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:70)
| 22:44:03,952 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| 22:44:03,952 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
| 22:44:03,952 ERROR [STDERR] at $Proxy89.revokeTransaction(Unknown Source)
| ...
| 22:44:03,962 ERROR [STDERR] Caused by: java.lang.NullPointerException
| 22:44:03,962 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.markDirty(JavaBeanInterceptor.java:94)
| 22:44:03,962 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:79)
| 22:44:03,962 ERROR [STDERR] at com.jboss.seam.test.TestTransactionRequest_$$_javassist_7.getParentTransaction(TestTransactionRevokeRequest_$$_javassist_7.java)
| 22:44:03,962 ERROR [STDERR] at com.jboss.seam.test.bean.TransactionRevokeServiceBean.revokeTransaction(TransactionRevokeServiceBean.java:67)
|
What's wrong with it?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056662#4056662
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056662
18Â years, 10Â months
[Persistence, JBoss/CMP, Hibernate, Database] - Locking behaviour in Hibernate - Must be missing something.
by jpebe
Hi there at JBoss Forums,
I am possibly missing something very obvious, but after reading loads of material I still cannot figure it out - so I'd thought I'd ask the experts.
I have the following method in a stateless session bean (the entity manager is injected)
| public void test(String id, String value, long sleep) {
|
| SimpleTestEntityBean bean = em.find(SimpleTestEntityBean.class, id);
|
| try {
| Thread.sleep(sleep);
| } catch (InterruptedException exception) {
| exception.printStackTrace();
| }
| System.out.println(id + " setting state to " + value);
| bean.setValue(value);
|
| }
|
Now this works fine on its own and the SimpleTestEntity 'value' field is updated accordingly.
My problem is when I start two concurrent threads which call this method simultaneously.
Something like
| Thread firstRunner = new Thread() {
| public void run() {
| SimpleTestFacadeAccess.getInstance().test("1", "BOGUS", 5000);
| }
| };
| Thread secondRunner = new Thread() {
| public void run() {
| SimpleTestFacadeAccess.getInstance().test("1", "OTHER_BOGUS", 2000);
| }
| };
|
| System.out.println ("Starting A simple");
| firstRunner.start();
|
| try {
| Thread.sleep(750);
| } catch (InterruptedException exception) {
| exception.printStackTrace();
| }
|
| System.out.println ("Starting B simple");
| secondRunner.start();
|
The behaviour which I would like (which was default in 4.0.1, EJB2.1 not so many moons ago) is that the first thread which enters the session bean method takes control and locks on the entities it is going to use. So when a second thread enters the method (and the first thread is still sleeping say) the second thread has to wait for the first to finish.
With the default behaviour - I get the lost update problem.
x = 10
Thread a reads x (10)
Thread b reads x (10) (a has not read/write locked x)
Thread a writes x=x+1 (11)
Thread b writes x=x+2 (12) (b has old x)
Thread a commits; (x = 11)
Thread b commits; (x = 12)
... BUT x (should be) 13!
Many Thanks
Jean-Paul, Malta.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056657#4056657
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056657
18Â years, 10Â months
[JBoss Seam] - [ANNOUNCE] Recent JSFCentral Articles (JBoss, Craig McClanah
by kito99
Hello everyone,
If you haven't checked out JSFCentral recently, you may want to read one of our recent exclusive articles:
Designing User Interfaces with JSF, Dreamweaver, and the JSFToolbox
Learn how to use JSFToolbox for Dreamweaver, a Web development tool that connects these two disciplines and promotes synergy between UI design and Java development teams.
==
Interview with Craig McClanahan
Craig McClanahan, Sun's Web 2.0 Architect for its Java Tools division and lead for Apache's Shale project, talks about JSF, Shale, development tools, and dynamic languages.
==
JBoss: The JavaServer Faces Powerhouse?
JSFCentral editor-in-chief Kito D. Mann discusses JBoss and their involvement in the JavaServer Faces community.
Stay tuned for more new articles, including In the Trenches case studies.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kito D. Mann - Author, JavaServer Faces in Action
www.virtua.com - JSF/Java EE consulting, training, and mentoring
www.jsfcentral.com - JavaServer Faces FAQ, news, and info
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056656#4056656
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056656
18Â years, 10Â months