EJB / Timeout / HttpUrlConnection

I have an EJB that needs to talk to an outside vendor using http.
Is there a way I can specify a timeout and thus if the vendor http port is down,
the bean doesn't try forever to connect.
I saw a similar post in this newsgroup and a proposed solution but that works
only for https.
I was hoping to find either 1) a property somewhere in weblogic to control the
timeout parameter. This call is in a bean method by itself.
2) A timeout parameter that could be specified while connecting to the external
port.
We are using WLS 6.1/JDK 1.3.1.
Here is a code snippet...
URL myURL = new URL (....)
HttpURLConnection myConn = myURL.getOpenConnection();
myURL.getOutputStream()

1.4 finally supports this. Using 1.3 you have several choices to add
read timeout:
use HTTPClient: http://www.innovation.ch/java/HTTPClient/
if you use Sun's JVM this hack works: http://www.logicamente.com/sockets.html
2) Until 1.4 there is no way to specify socket connect timeout.
Ashish <[email protected]> wrote:
I have an EJB that needs to talk to an outside vendor using http.
Is there a way I can specify a timeout and thus if the vendor http port is down,
the bean doesn't try forever to connect.
I saw a similar post in this newsgroup and a proposed solution but that works
only for https.
I was hoping to find either 1) a property somewhere in weblogic to control the
timeout parameter. This call is in a bean method by itself.
2) A timeout parameter that could be specified while connecting to the external
port.
We are using WLS 6.1/JDK 1.3.1.
Here is a code snippet...
URL myURL = new URL (....)
HttpURLConnection myConn = myURL.getOpenConnection();
myURL.getOutputStream()--
Dimitri

