Forcing and EJB to return from a method


EJB programming & troubleshooting: Forcing and EJB to return from a method

  1. Forcing and EJB to return from a method (1 messages)


    I have an EJB stateless session bean (EJB 2.0) running on a weblogic 7.0 SP 4 server. I would like to know if it is possible to force a a return from a stateless session bean method without changing code ?. The problem is that I have to access and external EJB (can´t change source code), sometimes the method takes X mins/hours to return. Is there a way to tell weblogic to "timeout" after X seconds from a method/ejb call.

    I tried modifying the descriptors of the EJB (ejb-jar.xml and weblogic-ejb.xml) to apply demarcation transaction, but no luck. Any help would be appreciated.
    Here are the XML files:

    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' ''>



    <?xml version="1.0"?>

    <!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 7.0.0 EJB//EN' ''>




    Thanks for reading :-)

  2. not that I'm aware of.

    You need to think of this in terms of java threads - execution of a thread has passed through the ejb container into your bean code, and then onto whatever else from there - RDBMS driver for example. Weblogic doesn't have control over what the thread does until it gets back from whatever it's doing. It could interrupt the thread, but could be problematic for whatever code thread was currently executing - leaving resources unfreed etc.

    There's nothing in the ejb specs to address this - changing the descriptors will not help. The trans-timeout setting won't help either - it just tells weblogic to abort the transaction if the thread spent longer than x seconds inside your bean, rather than forcing the call to return after x seconds.

    I think you need to look more closely at why the call is taking so long. Are you calling some other resource ? Is there a deadlock situation occuring ? Something is going wrong if a call is taking this long - if you can find and fix this you'll have addressed the source of the problem, rather than working around it.