users@glassfish.java.net

set cmt-timeout-in-seconds on session bean

From: <forums_at_java.net>
Date: Thu, 13 Oct 2011 08:28:10 -0500 (CDT)

Hello forum members, I hava a question, maybe anyone has example code for me,
because mine does not work... I want to set a timeout on my session bean if
it does not complete within a specified time My sun-ejb.jar.xml looks like
this [font=Courier] <?xml version="1.0" encoding="UTF-8"?> lexicalanalyzer
ejb/lexicalanalyzer 20 [/font] call from the singletion bean [font=Courier]
@Singleton(name="lexicalfilter", mappedName="ejb/lexicalfilter") @LocalBean
@Startup public class LexicalFilter implements CDFSystemBean{ ... [/font]
calling the corresponding processor bean [font=Courier] try { InitialContext
ctx = new InitialContext(); LexicalAnalyzerRemote sbean =
(LexicalAnalyzerRemote) ctx.lookup("ejb/lexicalanalyzer");
System.out.println("calling at"+ new Date()); sbean.analyze(container);
System.out.println("finished at"+ new Date()); } catch (NamingException ex) {
Logger.getLogger(LexicalFilter.class.getName()).log(Level.SEVERE, null, ex);
} ... [/font] the statless session bean [font=Courier] @Stateless(name =
"lexicalanalyzer", mappedName = "ejb/lexicalanalyzer") public class
LexicalAnalyzer implements LexicalAnalyzerRemote { ... @Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void
analyze() { // we'll sleep for 180 seconds but after 20 shoule wake up try {
Thread.sleep(180000); } catch (InterruptedException ex) {
Logger.getLogger(LexicalFilterAnalyzer.class.getName()).log(Level.SEVERE,
null, ex); } } ... [/font] its remote interface [font=Courier] @Remote public
interface LexicalAnalyzerRemote {
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void
analyze(); } [/font] When I execute the code, the "calling" and "finished at"
dates written to the commandline are 3 minutes apart, but they should be only
20 seconds, so it not works. Please can anyone tell me what I am doing wrong,
I serached very long for a example on the internet but could not find one.
regards. j.

--
[Message sent by forum member 'jcite']
View Post: http://forums.java.net/node/852556