Similar Messages

  • EJB timeout.

    Hi! Everyone,
         I am having a problem that I am not sure how to solve this. Hopefully I can get
    some help from expert out there. The situation I am running into is that my application
    that runs inside the Weblogic server need to make a method call to a EJB which runs
    on iPlanet on a different Unix box. My Weblogic Server will stop running (freeze)
    when the iPlanet app server had a core dump. I did a thread dumping on the weblogic
    side. All “ExecuteThread” are had same message as I show below.
    "ExecuteThread: '12' for queue: 'default'" daemon prio=5 tid=0x76e790 nid=0x173 waiting
    on monitor [0xd65f000..0xd65fdc0]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:420)
         at com.sun.corba.se.internal.orbutil.Condition.wait(Condition.java:28)
         at com.sun.corba.se.internal.iiop.IIOPConnection.send(IIOPConnection.java:1002)
         at com.sun.corba.se.internal.iiop.IIOPOutputStream.invoke(IIOPOutputStream.java:76)
         at com.sun.corba.se.internal.iiop.ClientRequestImpl.invoke(ClientRequestImpl.java:87)
         at com.sun.corba.se.internal.corba.ClientDelegate.invoke(ClientDelegate.java:158)
         at com.sun.corba.se.internal.corba.ClientDelegate.invoke(ClientDelegate.java:198)
         at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:459)
    at……
    Any idea on how to broken the pipe between Weblogic and iPlanet when iplanet had
    core dump?
    Thanks a Lot!

    A runtime exception could be getting thrown as well. Add a
    try {
    } catch ( Throwable t ) {
    System.err.println(t);
    around your loop.
    Or, better yet, attach a debugger to the process if you can.
    Slava Imeshev wrote:
    Hi Jani,
    Loop can not break itself. Java is not that smart yet.
    I'd check the code for things like:
    } catch (Exception ex) {
    Slava
    "Jani P." <[email protected]> wrote in message
    news:[email protected]..
    Hello,
    I have a problem related to session Bean which has a method making
    simple queries to database. The problem shows when i call the method
    from client in a loop....exactly when the loop has run 50sec (the method
    has been called like 100-140 times). After 50sec the loop just breaks
    off without any Exception or Error messages.
    I have tried to find from config.xml something in settings that
    indicates to 50sec timeout, but haven't found anything.
    Does someone have a hint for me?
    Our Weblogic6.1 SP3 is running on Linux and the database we are using is
    Oracle8.i.
    Jani
    Steve Buzzard
    Anexinet
    One International Plaza
    Suite 140
    Philadelphia, PA 19113
    http://www.anexinet.com

  • EJB timeout - removal

    I have a SessioBean, this bean is removed when client is logged out , if client is not logging out / client crash the bean should be removed from server after a specified period of time. We tried setting timeout attribute to tag <session-deployment> in the orion-ejb-jar.xml file. but this doesnt work. see bug #173 in orion bugzilla( http://bugzilla.orionserver.com/bugzilla/show_bug.cgi?id=173 ),
    So we need a scheme to detect client disconnection/Inactivity and to remove unused beans from the application server ,

    On WebSphere you can specify 'Transaction timeout' and 'Transaction inactivity timeout' fields for each application server from its Administrative Console. I'm not farmiliar with other vendor's product but I'll assume they should have similar function to compete. So depends on what you want to do you may have a few options:
    1. Make the client's timeout a little more than the transaction timeout value so you can make sure if something gets returned the client will receive it.
    2. If you don't have control on either of the server's transaction timeout or client's timeout, assign a default boolean to the client method when it timeouts.
    3. I don't think you need to handle the 'orphan response'. Say, let's suppose the client method never timeouts and so it receives the response all the time, will the EJB know the response gets received or not? Probably not, because this is not a message service. It simply does not care. That is why I don't feel you need handle this.
    PC

  • How to set the EJB timeout value??

    I made a Swing application connecting with EJB to provide some service. If I set the correct J2EE server IP, everything works fine. However, it will throw an Exception after some time, if I set an incorrect IP. I would like to ask if there is any means to set a timeout value for the Swing application that it throws an exception while it cannot connect to the server after the timeout value.

    Hi,
    Amount of time required to call an EJB on a remote server depends on, I would guess, multiple factors, like server performance, network speed, link quality, etc. I'm not sure if there is a direct way of telling the client-side code to wait for results for a limited amount of time, but in general blocking on the client side until the server results are available is not a good idea (at least not from the GUI perspective, since you would be locking the display). Either way, you could make all your EJB calls from a separate thread, and timeout that. This way your client code would have complete control of responsiveness of the server side.
    Just a thought.
    Mark

  • A question about EJB timeouts

    Good day!
    I encountered an interesting situation about EJB timer service.
    1) For example, I created an implementing TimerObject Stateless Session Bean.
    2) In ejbSetSessionContext method I created an timer to invoke ejbTimeout on my EJB every 15 seconds.
    3) Ok. Container invokes this ejbTimeout every 15 sec. But what happens is previous ejbTimeout didn't returned because it is waiting for some connection for example. Would container invoke ejbTimeout while processing previous ejbTimeout on this one Stateless EJB?
    I looked in EJB 2.1 spec. but didn't find corresponding answer.

    Hi russiandroopy,
    This isn't specifically mentioned in the spec because the design center of the Timer Service was not fine-grained events. The spec suggests that typical timeouts would be on the order of minutes or hours, which is typically much longer than the duration of the handling time within a timeout method or business method. In SUN's implementation we do not attempt to deliver a subsequent periodic timeout until the previous timeout completes successfully.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • EJB / Thread / URLConnection

    All,
    I have an EJB that needs to talk to an outside vendor using http. I could not find
    an elegant way to specify the timeout in the HttpURLConnection and thus I ended up
    implementing this using threads.
    I was wondering if this approach has some issues (since threads usage is not exactly
    recommended with EJBs).
    Here is the code snippet
    URLConnectionThread uct = new URLConnection(host, inMesg)
    uct.start();
    uct.join(timeout)
    if (uct.isAlive == true) uct.interrupt.
    URLConnectionThread class opens the connection and get the input/output stream.
    I know that this timeout issue is fixed in JDK 1.4 but we can not afford to upgrade
    at this time.
    Thanks,

    Hrm. I use this hack for quite a while and it works perfectly. Of course it works
    only with Sun's JVM ;-)
    Here is the test error:
    java.io.InterruptedIOException: Read timed out
    at java.net.SocketInputStream.socketRead(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:86)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:186)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:225)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:280)
    at java.io.FilterInputStream.read(FilterInputStream.java:114)
    at java.io.PushbackInputStream.read(PushbackInputStream.java:164)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:649)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:613)
    at HttpClientTimeout.parseHTTP(HttpClientTimeout.java:39)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:621)
    at HttpClientTimeout.parseHTTP(HttpClientTimeout.java:39)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:506)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:230)
    at TestTimeout.main(TestTimeout.java:9)
    And here are all .java files (for 1.3) :
    TestTimeout.java
    import java.io.*;
    import java.net.*;
    public class TestTimeout {
    public static void main(String[] args) {
         try {
         URL url = new URL(null, "http://www.cnn.com", new HttpTimeoutHandler(10));
         HttpURLConnection conn = (HttpURLConnection)url.openConnection();
         System.out.println(conn.getResponseCode());
         } catch(Throwable t) {
         t.printStackTrace();
    HttpClientTimeout.java
    import sun.net.www.http.HttpClient;
    import java.net.*;
    import java.io.*;
    import sun.net.www.MessageHeader ;
    import sun.net.ProgressEntry ;
    public class HttpClientTimeout extends HttpClient
    public HttpClientTimeout(URL url, String proxy, int proxyPort) throws IOException
         super(url, proxy, proxyPort);
    public HttpClientTimeout(URL url) throws IOException
         super(url, null, -1);
    private int timeout = -1;
    public void SetTimeout(int i) throws SocketException {
         timeout = i;
         serverSocket.setSoTimeout(i);
    public boolean parseHTTP(MessageHeader header, ProgressEntry entry)
         throws java.io.IOException
         if( this.timeout != -1 ) {
         try {
              serverSocket.setSoTimeout(this.timeout) ;
         } catch( SocketException e ) {
              throw new java.io.IOException("unable to set socket timeout!") ;
         return super.parseHTTP(header, entry) ;
    /* This class has no public constructor for HTTP. This method is used to
    * get an HttpClient to the specifed URL. If there's currently an
    * active HttpClient to that server/port, you'll get that one.
    * no longer syncrhonized -- it slows things down too much
    * synchronize at a higher level
    public static HttpClientTimeout GetNew(URL url)
         throws IOException {
         /* see if one's already around */
         HttpClientTimeout ret = (HttpClientTimeout) kac.get(url);
         if (ret == null) {
         ret = new HttpClientTimeout (url); // CTOR called openServer()
         } else {
         ret.url = url;
         // don't know if we're keeping alive until we parse the headers
         // for now, keepingAlive is false
         return ret;
    public void Close() throws IOException
         serverSocket.close();
    public Socket GetSocket()
         return serverSocket;
    HttpTimeoutFactory.java
    import java.net.*;
    public class HttpTimeoutFactory implements URLStreamHandlerFactory
         int fiTimeoutVal;
         public HttpTimeoutFactory(int iT) { fiTimeoutVal = iT; }
         public URLStreamHandler createURLStreamHandler(String str)
              return new HttpTimeoutHandler(fiTimeoutVal);
    HttpTimeoutHandler.java
    import java.net.*;
    import java.io.IOException;
    public class HttpTimeoutHandler extends sun.net.www.protocol.http.Handler
         int fiTimeoutVal;
         HttpURLConnectionTimeout fHUCT;
         public HttpTimeoutHandler(int iT) { fiTimeoutVal = iT; }
    protected java.net.URLConnection openConnection(URL u) throws IOException {
              return fHUCT = new HttpURLConnectionTimeout(u, this, fiTimeoutVal);
    String GetProxy() { return proxy; }          // breaking encapsulation
    int GetProxyPort() { return proxyPort; } // breaking encapsulation
         public void Close() throws Exception
              fHUCT.Close();
         public Socket GetSocket()
              return fHUCT.GetSocket();
    HttpURLConnectionTimeout.java
    import java.net.*;
    import java.io.*;
    import sun.net.www.http.HttpClient;
    public class HttpURLConnectionTimeout extends sun.net.www.protocol.http.HttpURLConnection
         int fiTimeoutVal;
    HttpTimeoutHandler fHandler;
         HttpClientTimeout fClient;
         public HttpURLConnectionTimeout(URL u, HttpTimeoutHandler handler, int iTimeout) throws IOException
         super(u, handler);
              fiTimeoutVal = iTimeout;
         public HttpURLConnectionTimeout(URL u, String host, int port) throws IOException
         super(u, host, port);
    public void connect() throws IOException {
         if (connected) {
         return;
         try {
         if ("http".equals(url.getProtocol()) /* && !failedOnce <- PRIVATE */ ) {
              // for safety's sake, as reported by KLGroup
              synchronized (url)
                   http = HttpClientTimeout.GetNew(url);
              fClient = (HttpClientTimeout)http;
              ((HttpClientTimeout)http).SetTimeout(fiTimeoutVal);
         } else {
              // make sure to construct new connection if first
              // attempt failed
              http = new HttpClientTimeout(url, fHandler.GetProxy(), fHandler.GetProxyPort());
         ps = (PrintStream)http.getOutputStream();
         } catch (IOException e) {
         throw e; }
              // this was missing from the original version
              connected = true;
    * Create a new HttpClient object, bypassing the cache of
    * HTTP client objects/connections.
    * @param url     the URL being accessed
    protected HttpClient getNewClient (URL url)
    throws IOException {
              HttpClientTimeout client = new HttpClientTimeout (url, (String)null, -1);
              try {
              client.SetTimeout(fiTimeoutVal);
              } catch (Exception e)
              { System.out.println("Unable to set timeout value"); }
         return (HttpClient)client;
    * opens a stream allowing redirects only to the same host.
    public static InputStream openConnectionCheckRedirects(URLConnection c)
         throws IOException
    boolean redir;
    int redirects = 0;
    InputStream in = null;
    do {
    if (c instanceof HttpURLConnectionTimeout) {
    ((HttpURLConnectionTimeout) c).setInstanceFollowRedirects(false);
    // We want to open the input stream before
    // getting headers, because getHeaderField()
    // et al swallow IOExceptions.
    in = c.getInputStream();
    redir = false;
    if (c instanceof HttpURLConnectionTimeout) {
    HttpURLConnectionTimeout http = (HttpURLConnectionTimeout) c;
    int stat = http.getResponseCode();
    if (stat >= 300 && stat <= 305 &&
    stat != HttpURLConnection.HTTP_NOT_MODIFIED) {
    URL base = http.getURL();
    String loc = http.getHeaderField("Location");
    URL target = null;
    if (loc != null) {
    target = new URL(base, loc);
    http.disconnect();
    if (target == null
    || !base.getProtocol().equals(target.getProtocol())
    || base.getPort() != target.getPort()
    || !HostsEquals(base, target)
    || redirects >= 5)
    throw new SecurityException("illegal URL redirect");
    redir = true;
    c = target.openConnection();
    redirects++;
    } while (redir);
    return in;
    // Same as java.net.URL.hostsEqual
         static boolean HostsEquals(URL u1, URL u2)
    final String h1 = u1.getHost();
    final String h2 = u2.getHost();
    if (h1 == null) {
    return h2 == null;
    } else if (h2 == null) {
    return false;
    } else if (h1.equalsIgnoreCase(h2)) {
    return true;
    // Have to resolve addresses before comparing, otherwise
    // names like tachyon and tachyon.eng would compare different
    final boolean result[] = {false};
    java.security.AccessController.doPrivileged(
    new java.security.PrivilegedAction() {
    public Object run() {
    try {
    InetAddress a1 = InetAddress.getByName(h1);
    InetAddress a2 = InetAddress.getByName(h2);
    result[0] = a1.equals(a2);
    } catch(UnknownHostException e) {
    } catch(SecurityException e) {
    return null;
    return result[0];
         void Close() throws Exception
              fClient.Close();
         Socket GetSocket()
              return fClient.GetSocket();
    Ashish <[email protected]> wrote:
    Thanks for your help.
    I'm still having problems though. I changed the code to look like your sample code.
    It compiles and runs okay but the timeout thing does not take affect.
    Do I need to alter the classpath or something ? In my test code, I'm not even running
    under weblogic. It's a standalone client trying to connect to a url. (though it has
    weblogic.jar in front of the classpath).
    <[email protected]> wrote:
    You need to update HttpClientTimeout (see below) for 1.3 and use it
    like this:
    URL url = new URL(null, "http://...", new HttpTimeoutHandler(timeout));
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    (you will also need to modify weblogic.policy to allow your code to specify
    handler).
    --- HttpClientTimeout.java ---
    import sun.net.www.http.HttpClient;
    import java.net.*;
    import java.io.*;
    import sun.net.www.MessageHeader ;
    import sun.net.ProgressEntry ;
    public class HttpClientTimeout extends HttpClient
    public HttpClientTimeout(URL url, String proxy, int proxyPort) throws
    IOException
         super(url, proxy, proxyPort);
    public HttpClientTimeout(URL url) throws IOException
         super(url, null, -1);
    private int timeout = -1;
    public void SetTimeout(int i) throws SocketException {
         timeout = i;
         serverSocket.setSoTimeout(i);
    public boolean parseHTTP(MessageHeader header, ProgressEntry entry)
         throws java.io.IOException
         if( this.timeout != -1 ) {
         try {
              serverSocket.setSoTimeout(this.timeout) ;
         } catch( SocketException e ) {
              throw new java.io.IOException("unable to set socket timeout!") ;
         return super.parseHTTP(header, entry) ;
    /* This class has no public constructor for HTTP. This method is used
    to
    * get an HttpClient to the specifed URL. If there's currently an
    * active HttpClient to that server/port, you'll get that one.
    * no longer syncrhonized -- it slows things down too much
    * synchronize at a higher level
    public static HttpClientTimeout GetNew(URL url)
         throws IOException {
         /* see if one's already around */
         HttpClientTimeout ret = (HttpClientTimeout) kac.get(url);
         if (ret == null) {
         ret = new HttpClientTimeout (url); // CTOR called openServer()
         } else {
         ret.url = url;
         // don't know if we're keeping alive until we parse the headers
         // for now, keepingAlive is false
         return ret;
    public void Close() throws IOException
         serverSocket.close();
    public Socket GetSocket()
         return serverSocket;
    Ashish <[email protected]> wrote:
    I tried using the http://www.logicamente.com/sockets.html but it didn't
    work for me.
    The timeout parameter I specify is completely ignored.
    Did you get it to work ?
    Appreciate your help.
    Ashish.
    <[email protected]> wrote:
    Just use a different HTTP client implementation -
    http://www.innovation.ch/java/HTTPClient/ for example :
    HTTPConnection conn = new HTTPConnection("someserver", port);
    conn.setTimeout(...);
    HTTPResponse res = conn.Get("/...");
    InputStream in = res.getInputStream();
    This hack also works, if you want to keep using java.net APIs:
    http://www.logicamente.com/sockets.html
    Ashish <[email protected]> wrote:
    All,
    I have an EJB that needs to talk to an outside vendor using http. I
    could
    not find
    an elegant way to specify the timeout in the HttpURLConnection and thusI ended up
    implementing this using threads.
    I was wondering if this approach has some issues (since threads usageis not exactly
    recommended with EJBs).
    Here is the code snippet
    URLConnectionThread uct = new URLConnection(host, inMesg)
    uct.start();
    uct.join(timeout)
    if (uct.isAlive == true) uct.interrupt.
    URLConnectionThread class opens the connection and get the input/outputstream.
    I know that this timeout issue is fixed in JDK 1.4 but we can not affordto upgrade
    at this time.
    Thanks,--
    Dimitri
    Dimitri
    Dimitri

  • How to call the secured EJB from timer ejb timedout method.

    Hi All,
    I have a couple of questions on EJB 3.1 Timer Service.
    1. How to call the secured EJB (annotated @RolesAllowed) from Timer EJB @Timeout Method?
    2. What's the default role/principal with which the Timer @Timeout Method gets called?
    Please let me know any info regarding the same.
    Thanks,
    Suresh

    I'd start here:
    http://ant.apache.org/manual/index.html
    If that doesn't help, go to the table of contents and start poking around. You don't need to read the whole thing front to back, but if you're not willing to spend some time researching and reading, you're not going to get very far.

  • Stateless EJB is null using TimerService

    Hi,
    I created a stateless ejb using TimerService to run it in weblogic 10.3. After deploying it, I could not get the ejb instantiated properly. The code is as below.
    Could anyone explain what is missing?
    Thanks in advance.
    //=================================================
    public interface ReconTimer {
    public void createTimer();
    //================================================
    import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import javax.annotation.Resource;
    import javax.ejb.EJB;
    import javax.ejb.Stateless;
    import javax.ejb.Timeout;
    import javax.ejb.Timer;
    import javax.ejb.TimerService;
    import javax.ejb.Local;
    import javax.ejb.TransactionAttribute;
    import javax.ejb.TransactionManagement;
    import javax.ejb.TransactionManagementType;
    @Stateless (name="ReconTimerBean")
    @Local (ReconTimer.class)
    @TransactionManagement(value=TransactionManagementType.BEAN )
    @TransactionAttribute(value=NOT_SUPPORTED)
    public class ReconTimerBean implements ReconTimer {
         private static final Log log = LogFactory.getLog(ReconTimerBean.class);
    @Resource
    TimerService timerService;
    public void createTimer() {
         log.info("Crating timer");
         log.info("timerService [" + timerService + "]");
    Timer timer = timerService.createTimer(20000,
    "Created new timer");
    @Timeout
    public void timeout(Timer timer) {
    log.info("Timeout occurred !!!");
    ========================================
    client code:
    @EJB(beanName="ReconTimerBean")
    ReconTimer timerBean
    if (timerBean != null)
    timerBean.createTimer();
    else log.error ("Timer Bean is null !!!");
    Error is always logged when the bean is deployed.
    ======================================
    weblogic-ejb-jar.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar"
         xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://www.bea.com/ns/weblogic/weblogic-ejb-jar http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd">
    <weblogic-enterprise-bean>
    <ejb-name>ReconTimerBean</ejb-name>
         <stateless-session-descriptor>
              <pool>          
                   <max-beans-in-free-pool>1</max-beans-in-free-pool>          
                   <initial-beans-in-free-pool>1</initial-beans-in-free-pool>     
              </pool>
         </stateless-session-descriptor>
    <jndi-name>app-recon-bean</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>

    Hi Ashley,
    The Dependency injection has some limitations as well…Please referto the following link: (Web Component Classes That Support Annotations)
    http://download.oracle.com/docs/cd/E13222_01/wls/docs100/webapp/annotateservlet.html
    …Which says that DI is not possible from every web component.
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com/ejbs_weblogic/#comment-165  (Dependency Injection Issues)

  • Removing an IIOP User connection to an EJB on JServer

    I am writing an application using a servlet engine to connect to an EJB in JServer. I am not using connection pooling because each user will be logging in with their database username. When the session times out on the servlet, I would like to clean up the connection, and release the EBJ/IIOP connection. Is there a preferred method to do this, or should I let JServer time out?
    Thanks
    Ken

    The beans have session lifetime and will be removed/cleaned up when the session is deleted.
    The session is constructed when the first JNDI lookup (on InitialContext) to an object (EJB in your case) of a given database instance is made. The session is deleted when there are :
    a) no connections to the session
    -and-
    b) the EJB timeout has expired.
    The timeout only starts ticking when there are no connections to the session.

  • RMI - How to set a client timeout?

    Hey folks,
    please don't crucify me, but i googled for "rmi client timeout" and i only found confusing and / or really dated information.
    Could somebody enlighten me on how to set a timeout for an RMI-client?
    Even an RTFM would be fine, but which?

    Hi,
    thanks for your insistence.....:-)
    ejp wrote:
    1. Are you using rmic? UnicastRemoteObject? or some JBoss API?Ehm, for the client?
    The client's sourcecode for connecting to the Jboss-Server / my EJB-application is:
    Hashtable<String, String> props = new Hashtable<String, String>();
    props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
    props.put(Context.PROVIDER_URL,"jnp://" + "myhost");
    props.put(Context.SECURITY_PRINCIPAL, "myuser");
    props.put(Context.SECURITY_CREDENTIALS, "mypassword");
    Context ctx = new InitialContext(props);
    // get RMI stub
    ISendCommand sendCommand = (ISendCommand) ctx.lookup(myjndiname);
    String result = sendCommand.sendCommand(myArgs);So i think this corrensponds to "UnicastRemoteObject" from your enumeration?
    ejp wrote:
    2. How do you know JBoss terminates the connection?Because i have a timeout configured in my EJB-application, but in the example i try to get working, the client shall use its own timeout which is before the EJB-timeout.
    The EJB-timeout works, but not the client timeout.....(as described above)
    ejp wrote:
    3. What happens at the client? An exception? Nothing?"Nothing", i.e. the client terminates when the connection times out (from the JBoss / EJB-side!)
    ejp wrote:
    4. Are you ignoring any exceptions at the client?No.
    Shouldn't this client timeout be totally independent from any server / Jboss / whatever stuff?
    Any more ideas?

  • MDB rollbacks and stops the listener port with error code 2072

    Hi
    We have a MDB listening on QUEUE1. This MDB processes the message and puts another message in QUEUE2. Transaction is "required" for this MDB.
    The processing could somtime take more than 2 min. We used to get EJB timeout error in this scenario. We changed EJB timeout to 5 min (default was 2 min). This resolved the timeout error. But it started throwing following exception. Note that if the processing takes less than 2 min, MDB never rollbacks.
    After this rollack, listener port can not pick up the next message and it throws error (MQJMS2002: failed to get message from MQ queue. MQ Error Code 2072) . It stops as a result and restarts after 60 sec. Even after restart it can not process the messages till we restart the JVM.
    Regarding error handling, Backout threshold is 3. If the message is redelivered, we discard this message.
    We are using 2 Phase commit for 2 resources MQ (5.3) and MS SQL.
    Websphere version is 5.1.
    Two issues here
    1. Why is MDB rolling back if processing takes more than 2 min.
    2. After the rollback, why is listener port not picking up the messages. Why do we need to recycle the JVM.
    Any pointers to resolve this issue?
    EXCEPTION
    [11/29/05 15:03:37:752 EST] 1b9bccc XATransaction E J2CA0027E: An exception occurred while invoking end on an XA Resource Adapter from dataSource JMS$postprocessor$JMSManagedConnection@25078403, within transaction ID {XID: formatId(57415344), gtrid_length(51), bqual_length(2, data(00000000000000950000000113238145f813eccfef12249c6aab206666f96901636c5f6170703130355f73656e7431715f716113238145f813eccfef12249c6aab206666f969010000000100000000)}: javax.transaction.xa.XAException: XA operation failed, see errorCode
    at com.ibm.mq.MQXAResource.end(MQXAResource.java:520)
    at com.ibm.ejs.jms.JMSManagedSession$JMSXAResource.end(JMSManagedSession.java:1557)
    at com.ibm.ejs.j2c.XATransactionWrapper.end(XATransactionWrapper.java:525)
    at com.ibm.ws.Transaction.JTA.JTAResourceBase.end(JTAResourceBase.java:253)
    at com.ibm.ws.Transaction.JTA.RegisteredResources.distributeEnd(RegisteredResources.java:629)
    at com.ibm.ws.Transaction.JTA.TransactionImpl.internalPrepare(TransactionImpl.java:1241)
    at com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:981)
    at com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:150)
    at com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:177)
    at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:712)
    at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:167)
    at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:570)
    at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3068)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:102)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
    at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:375)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)
    [11/29/05 15:03:38:089 EST] 1b9bccc ServerSession W WMSG0031E: Exception processing JMS Message for MDB BatchProcessorMDB, JMSDestination jms/PostprocessorQ : javax.ejb.TransactionRolledbackLocalException: ; nested exception is: com.ibm.ws.exception.WsEJBException
    com.ibm.ws.exception.WsEJBException
    at com.ibm.ejs.container.LocalExceptionMappingStrategy.mapException(LocalExceptionMappingStrategy.java:159)
    at com.ibm.ejs.container.LocalExceptionMappingStrategy.mapCSITransactionRolledBackException(LocalExceptionMappingStrategy.java:293)
    at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3159)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:102)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
    at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:375)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)
    javax.ejb.TransactionRolledbackLocalException: ; nested exception is: com.ibm.ws.exception.WsEJBException
    at com.ibm.ejs.container.LocalExceptionMappingStrategy.mapCSIException(LocalExceptionMappingStrategy.java:96)
    at com.ibm.ejs.container.LocalExceptionMappingStrategy.mapException(LocalExceptionMappingStrategy.java:165)
    at com.ibm.ejs.container.LocalExceptionMappingStrategy.mapCSITransactionRolledBackException(LocalExceptionMappingStrategy.java:293)
    at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3159)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:102)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
    at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:375)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)
    [11/29/05 15:03:38:124 EST] 1e9aa18 JMSExceptionL E WMSG0018E: Error on JMSConnection for MDB BatchProcessorMDB , JMSDestination jms/PostprocessorQ : javax.jms.JMSException: MQJMS2002: failed to get message from MQ queue
    at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:553)
    at com.ibm.mq.jms.MQSession.consume(MQSession.java:3144)
    at com.ibm.mq.jms.MQSession.run(MQSession.java:1585)
    at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:924)
    at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:752)
    at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:527)
    at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:494)
    at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:91)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
    at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:375)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)
    ---- Begin backtrace for Nested Throwables
    com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2072
    at com.ibm.mq.jms.MQSession.consume(MQSession.java:3118)
    at com.ibm.mq.jms.MQSession.run(MQSession.java:1585)
    at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:924)
    at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:752)
    at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:527)
    at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:494)
    at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:91)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
    at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:375)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)
    [11/29/05 15:03:38:149 EST] 1e9aa18 JMSExceptionL E WMSG0057E: Error on JMSConnection for MDB BatchProcessorMDB , JMSDestination jms/PostprocessorQ , JMS Linked Exception : com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2072
    at com.ibm.mq.jms.MQSession.consume(MQSession.java:3118)
    at com.ibm.mq.jms.MQSession.run(MQSession.java:1585)
    at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:924)
    at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:752)
    at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:527)
    at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:494)
    at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:91)
    at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
    at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:375)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:912)
    [11/29/05 15:03:38:190 EST] 1e9aa18 MDBListenerIm I WMSG0043I: MDB Listener ProcessorLP stopped for JMSDestination jms/PostprocessorQ
    [11/29/05 15:03:38:192 EST] 1e9aa18 MDBListenerIm I WMSG0058I: Listener Port ProcessorLP will attempt to restart in 60 seconds
    [11/29/05 15:03:38:194 EST] 1e9aa18 ConnectionEve A J2CA0056I: The Connection Manager received a fatal connection error from the Resource Adaptor for resource jms/PostprocessorQF. The exception which was received is javax.jms.JMSException: MQJMS2002: failed to get message from MQ queue
    [11/29/05 15:04:38:230 EST] 1436f66 MDBListenerIm I WMSG0042I: MDB Listener ProcessorLP started successfully for JMSDestination jms/PostprocessorQ

    Have been able to solve this problem? The same occurs in our environment. I have a nagging feelin git has something to do with a known bug that is solved in some fixpack or something. We're on Websphere 5.1.1.4.
    Any feedback would be appreciated.
    Thanks,
    Jaap

  • TimedObject -' TX attribute ' is not working with netbeans 5.0 and SAS 8.0

    Hello,
    I am building a master timer stateless session bean. I have followed the examples from this site as well as I know how, and have even removed all of the system messages and other fluff. I continue to get the following error:
    EJB Timeout method must have an attribute value of TX_REQUIRES_NEW OR TX_NOT_SUPPORTED for ejb
    I have looked through the TimedObject, Timer, and TimerHandle API, all of which seems very simple and does not have any TX field. The example from the site is also very simple, only requiring the declaration of a timer start, which needs a TimerHandle return(although the example does not have it returning a value, I have tried this code both as written and with a class level TimerHandle object returned from the createTimer(...).getHandle() method ), and the declaration of a void ejbTimeout(Timer timer). This method should work with no body in the method since the return is void. I also set my timer intervals to ensure that they were
    I am very confused and feel that this should be very easy. Does anyone know if I am dealing with a configuration error? I know that netbeans does not directly support the use of the ejb TimerService (which seems a little crazy to me, as most non-trivial applications require a timer in some form for periodic events), so are there any deployment descriptors in any of the files which need to be set for this service to work? This error looks to me like a configuration error on some level, or possibly a missing entry in one of the myriad of xml configuration files that are required. The code for my bean is below:
    package QualityPortal;
    import javax.ejb.*;
    * This is the bean class for the MasterSchedulerBean enterprise bean.
    * Created Jul 18, 2006 12:40:18 PM
    * @author ttaylor
    public class MasterSchedulerBean implements SessionBean, MasterSchedulerLocalBusiness, TimedObject
    private SessionContext context;
    private TimerHandle timerHandle = null;
    public void setSessionContext(SessionContext aContext)
    context = aContext;
    * @see javax.ejb.SessionBean#ejbActivate()
    public void ejbActivate()
    * @see javax.ejb.SessionBean#ejbPassivate()
    public void ejbPassivate()
    * @see javax.ejb.SessionBean#ejbRemove()
    public void ejbRemove()
    // </editor-fold>
    * See section 7.10.3 of the EJB 2.0 specification
    * See section 7.11.3 of the EJB 2.1 specification
    public void ejbCreate()
    timerHandle = startTimer();
    public javax.ejb.TimerHandle startTimer()
    TimerService timerService = context.getTimerService();
    Timer timer = timerService.createTimer(30000, "created timer");
    return timer.getHandle();
    public void ejbTimeout(Timer timer)
    //call to another bean here
    WMLReportFactoriesBean wml = new WMLReportFactoriesBean();
    wml.inspectionThroughput();
    }

    Your ejbTimeout() must have a transaction attribute, which resides in the ejb-jar.xml. You'd have to edit your descriptor to contain something like:
    <container-transaction>
    <method>
    <ejb-name>MasterScheduler</ejb-name>
    <method-name>ejbTimeout</method-name>
    </method>
    <trans-attribute>RequiresNew</trans-attribute>
    </container-transaction>
    Or NotSupported.
    Hope it helps.

  • Canceling timers after server restart

    hi,
    i create a couple of timers. while the application server is up i can cancel them by getting the TimerService object of the bean it's associated with, calling getTimers() and cancelling the Timer objects returned from it.
    if i restart the server (let's say it crashed), the timers created in the previous session are back to run - they are persistent by definition. but now i can't cancel them anymore: same getTimers() returns an empty Collection. i think this happens because the old timers from the previous session were not rebound to the new ejbcontext, or something like this.
    my question is: how can i cancel timers, that were re-invoked after server restart.
    thank you.
    Message was edited by:
    cyclid

    Below are my tests that show canceling of timers working as expected:
    Session bean methods:
    public void createTimers()
    {       System.out.println("### CREATE - a single-action timer that expires in 4s");
    ctx.getTimerService().createTimer(4000, "single-action timer that expires in 4s");
    System.out.println("### CREATE - an interval timer that expires in every 2s");
    ctx.getTimerService().createTimer(2000, 2000, "interval timer that expires in every 2s");
    public void cancelAllTimers() {   
         System.out.println("### CANCEL - timers:");     
         for (java.util.Iterator iter = ctx.getTimerService().getTimers().iterator(); iter.hasNext();) {
              Timer timer = (Timer) iter.next();
              System.out.println(" canceling ... " + timer.getInfo());
              timer.cancel();
    public void logCurrentTime() {
         System.out.println("### CURRENT TIME - " + java.util.Calendar.getInstance().getTime());
    public void ejbTimeout(Timer timer)
    {     System.out.println("### EJB TIMEOUT - " + timer.getInfo());       
    Java Client test:
    ejb.cancelAllTimers();
    Thread.sleep(4000);
    ejb.logCurrentTime();
    ejb.createTimers();
    Thread.sleep(8000);
    ejb.cancelAllTimers();
    ejb.logCurrentTime();
    Thread.sleep(8000);
    ejb.logCurrentTime();
    Logs:
    1. Shutdown servers while there is an interval timer
    The log shows the interval timer came back and then was cancel after server restart
    07/02/06 13:46:23 ### CANCEL - timers:
    07/02/06 13:46:27 ### CURRENT TIME - Tue Feb 06 13:46:27 EST 2007
    07/02/06 13:46:27 ### CREATE - a single-action timer that expires in 4s
    07/02/06 13:46:27 ### CREATE - an interval timer that expires in every 2s
    07/02/06 13:46:29 ### EJB TIMEOUT - interval timer that expires in every 2s
    07/02/06 13:46:31 ### EJB TIMEOUT - single-action timer that expires in 4s
    07/02/06 13:46:31 ### EJB TIMEOUT - interval timer that expires in every 2s
    07/02/06 13:46:32 Shutting down OC4J...
    C:\oc4j\10131_061009\j2ee\home>java -jar oc4j.jar
    07/02/06 13:48:12 Oracle Containers for J2EE 10g (10.1.3.1.0) initialized
    07/02/06 13:48:13 ### EJB TIMEOUT - interval timer that expires in every 2s
    07/02/06 13:48:15 ### EJB TIMEOUT - interval timer that expires in every 2s
    07/02/06 13:48:17 ### EJB TIMEOUT - interval timer that expires in every 2s
    07/02/06 13:48:18 ### CANCEL - timers:
    07/02/06 13:48:18 canceling ... interval timer that expires in every 2s
    07/02/06 13:48:22 ### CURRENT TIME - Tue Feb 06 13:48:22 EST 2007
    2. Cancel timers right after they were created
    07/02/06 13:50:11 ### CANCEL - timers:
    07/02/06 13:50:15 ### CURRENT TIME - Tue Feb 06 13:50:15 EST 2007
    07/02/06 13:50:15 ### CREATE - a single-action timer that expires in 4s
    07/02/06 13:50:15 ### CREATE - an interval timer that expires in every 2s
    07/02/06 13:50:17 ### EJB TIMEOUT - interval timer that expires in every 2s
    07/02/06 13:50:19 ### EJB TIMEOUT - single-action timer that expires in 4s
    07/02/06 13:50:19 ### EJB TIMEOUT - interval timer that expires in every 2s
    07/02/06 13:50:21 ### EJB TIMEOUT - interval timer that expires in every 2s
    07/02/06 13:50:23 ### EJB TIMEOUT - interval timer that expires in every 2s
    07/02/06 13:50:23 ### CANCEL - timers:
    07/02/06 13:50:23 canceling ... interval timer that expires in every 2s
    07/02/06 13:50:23 ### CURRENT TIME - Tue Feb 06 13:50:23 EST 2007
    07/02/06 13:50:31 ### CURRENT TIME - Tue Feb 06 13:50:31 EST 2007

  • Transaction Error In Synchronous BPEL Process

    Hi All,
    The Bpel Component makes a synchronous call to webservice , at few occurences response from
    webservice delays to 50 secs .
    The default time out of Synchronous Bpel Process is 45 secs, so when response from webservice takes more than 45 secs, the expected behaviour of BPEL
    component should get faulted and control should go to catch all block
    Issue
    But instead, the Invoke activity in BPEL component gets rolled back, and control did not go to catch all block and complete instance goes into running state.
    And after 50 secs, once webservice response back , a new instances gets automitically created .
    Can anyone, Please help me to resolve the issue, i do not want the instances to go into running state .

    What I would do is, have the timeout settings as follows.
    syncMaxWaitTime < EJB Timeout < JTA timeout
    Then, as Vijay pointed in "http://technology.amis.nl/2011/11/18/timeouts-in-oracle-soa-suite-11g/" link, you should add the httpConnTimeout property and httpReadTimeout property to be set less than syncMaxWaitTimeout, so that those timeout will kick in before the syncMaxWaitTime and throw the exception and you can catch it in the catchall block.
    HTH.
    Hruthayah

  • One way BPEL Process Retrying after 60 seconds

    Hi,
    We have a one way BPEL Process that is getting errored after 60 seconds and retrying for 2 times. We check the JTA Timeout and it is set to 1800 sec.
    Any transaction that gets completed in 60 seconds is not rolling
    We also verified the EJB Timeout properties and it is set to 600 sec. Your help is highly appreciated, since we are having this issue in production.
    <The execution of this instance XXX for process XXXXX is supposed to be in an active jta transaction, the current transaction status is "MARKED_ROLLBACK" >
    <Nov 17, 2014 7:44:43 PM PST> <Error> <oracle.soa.bpel.system> <BEA-000000> <Error while invoking bean "cube delivery": JTA transaction is not in active state.
    bpel engine can not execute activities without an active transaction. please debug the invoked subsystem on why the tranasction is not in active status. the bpel instance id is XXX.
    The reason was The execution of this instance XXXXXXXX for process XXXXXXXXx is supposed to be in an active jta transaction, the current transaction status is "MARKED_ROLLBACK" .
    Consult the system administrator regarding this error.
    ORABPEL-02183
    JTA transaction is not in active state.
    bpel engine can not execute activities without an active transaction. please debug the invoked subsystem on why the tranasction is not in active status. the bpel instance id isXX.
    The reason was The execution of this instance XXXXXXXXX for process XXXXXXXXX is supposed to be in an active jta transaction, the current transaction status is "MARKED_ROLLBACK" .
    Consult the system administrator regarding this error.

    Hi,
    have you already checked this thread : oracle.fabric.common.FabricInvocationException while invoking external service from bpel 11g
    You should check following parameters:
    1. JTA Transaction timeout. (which you have already done)
    2. BPEL EJB Timeout settings (which you have already done)
    3. SyncMaxWaitTime setting. ( I can recoomend you this link to understand this parameter SyncMaxWaitTime in Oracle BPEL.. | Vikrant Bhardwaj's SOA Blog)
    4. DB Tuning. (Specially the DISTRIBUTED_LOCK_TIMEOUT)
    best regards, Nicolas

Maybe you are looking for