This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes BEA/Weblogic and the fly likes Problem in Join() with user threads in weblogic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Problem in Join() with user threads in weblogic" Watch "Problem in Join() with user threads in weblogic" New topic
Author

Problem in Join() with user threads in weblogic

Jolly Tiwari
Ranch Hand

Joined: Mar 26, 2006
Posts: 77
I have got an EJB deployed in webogic 9.2 environment in which we are creating
a new Thread .In the EJB after starting the thread i have written
Thread th=new Thread(new SomeJob());
th.start();

try
{

th.join(120000);

}catch(InterruptedException iex)
{

}

if the thread executes normally ( i mean their is no problem in the Thread) in this case , My EJB code waits for the
thread to finish till the specified time interval in milli seconds and after that
EJB code executes which fulfills my requirement.

But the problem is if the thread executes above the configured StuckThreadMaxTime(600sec), then weblogic throws an ecxception but code in the EJB is not executed even though it should because thead is no more.


Don't know what's going on???

please give some inputs on this


Regards

Jolly
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8834
    
    7

Creating threads in an EJB is a Bad Idea:
If application components contain the same functionality
provided by J2EE system infrastructure, there are clashes and mis-management of the functionality.
For example, if enterprise beans were allowed to manage threads, the J2EE
platform could not manage the life cycle of the enterprise beans, and it could not properly manage transactions.

J2EE 1.4 Specification section 6.2.1 Programming Restrictions

The usual way to handle a long-running process in a web application is to return a message to the user immediately and hand the request off to a non-web client. Once the request has been processed, the non-web client can inform the user the results are available via email.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Jolly Tiwari
Ranch Hand

Joined: Mar 26, 2006
Posts: 77
But in case where execution of the code in the EJB (Which created and started the therad)makes sense only when the thread has done its job , which mechanism shall i follow ...to implement such scenario because i have to wait either for the response of the thread or in case i don't get the response i have to wait for a fixed time duration.Thats why i was using join(120000) in the EJB code.


Hope i am able to elaborate the case.

please give some inputs


Regards

Jolly
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem in Join() with user threads in weblogic
 
Similar Threads
Confusion on ejb client and jdk versions
EJB 3 TransactionTimeout annotation needed
Weblogic portal upgrade from 7.0 to 9.2
Thread Scheduler
Do Listeners execute in seperate thread?