session bean methods, very-very slow, when just about "return"

Discussions

EJB programming & troubleshooting: session bean methods, very-very slow, when just about "return"


  1. I have a simple session bean, which works fine
    if the data, it is loading at ejbCreate() is not very huge, but othewise it is taking a long-long time, when "return" is being performed from any method on the session bean.
    I have tried both stateless and stateful, same results.

    In stateful, I have made sure it is not becuase the server
    is performing an ejbPassivate() and trying to passivate the large instance data....as the control never came to ejbPassivate() or the server never had to passivate the bean.

    But in any case could someone throw any light on why is taking a long time at the time of return...especially if it is a stateless bean (with large instance data)

    Here is the skelton the the bean.....

    ejbCreate()
    {
     makeConnection();
     loadHugeData();
    }

    businessMethod()
    {
     System.out.println("fine so far!");
     return someThingFromHugeData.
    }

    It would print "fine so far" and then would take a long time............
    Again if the loadHugeData() is loading small amount of data it would work quite fast.....
    I have tried the same bean on J2EE RI as well as on Visual age.....
  2. It could be any number of things... Could you post some actual code to show what kind of data you return?
    One quick idea: when you return the partial data do you use Java serialization? Are you sure the rest of the data isn't referenced somehow by the data you return?

    Gal
  3. Hi,

    It could be that serializing/deserialization of your object (might be quite large) is taken some time. Also, it could be your network is so congested that the time to transport your object across the wire is substantial.

    Ben
  4.  
    Ben
    >>It could be that serializing/deserialization of your
    >>object (might be quite large) is taken some time.
    See my response earlier.

    >>Also, it could be your network is so congested that the
    >>time to transport your object across the wire is
    >>substantial.
    I would consider that if I was returning the whole object back to the caller, which is not the case. Just returning a
    small string.




  5. My bean is loading some data into a large hashtable.

    For testing purposes, I have two methods in my bean,
    one returning an element from that large hashtable.
    and second returing a fixed string, but in both cases
    it is taking a long time at "return".

    >>Could you post some actual code to show what kind of data >>you return?
    I will, if u still think so. Just dont want clutter the thread.

    >>One quick idea: when you return the partial data do you
    >>use Java serialization?
    What exactly do u mean by that? My business method is returning a string from the Hashtable. I am not doing any serialization in my code, but Hashtable per say is serializable.
    The two questions here are
    1) why would the J2ee server do any serilazation, in case if it is a stateless session bean

    2) in case it is a stateful bean, why dont the control ever come to ejbPassivate(), in case it is serializing the object and hence the large Hashtable.
  6. What I ment is that maybe the object you return contains references to the rest of the data, so you wind up serializing the entire data back to the client. If you return a String, that isn't the case.
    Some code could help. It's possible that the transaction-related operations take some time, but it shouldn't take very long.
    If you post the code and we can't find a solution, you can try to check it out using a profiler. I personally like OptimizeIt, which has integrated support for many App servers. You can download a trial version at http://www.optimizeit.com/ (it's fully functional)

    Good luck
    Gal