All session objects should be serializable to replicate error.

Hi All,
Having 'EmployeeBean' and it is having below properties with getters and setters methods
private long emp_id;
private String emp_name;
private java.sql.Timestamp date_of_join;
private boolean isActive;
private int dept_no;
Adding multiple employees(creating multiple EmployeeBean) into an ArrayList and storing this ArrayList into a Session object. This is working fine but when I move this code to production(cluster environment) it is throwing below error
<Aug 23, 2011 2:15:40 PM EDT> <Error> <Cluster> <BEA-000126> <All session objects should be serializable to replicate. Check the objects in your session. Failed to replicate non-serializable object.
java.rmi.MarshalException: failed to marshal update(Lweblogic.cluster.replication.ROID;ILjava.io.Serializable;Ljava.lang.Object;); nested exception is:
     java.io.NotSerializableException: my.company.beans.EmployeeBean
     at weblogic.rjvm.BasicOutboundRequest.marshalArgs(BasicOutboundRequest.java:90)
     at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:221)
     at weblogic.cluster.replication.ReplicationManager_1032_WLStub.update(Unknown Source)
     at sun.reflect.GeneratedMethodAccessor163.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     Truncated. see log file for complete stacktrace
Caused By: java.io.NotSerializableException: my.company.beans.EmployeeBean
     at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
     at java.util.ArrayList.writeObject(ArrayList.java:570)
     at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     Truncated. see log file for complete stacktrace
Can someone please let me know, why I'm getting this error? The EmployeeBean should implement serializable? Is there any problems/cons to implement serializable?
Having other bean(LoginBean) and I'm keeping this bean into session and it doesn't implement serializable, not getting any error for this bean(LoginBean). Only difference is LoginBean is not added to ArrayList.
Why it is throwing error for EmployeeBean and not for LoginBean??
Thanks in advance.
Regards,
Sharath.

The EmployeeBean should implement serializable? - Yep Is there any problems/cons to implement serializable? - No
Just add java.io.Serializable to the EmployeeBean, for example,
public class EmployeeBean implements Serializable {
}For LoginBean you have probably, configured to be in the session, by using faces-config.xml.
In the case of EmployeeBean (or the object graph it is part of) have you used HttpSession.setAttribute(...)?
Note that setAtttibute(...) is the trigger for an application server to replicate the object.
In this case all objects in the object graph have to be serializable.
Typically, objects should be Serializable when they are part of the session and you are using a clustered environment.

