Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
JSP - A mailing list about Java Server Pages specification and reference
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
- Problem with Threads and Transactional context

- Problem with Threads and Transactional context

2007-07-16       - By zerok

 Back
Hi guys!

I've done the same post on Seam's, because I thought that would be a good place
to put the question together with others posts with similar problem. As it is
indeed an EJB3 related problem, I make the same post here too. So please don't
be mad with me because this problem is taking away my sleep and may cost my job
.

Here is the post:
-- ---- ---- ---- ---
I'm using threads inside a stateless bean and I cannot persist anything without
having that annoying message that states I can only use transaction manager
inside a transactional context.
I've tried to make a busy-wait on my stateless bean so I can assure my bean
will be alive until the very moment my thread needs the entityManager but when
the execution reaches the entityManeger.merge( object ) an exception is risen.
The story:

I have a jboss-4 (See http://oss-4.ora-code.com).0.5.GA with an upgrade on my original Javassist. Now I have
javassist-3 (See http://ist-3.ora-code.com).4 due to issues with threads.
My application needs to perform a fork in execution flow split in three parts.
Both of them are created as threads and are observed in normal-fashion-way
observer pattern, where the Stateless Bean is the observer.
I have a hunch that my bean life-cycle ends before my first thread finishes, so
the entityManager looses it transactional context.
Can anybody point a blueprint for creating a structure to support such a
business demand?

Here some parts of my code so you can place yourself. This code comes with only
one thread. The original one has three, all like this one.

@(protected)(TransactionManagementType.CONTAINER)
public @(protected)(name = "TempoRealRN") class TempoRealRNBean extends
IntegratorCommonBehavior implements TempoRealRN, Observer {

@(protected)(beanName = "GenericoDAO")
GenericoDAO genericoDAO;

@(protected) private EntityManager entityManager;

private static final Log log = LogFactory.getLog(TempoRealRNBean.class);

...
public void processar(CommonController controladorComum) throws
IntegratorException {

super.setEntityManager(this.entityManager);

tCorFrente = new ThreadCorFrente(controladorComum, this, log, dto,
nomeThreadFrente, grupoFrente);
tCorFrente.addObserver(this);
tCorFrente.start();
}// ends of: public void processar(...) ....

/*
* receives notification from thread state change and executes the proper action
to acomplish bussiness rule goals.
*
*/
public void update(Object o) {

//perform some state tests

//then try to persist.
//at this point an exception is risen
this.entityManager.merge( object );

}//ends public void update(Object o)

}//ends class

The exception risen is:
-- ---- ---- ---- ---- ---
17:01:47,480 ERROR [STDERR] Caused by: javax.persistence
.TransactionRequiredException: EntityManager must be access within a transaction
17:01:47,480 ERROR [STDERR] at org.jboss.ejb3.entity
.ManagedEntityManagerFactory.verifyInTx(ManagedEntityManagerFactory.java:150)
17:01:47,480 ERROR [STDERR] at org.jboss.ejb3.entity
.TransactionScopedEntityManager.merge(TransactionScopedEntityManager.java:180)
17:01:47,480 ERROR [STDERR] at wm.integrator.negocio.temporeal.impl
.TempoRealRNBean.persistirFrente(TempoRealRNBean.java:485)

It would be great if some good soul could enlight me regarding on how to use
the proper pattern for observing threads and how I can make this persistence
work.
Thank you all just for being patient enough to read this extensive post.
I apologize myself for any English grammar misuse or misspell as English is not
my 1st language. I'm from Brazil.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic
&p=4064753#4064753

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode
=reply&p=4064753
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user

©2008 junlu.com - Jax Systems, LLC, U.S.A.