Similar Messages

  • Is Bulky Session Object Better or a Bulky Stateful Sess bean better

    Hi,
              We are clustering on Weblogic 6.0. Currently we are debating on whether
              to cache out ACL information which is very bulky in the session object
              or to store it into a statefull session bean and store the handle to
              that bean in the HttpSession object
              I "feel" it might be preferable to bulk the Session bean than to bulk
              the HttpSession object. Weblogic documentation discourages making the
              HttpSession object heavy citing replication issues. But wouldnt the same
              issues arise when we store a lot of information on the Session Bean.
              Also do all attributes of the Session bean need to be Serializable to
              support clustering.
              Any help will be appreciated.
              Thanks
              Sameer
              

    Sticky -- it will continue to go back until the session or the server dies.
              Peace,
              Cameron Purdy
              Tangosol Inc.
              << Tangosol Server: How Weblogic applications are customized >>
              << Download now from http://www.tangosol.com/registration.jsp >>
              "Sameer Wadkar" <[email protected]> wrote in message
              news:[email protected]...
              > If user x makes a call to servlet Y on Machine A where Machine A and B are
              in
              > cluster. If the user makes a second call to Y will the proxy webserver if
              thats
              > what is being used redirect the user call to machine A
              > and not B for sake if laodbalancing?
              >
              > Sameer
              > Cameron Purdy wrote:
              >
              > > Replication uses serialization. Serialization does not take transient
              > > fields. Therefore, even when used in a stateful session bean,
              replication
              > > would not take transient fields.
              > >
              > > Peace,
              > >
              > > --
              > > Cameron Purdy
              > > Tangosol, Inc.
              > > http://www.tangosol.com
              > > Tangosol: How Weblogic applications are customized
              > >
              > > "Sameer Wadkar" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > Cameron,
              > > >
              > > > One last question? If I have a stateful session bean and I have an
              handle
              > > to
              > > > it. In a clustered environment would a transient field inside a
              Stateful
              > > > Session bean NOT BE replicated. I understand the situation for
              HTTPSession
              > > > objects. I just want to confirm if the situation is treated in
              identical
              > > > fashion while replicating Stateful Session Beans.
              > > > If I am working in a clustered environment and a client has
              established an
              > > > HTTPSession with respect to my server. When the client makes repeated
              > > calls to
              > > > the server in the context of that session is the client request
              forwarded
              > > to
              > > > the same server each time if there is no failover or to diff servers
              in
              > > the
              > > > cluster to meet loadbalancing req.
              > > > Also what is preferable (I am now not talking of clusteringnow : just
              > > > performance issues in a single server) storing a large object in
              > > HTTPSession
              > > > object or
              > > > putting that large object in a Stateful Session Bean and storing its
              > > handle in
              > > > the Session object(We need that object practically everytime a
              Controller
              > > > Servlet fires). Weblogic guys suggested to us that the session object
              > > should be
              > > > kept as small as possible to which I agree hence I thought of this
              > > solution.
              > > >
              > > > I would appreciate your response. We are using Weblogic 6.0
              > > >
              > > > Regards,
              > > > Sameer
              > > >
              > > > Cameron Purdy wrote:
              > > >
              > > > > Sameer,
              > > > >
              > > > > You are joking, right? Replicating a sh?tload of stuff across a
              cluster
              > > is
              > > > > expensive. Cached items that can be reloaded on another server in
              the
              > > rare
              > > > > case of failover should not be replicated, since they can be
              reloaded on
              > > > > another server in the rare case of failover. If you want your
              > > application to
              > > > > perform well, don't replicate things that you don't have to!
              > > > >
              > > > > Here's the math:
              > > > >
              > > > > - 1 in pf chance of a request having to failover, where pf should be
              at
              > > > > least 10,000,000
              > > > > - cb is the number of bytes being replicated, and f1(cb) is the cost
              of
              > > > > replicating
              > > > > - f2(cb) is the cost of loading the cache from the database (for
              > > example)
              > > > >
              > > > > If f2(cb)/pf is greater than f1(cb) then you should not replicate
              the
              > > cache.
              > > > > Generally that means that if you replicate the cache, you are
              expecting
              > > each
              > > > > server to die after serving between one and two requests. If that is
              the
              > > > > case, you are really hosed to begin with.
              > > > >
              > > > > If you have an object stored in the HTTP session, and that object
              has a
              > > > > transient field, the contents of the transient field are not
              replicated.
              > > > > That means that you can store your cache in a transient field on an
              > > object
              > > > > that you store in the HTTP session, and you will not pay a
              significant
              > > > > replication price on it. The accessor for the cache should follow
              the
              > > lazy
              > > > > pattern such that on failover it will reload the cache.
              > > > >
              > > > > For even more performance, you should implement Externalizable,
              since
              > > you
              > > > > can improve the performance of ser/deser by a factor of 3 to 10 or
              so.
              > > > >
              > > > > Peace,
              > > > >
              > > > > --
              > > > > Cameron Purdy
              > > > > Tangosol, Inc.
              > > > > http://www.tangosol.com
              > > > > Tangosol: How Weblogic applications are customized
              > > > >
              > > > > "Sameer Wadkar" <[email protected]> wrote in message
              > > > > news:[email protected]...
              > > > > > How would it matter. Both the Session Bean and The Session object
              are
              > > > > > destriyed whrn the user logs off.
              > > > > >
              > > > > > Cameron Purdy wrote:
              > > > > >
              > > > > > > If it is just a cache, then you need to prevent it from being
              > > > > replicated.
              > > > > > > Use a "transient" field or implement Externalizable on that
              object
              > > to
              > > > > > > control serialization and avoid serializing cached objects.
              > > > > > >
              > > > > > > Peace,
              > > > > > >
              > > > > > > --
              > > > > > > Cameron Purdy
              > > > > > > Tangosol, Inc.
              > > > > > > http://www.tangosol.com
              > > > > > > Tangosol: How Weblogic applications are customized
              > > > > > >
              > > > > > > "Sameer Wadkar" <[email protected]> wrote in message
              > > > > > > news:[email protected]...
              > > > > > > > Hi,
              > > > > > > >
              > > > > > > > We are clustering on Weblogic 6.0. Currently we are debating
              on
              > > > > whether
              > > > > > > > to cache out ACL information which is very bulky in the
              session
              > > object
              > > > > > > > or to store it into a statefull session bean and store the
              handle
              > > to
              > > > > > > > that bean in the HttpSession object
              > > > > > > > I "feel" it might be preferable to bulk the Session bean than
              to
              > > bulk
              > > > > > > > the HttpSession object. Weblogic documentation discourages
              making
              > > the
              > > > > > > > HttpSession object heavy citing replication issues. But
              wouldnt
              > > the
              > > > > same
              > > > > > > > issues arise when we store a lot of information on the Session
              > > Bean.
              > > > > > > > Also do all attributes of the Session bean need to be
              Serializable
              > > to
              > > > > > > > support clustering.
              > > > > > > >
              > > > > > > > Any help will be appreciated.
              > > > > > > >
              > > > > > > > Thanks
              > > > > > > > Sameer
              > > > > > > >
              > > > > >
              > > >
              >
              

  • Global object visible for all sessions in WebDynpro application

    Hello everybody,
    in a normal java web application you have the possibility
    to put an object into the servlet context.
    This object is visible for all sessions(e.g. some configurations or global settings for the
    web application).
    Now my question:
    Is there a possibility in a WebDynpro application to put such an object into a "global context" visible for all sessions?
    So I am looking for a container in WebDynpro which has
    the same behaviour like the servlet context in a web application.
    Thank you for your ideas an suggestions.
    Greetings
    Anton

    Hi Anton,
    To make an Variable Global ,you have define variable at various levels based on Usage.
    1)Ex: If you want to define Variable between two different Components . when A component is embedded into B Component then you have to define at Component Interface level and Mapping has to be Defined.
    2) If you want to make Variable to be used within the component among the Iviews ,then you can define at Component Controller or Custom Controller and Mapping has to be defined at Iview Level.
    3) If you want to use Variable between two Webdynpro Iviews then you have define the eventing mechanism to pass the values among the EP Webdynpro Iviews.
    Hope this answer helps you.
    Thanks
    Madhan

  • Killing all sessions at once who are locking the objects

    Hello all,
    i am working in 9i Oracle RDBMS on AIX IBM OS
    most of the time we face locking issue and there comes more then different 50 sessions which locking different tables.
    here is my script to find out what sessions are locking what tables.
    set lines 200
    set pages 50000
    col SID for 99999
    col SERIAL# for 999999
    col username format a12
    col sql format a55
    col event format a50
    col program format a40
    col MINS for 9999
    col ID1 for 999999
    col object_name for a35
    col locktype for a8;
    select  /*+ ORDERED */ s.sid,s.serial#,s.status,round(s.last_call_et/60) MINS,s.program,l.ID1,d.object_name,d.object_type,l.type as locktype
    from v$lock l,v$session s, dba_objects d
    where l.sid = s.sid
    and l.ID1 = d.object_id
    and s.username = 'MULDMS'
    and last_call_et > 120 and l.type <> 'TX' order by s.status,MINS,l.ID1,l.type; and the out put it gives something like
      SID SERIAL# STATUS    MINS PROGRAM                                      ID1 OBJECT_NAME                         OBJECT_TYPE        LOCKTY
    8981    1069 ACTIVE       2 frmweb@Appsdms31 (TNS V1-V3)               30407 VH_BTN                              TABLE              TM
    1642     512 ACTIVE      15 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
      690    1057 ACTIVE      17 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
      699    1787 ACTIVE      17 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
      690    1057 ACTIVE      17 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
      690    1057 ACTIVE      17 [email protected] (TNS V1-V3)    30643 VT_CHECK_INOUT                      TABLE              TM
    10877     895 ACTIVE      18 [email protected] (TNS V1-V3)     28846 AM_DOCS                             TABLE              TM
    6654    1085 ACTIVE      18 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    1912    1655 ACTIVE      18 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    10877     895 ACTIVE      18 [email protected] (TNS V1-V3)     30407 VH_BTN                              TABLE              TM
    6654    1085 ACTIVE      18 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    1912    1655 ACTIVE      18 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    1754    1582 ACTIVE      18 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    10877     895 ACTIVE      18 [email protected] (TNS V1-V3)     30643 VT_CHECK_INOUT                      TABLE              TM
    6654    1085 ACTIVE      18 [email protected] (TNS V1-V3)    30643 VT_CHECK_INOUT                      TABLE              TM
    10708     982 ACTIVE      19 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    5428     855 ACTIVE      19 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    10708     982 ACTIVE      19 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    5428     855 ACTIVE      19 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    10278     897 ACTIVE      20 [email protected] (TNS V1-V3)     28846 AM_DOCS                             TABLE              TM
    6261    1056 ACTIVE      20 frmweb@appsdms12 (TNS V1-V3)               28846 AM_DOCS                             TABLE              TM
    6598    1413 ACTIVE      20 [email protected] (TNS V1-V3)     28846 AM_DOCS                             TABLE              TM
    1312    1000 ACTIVE      20 [email protected] (TNS V1-V3)    28846 AM_DOCS                             TABLE              TM
    10278     897 ACTIVE      20 [email protected] (TNS V1-V3)     30407 VH_BTN                              TABLE              TM
    6261    1056 ACTIVE      20 frmweb@appsdms12 (TNS V1-V3)               30407 VH_BTN                              TABLE              TM
    1312    1000 ACTIVE      20 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    3521     717 ACTIVE      20 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    6598    1413 ACTIVE      20 [email protected] (TNS V1-V3)     30407 VH_BTN                              TABLE              TM
    6598    1413 ACTIVE      20 [email protected] (TNS V1-V3)     30643 VT_CHECK_INOUT                     TABLE              TM
    1312    1000 ACTIVE      20 [email protected] (TNS V1-V3)    30643 VT_CHECK_INOUT                   TABLE              TM
    9131    1002 INACTIVE     2 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
    4887    1040 INACTIVE     2 [email protected] (TNS V1-V3)     30455 VH_PSF                              TABLE              TM
      151    1982 INACTIVE     2 [email protected] (TNS V1-V3)     80224 RD_ENQEXD                           TABLE              TM
      846     988 INACTIVE     3 [email protected] (TNS V1-V3)    29228 GM_VIN                              TABLE              TM
    5364    1149 INACTIVE     3 [email protected] (TNS V1-V3)    30407 VH_BTN                              TABLE              TM
    9934     789 INACTIVE     3 [email protected] (TNS V1-V3)     30455 VH_PSF                              TABLE              TM
    7511    1092 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
    3595    1104 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
      846     988 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TM
      945     670 INACTIVE     3 [email protected] (TNS V1-V3)    30455 VH_PSF                              TABLE              TMand then i have to kill the session one by one . thaat is a tedious task to do.
    i want to modify this script which will give me all the kill statement and i just have to run it
    can someone help me in this regard as i am weak in sql/plsql
    thanks and many thanks

    >
    i want to modify this script which will give me all the kill statement and i just have to run it
    >
    Karthick's script will 'kill' the sessions but before you use that script you may want to read the docs about the KILL and DISCONNECT clauses.
    See the DISCONNECT SESSION and KILL SESSION clauses in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_2013.htm#sthref4724
    >
    DISCONNECT SESSION Clause
    Use the DISCONNECT SESSION clause to disconnect the current session by destroying the dedicated server process (or virtual circuit if the connection was made by way of a Shared Sever).
    The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without waiting for ongoing transactions to complete.
    KILL SESSION Clause
    The KILL SESSION clause lets you mark a session as terminated, roll back ongoing transactions, release all session locks, and partially recover session resources.
    IMMEDIATE Specify IMMEDIATE to instruct Oracle Database to roll back ongoing transactions, release all session locks, recover the entire session state, and return control to you immediately.
    >
    For DISCONNECT the IMMEDIATE clause will recover the session state 'immediately'.
    Using KILL, even with the IMMEDIATE clause, you are telliing Oracle to roll back any ongoing transactions and that can take a lot of time.
    Make sure you are really doing the operation you want to do. If you want to get the locks released immediately you need to use 'DISCONNECT IMMEDIATE'.

  • Memory limitation for session object!

    what is the memory limitation for using session objects?
    venu

    as already mentioned there is no actual memory limitation within the specification, it only depends on the jvm's settings
    how different app-server handle memory management of session objects is another part of the puzzle, but in general you should not have problems in writting any object to the session.
    we had the requirement once to keep big objects in session, we decided to do a ResourceFactory that returns us the objects, and only store unique-Ids into the session.
    We could lateron build on this and perform special serialization tasks of big objects in the distributed environment.
    Dietmar

  • How to validate a session object in jsp?

    Hi All,
    i am facing a problem.The problem is how to validate the session object object in jsp.I have written a java script by using a defined function as setInterval and has given 5 mintues if the user is idle and will show a pop up menu before time out the session but in case of page active still this pop up menu is coming. The java script as follows.
    function SetTimer(){
         //How long before timeout (should be a few minutes before your server's timeout
         //set timer to call function to confirm update
         if(timeoutMinutes)
         timerObj = setInterval("ConfirmUpdate()",60000);
    function clearTimerFn(){
              timerCount = 0;
              clearInterval(timerObj);
              //timerObj = setInterval("ConfirmUpdate()",60000);
    function ConfirmUpdate(){
         //Ask them to extend
         if(confirm("Your session is about to expire. Press 'OK' to renew your session.")){
              //load server side page if ok
              var url = "ajaxSessionchecker.do?sessionvalidate=sessionvalid";
              LoadXMLDoc(url);
    And in jsp i am calling this js function as
    <%session=request.getSession(false);
              if(session.getLastAccessedTime()==60000){ %>
              <script type="text/JavaScript">
         clearTimerFn();
    </script>
    <%}else{
    session.setMaxInactiveInterval(-1000);} %>
    could you pls help me out?

    The reason for doing this is when ever i come to this user.jsp from account.jsp with a different account number this user.jsp is not refreshed and i still
    see the same old user.jsp for the previous account that i naviated before. Also please let me know if there is any other approach to acheive this taskDoes refreshing the page by pushing F5 solve the problem?
    If so, then the browser is caching the page, despite your attempts to stop it.

  • Get session object in a class

    hi,
    is possible obtain the session object in a class method without send it from jsp as a parameter?

    you mean like this?
         public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest req,
              HttpServletResponse res)
              throws Exception {
              SessionManager sm = new SessionManager(req);
                                    ....sessionmanager class
    package com....;
    import java.util.*;
    import java.lang.reflect.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.http.*;
    import org.apache.log4j.*;
    * <code>SessionManager</code> is a wrapper for request, response and session
    * @author
    public class SessionManager {
         static Logger log = Logger.getLogger(SessionManager.class);
         ** Holds string containing the unique identifier assigned to this session
         private String sessionid;
         ** Holds HttpSession object
         private HttpSession session;
         ** Holds request object object - must be passed in by the calling application
         private HttpServletRequest request;
         ** Holds response object - any application sending a response must call
         ** session manager
         private HttpServletResponse response;
         ** Holds Servlet Context - useful if logging is reqd.
         private ServletContext context;
          * Page context.
         private PageContext pctx = null;
         ** Constructor to initialize with a request object
         public SessionManager(HttpServletRequest req) {
              request = req;
              session = req.getSession();
              sessionid = session.getId();
         ** Constructor to initialize with a pagecontext object - convenient to call from jsp's
         public SessionManager(PageContext pctx) {
              request = (HttpServletRequest) pctx.getRequest();
              response = (HttpServletResponse) pctx.getResponse();
              context = pctx.getServletContext();
              session = pctx.getSession();
              sessionid = session.getId();
              this.pctx = pctx;
         ** Constructor to initialize with request, response objects
         public SessionManager(HttpServletRequest req, HttpServletResponse resp) {
              request = req;
              response = resp;
              session = req.getSession();
              sessionid = session.getId();
         ** Constructor to initialize with request, servletcontext objects
         public SessionManager(HttpServletRequest req, ServletContext ctx) {
              request = req;
              context = ctx;
              session = req.getSession();
              sessionid = session.getId();
         ** Constructor to initialize with request, response and context objects
         public SessionManager(HttpServletRequest req, HttpServletResponse resp, ServletContext ctx) {
              request = req;
              response = resp;
              context = ctx;
              session = req.getSession();
              sessionid = session.getId();
         ** Setter and getter methods
         public void setRequest(HttpServletRequest req) {
              request = req;
              session = req.getSession();
              sessionid = session.getId();
         ** Setter and getter methods
         public void setContext(ServletContext ctx) {
              context = ctx;
         ** Setter and getter methods
         public ServletContext getContext() {
              return context;
         public void createLoginSession(java.io.Serializable obj) {
              if (obj == null)
                   log.debug("Object is null");
              setAttribute("user", obj);
         public void setAttribute(String key, java.io.Serializable obj) {
              session.setAttribute(key, obj);
         public void removeAttribute(String key) {
              session.removeAttribute(key);
         ** Setter and getter methods
         public HttpServletRequest getRequest() {
              return request;
         ** Setter and getter methods
         public HttpServletResponse getResponse() {
              return response;
         ** Checks if either member session or guest session exists
         public boolean isLoggedIn() {
              if (session.getAttribute("user") != null)
                   return true;
              else
                   return false;
         public long getCreationTime() {
              return session.getCreationTime();
         ** Setter and getter methods
         public String getId() {
              return session.getId();
         public long getLastAccessedTime() {
              return session.getLastAccessedTime();
         public int getMaxInactiveInterval() {
              return session.getMaxInactiveInterval();
         ** Setter and getter methods - also useful for retrieving state object(s)
         public Object getAttribute(String name) {
              if (session != null)
                   Object sObject = session.getAttribute(name);
                   //Log.debug("Session State for the object "+name+" is "+sObject);
                   return sObject;
              else
                   return null;
         ** Setter and getter methods - gets enum of all stored state objects
         public Enumeration getAttributeNames() {
              return session.getAttributeNames();
         public void invalidate() {
              session.invalidate();
              // Remove all object that is bound to this session
              //wip : Resetting instance variable.
              //This is necesary as further operations on session will
              //result in illegalstateexception
              session = null;
         public boolean isNew() {
              return session.isNew();
         public void setMaxInactiveInterval(int interval) {
              session.setMaxInactiveInterval(interval);
          * This method returns the host url in the form "www.carclub.com".
          * <p>
          * The return value is compatible with default_website field of clubs DB table.
          * </p>
          * @return host url present as part of the http request object
         public String getHostURL()
              if (request == null)
                   return null;//No request object present, hence return null
              String str = request.getServerName();
              //Log.debug("--- The request URL is --- " + str);
              return str;
          * Flushes <code>out</code> stream.
         public void flush()
              throws IOException
              if (pctx != null)
                   pctx.getOut().flush();
    }

  • Access Session objects

    Hi you all,
    How can I access, from a normal class which doesn't extend the HttpServlet abstract class, any session objects that might have been stored. It is a requirement that all the classes that I am using which make part of the bussiness logic cannot extend the HttpServlet. Since the HttpServlet in an abstract class I cannot create an instance of it... so how can I access any session objects without extending the HttpServlet class.
    Any help is welcome,
    Thanks,
    MeTitus

    You could pass the session object as a parameter to the contructor or in any method calls. However most people will tell that this is poor design an dyou should extract any needed data from the session and only pass that data to the objects instead of the entire session object.

  • How do I  call a DeleteAllQuery stored in the session object?

    Hi all,
    I have a DeleteAllQuery that I have stored in my session object by name (PURGE_IRLE):
    srvSession.addQuery(DaoConst.PURGE_IRLE, delq);
    I have RTFM:ed but the only description for deleteing that I could find delets individual objects. I couldn't find an example for DeleteAllQuery. :-(
    I set the reference class when I define the query but I'm confused by the getObjects() and setObjects() methods.
    Q1: When do I need to call them?
    Q2: How do I call this query?
    Q3: Which Session.executeQuery(...) should I use? (this relates to 1 & 2).
    Q4: How do I get back the number of rows deleted? execute returns an Object; can I assume it's an Integer containing the numbers of rows deleted?
    Many thanks in advance,
    Andrei Lenkei

    Ok, but this causes me some problems because:
    1) I can't really use SQL because I need a notExists subquery access on a TopLink object that represents a join (in the pre-TopLink version of the code the object was represented by a temporary table; I could put that whole select as a subquery to the subquery but that's not very elegant and would be quite inefective)
    2) This could be hundreds/thousands of row; wouldn't deleteing them 1-by-1 be extremly inefective?
    Isn't there a way i can call the DeleteAllQuery the same way TopLink would call it?
    Regards,
    Andrei Lenkei

  • How to detect session objects in a project

    Hi,
    There are many session objects in our project which has over 1000 classes. What would you suggest as the best practice to identify all of them. I am using eclipse. How to detect they are serialized or not. If not serialized how could i make sure they are serializable or not.?
    Appreciate your time.
    Pralav

    If not serialized how could i make sure they are serializable or not.?By implementing the Serializable interface.
    If you want to ensure they can't be serialised, then you implement Externalisable and throw exceptions when you override readExternal() and writeExternal()
    As for identifying the objects that are added to a session.... do a search for things like session.setAttribute() on your code. No easy way.
    regards,
    Owen

  • Storing array(or other data structure) in a session object

    hi wise ones
    to minimise my calls to a database I would like to store the information retrieved from a ResultSet in an array and then store this in a session object, retrieving it with getAttribute("nameOfArray"); when I need it.
    I have tried to print the object contents to test what is happening but am getting a[b] [Ljava.lang.String;@11d646c[/b] response which is something, but not what I expected.
    Is using a session the right way to make the information available to all servlets? If not what other method is appropriate?
    thank you

    thanks for your comments Annie & MLRon. I have tried both suggestions but am still hitting problems
    the usual method to get the elements results in my compiler complaining that sessionINFO is an object and .length cannot be applied to an object.
    for (int i = 0; i < sessionINFO.length; i++) {
                       out.print(sessionINFO);
                   out.print("<BR>");
    An array IS an object though?
    I have used Arrays.asList(sessionINFO) and get another compiler error stating that java.util.Arrays cannot be applied to an object
    I took my variables from the ResultSet and converted them all to Strings and put them into a String array
    int bankIDLogin=customerResults.getInt("id");
                                   //convert to String for array
                                   String bankIDLoginSTR = String.valueOf(bankIDLogin);
                                  String passwordLogin =customerResults.getString("password");
                                  String accNo=customerResults.getString("number");
                                  float accBal=customerResults.getFloat("balance");
                                  //convert to String for array                              
                                  String accBalSTR = String.valueOf(accBal);
                                  //put info into array
                                  String[]customerDetails={bankIDLoginSTR,passwordLogin,accNo,accBalSTR};then I put that array into the session object
                        HttpSession session =req.getSession(true);
                        session.setAttribute("id",bankID);
                        session.setAttribute("customerdetails",customerDetails);In a separate servlet I called the session object
    Object sessionINFO = session.getAttribute("customerdetails");How can I get the original array out of this object?
    What should I do if more than one result set is created and I need to create two session objects with customer details, (one customer has two accounts)? multi dimensional array?

  • Session object question put vs. putValue vs. setAttribute?

    I have the following code:
    <%@ page import="java.util.*" %>
    <jsp:useBean id="EducationBean" class="java.util.Hashtable" scope="session" />
    <%
    String swCurrFileName = "swcontrol.jsp";
    Enumeration params = request.getParameterNames();
    while (params.hasMoreElements()) {
         String name = (String)params.nextElement();
         EducationBean.put(name, request.getParameter(name));
    %>
    My question is I can't find any documentation on the put command, whats the difference between 'put', and 'putValue', and 'setAttribute'? When I try using the 'putValue' or 'setAttribute' command I get errors.
    What I'm trying to do is store form values in a session object across several pages, and on the last page display all the form values from the previous pages.

    the object you are calling put on is a java.util.Hashtable. put places an object into the table to be keyed off of another object. In your case, your key is the variable name and the object to be stored is your parameter from that name.
    the putValue and setAttribute are methods on the session object. They both do the same action as above, but are for HttpSession objects. putValue is deprecated and you should be using setAttribute, but most WebServers have putValue() pointing to the setAttribute() method. hope this helps.

  • Lost Object[] data after serialization

    Hi all,
    I posted this problem already in the servlet forum, but now I found out that it's more a serialization problem. I hope you guys can help me!!!!
    I have a problem sending a serialized object from a java application to a servlet (inside Tomcat).
    I'm using Commons HttpClient's PostMethod to get a connection to the servlet over https. The encryption should be done automatically within HttpClient and Tomcat.
    The object container I'm sending contains a few Strings and an Object[] that is filled with Strings.
    The container i'm sending implements Serializable.
    The connection is working fine, and the object has no serialization problems but the incoming request at server-side is kind of broken.... The single Strings are the same I've set on client-side, but the Object[] is null. I tried it with directly sending the ArrayList but with the same result.
    The size of the incoming data stream is the same as it was on client side.
    The funny thing is that sending data back from server to client works perfectly fine. My Object[] goes through without any problems!
    Here is the client code I'm using:
    PostMethod method = new PostMethod(mServerUrl);
    MyContainer container = new MyContainer("Message2Server",new Object[]{"ArrayElement1"});
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    ObjectOutputStream serializer = new ObjectOutputStream(byteStream);
    serializer.writeObject(container);
    serializer.flush( );
    serializer.close();
    method.setRequestHeader("Content-Type","binary/x-java-serialized");
    ByteArrayRequestEntity output = new ByteArrayRequestEntity(byteStream.toByteArray());
    method.setRequestEntity(output);
    mClient.executeMethod(method);...and here is the servlet code:
    InputStream is = request.getInputStream();
    ObjectInputStream ois = new ObjectInputStream(is);
    MyContainer out = (MyContainer) ois.readObject();
    out.getString1(); //<-- is OK!
    out.getString2(); //<-- is OK!
    out.getObjectArray(); //<-- is null!!!!!!
    out.setObjectArray(new Object[]{"Message for the Client!!!"});
    response.setContentType("binary/x-java-serialized");
    // get output stream and send it back
    OutputStream os = response.getOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(os);
    oos.writeObject(out);
    oos.flush();
    oos.close();Does anybody see a solution????
    I think it just could be two things:
    - Serialization fails for any reason?!
    - The Servlet InputStream fails?
    Thanx for any help!
    CU Jan

    This looks very useful to me. Can you tell us what
    the typo was?Considering he/she hasn't posted for 4 months, I'd doubt it.

  • Http session object in portal

    Hi,
    I am working on weblogic portal 9.2
    I am seeing some weird behavior while handling http session object.
    I have a desktop contains 2 page flow portlet and 1 Jsp/Html portlet.
    On Portal Admin I have created 2 differennt desktop as below.
    1.http://localhost:7001/Test/appmanager/desk/desk1
    2.http://localhost:7001/Test/appmanager/desk/desk2
    Desktop 1 will put some value in session but when I am running the other desktop i.e. desk2 then desk2 is receiving the same session value that desktop 1 put.. Not sure why?
    Generally for every desktop URL new Http Session should be created. But in my Case old session is sharing between 2 desktop.
    Java code
    HttpSession session = request.getSession(false);
    session.getAttribute("");
    JSP
    <%@ page session="false"%>
    In non Portal application, we can have control to all the href but in case of Portal we are getting data from content management that provides href.
    Edited by: user11311969 on Oct 9, 2009 4:58 AM
    Edited by: user11311969 on Oct 9, 2009 5:23 AM

    Hi,
    Thanks for the replay.
    You are right If I add desktop name in session then atleast I can insure that correct desktop is fetching the session value.
    Ok But while rending both the desktop there is common code that put some values in session.
    Let say Desktop1 put "name = Desktop1" and "Value = "MyDesktop" in session.
    After that I run Desktop2, that will put "name = Desktop2" and "Value = "OtherDesktop " in session.
    i.e when I run Desktop1, then I should get "name = Desktop1" and "Value = "MyDesktop "
    when I run Desktop2, then I should get "name = Desktop2" and "Value = "OtherDesktop "
    If I click any link on Desktop1 then i will get "name = Desktop2" and "Value = "OtherDesktop " because Desktop2 has already overwrite the session value.
    How can I solve this?

  • Question about app design - database + session object in JSP

    hi all
    i am studying this application built mostly with servlets and JSPs, and there are several questions i want to ask your guys' opinions about it.
    first of all, i noticed that the application hits database to get/save data very frequently. from one page to another it would save data collected from user to the DB, and retrieve data from DB to display on the next page. it does this a lot. would this decrease the overall performance of the application, i mean a DB hit requires network traffic overhead, wouldn't it be better if all data collected from user are stored in a session object temporarily, and all the data that are displayed on those pages retrieved at the start time? and do one save process in the end. it uses Oracle DB if it makes any difference. should we try to avoid db hit as much as possible?
    my next question is that is it good approach to keep information in session object? even if there is a lot of data to keep?
    another question is the db connection. in a pooled environment - weblogic server, we would use JNDI in the code to get connection from the pool, we use it and close it. when we close a connection with close() method, what really happens? does this connection gets return to the pool or it is being destroyed completely.
    i know this is a lot to ask, i appreciate your help very much. looking forward to seeing some feedback.

    No, I don't have tables of values. I have a java 1.5 enumeration, like for instance:
    public enum VelocityConvention {
       RELATIVISTIC,
       REDSHIFT;
    }and a class Velocity that contains a convention and a value like so:
    public class Velocity {
       public VelocityConvention getConvention() {...}
       public double getValue() {...}
       public void set(VelocityConvention conv, double value) {...}
    }When I persist the Velocity class to the database, I want a field called convention that holds the appropriate value of the enumeration. That much is done how I explained before.
    I want to have a selectOneMenu for setting the convention. Via trial and error, I found that MyFaces wasn't able to automatically convert from a string back to a proper VelocityConvention enum constant. It can, of course, convert from the enum to a string because it just calls toString(). But I need both directions for any UIInput element I use, be it a selectOne, or just a straight inputText.

Maybe you are looking for

  • How to delete multiple variables from the variables list

    Hello, Iam using FrameMaker 9.0. Is there a way I can select multiple variables from the book and delete them together. Thanks, CP.

  • Need Help on how to center Pop Ups

    Here's what I'm trying to do - I have thumbnails on my site and when you click on them I want a larger image to show up in a pop up. I've accomplished this by: 1. Clicking on the thumb and adding "javascript:;" as the link 2. Clicking on <a> so I can

  • How do I import a quicktime movie?

    Hi, I think this is a super simple question, How do I import a quicktime movie onto my page? I presume you go to insert>media>? not to sure what comes next though? Is it shockwave,applet,active x or plugin? Thanks, Beth H

  • Cannot import videos to iTunes

    So I downloaded a video, and want to get it onto my iPod. When trying by File > Import... > etc., I get the message "+The file 'blank.flv' cannot be imported because it does not appear to be a valid exported file."+ The file is (when I downloaded it)

  • Airport Wireless error message,

    I keep getting this error message: "Invalid Password" I just bought the new macbook and this is my first macbook. So I don't know what I am doing wrong or if I should be doing something different? Thanks~