Stateful Bean replication

Hi,
          Is this possible to deploy some Stateful SessionBean on few different WL
          instances in cluster in such way that content of each bean will be the same
          in every time???
          I mean that, if anybody will update Stateful SessionBean on first instatnce
          of WL, replication will make the same copy of bean on each WL instances and
          hance the user who will connect to second instance of WL will get the same
          content of bean like in first instance.
          If it is possible, are there any special recommends to accomplish it?
          Best regards,
          Robert
          

Our replication uses a primary-secondary scheme where all requests are always
          directed to the primary copy unless the server on which it is residing fails...
          "Robert Zaczyñski" wrote:
          > Hi,
          >
          > Is this possible to deploy some Stateful SessionBean on few different WL
          > instances in cluster in such way that content of each bean will be the same
          > in every time???
          >
          > I mean that, if anybody will update Stateful SessionBean on first instatnce
          > of WL, replication will make the same copy of bean on each WL instances and
          > hance the user who will connect to second instance of WL will get the same
          > content of bean like in first instance.
          >
          > If it is possible, are there any special recommends to accomplish it?
          >
          > Best regards,
          > Robert
          

Similar Messages

  • Stateful bean not failing over

              I have a cluster of two servers and a Admin server. Both servers are running NT
              4 sp6 and WLS6 sp1.
              When I stop one of the servers, the client does n't automatically failover to
              the other server, instead it fails unable to contact server that has failed.
              My bean is configured to have its home clusterable and is a stateful bean. My
              client holds onto the remote interface, and makes calls through this. If Server
              B fails then it should automatically fail over to server A.
              I have tested my multicast address and all seems to be working fine between servers,
              my stateless bean work well, load balancing between servers nicely.
              Does anybody have any ideas, regarding what could be causing the stateful bean
              remote interface not to be providing failover info.
              Also is it true that you can have only one JMS destination queue/topic per cluster..The
              JMS cluster targeting doesn't work at the moment, so you need to deploy to individual
              servers?
              Thanks
              

    Did you enable stateful session bean replication in the
              weblogic-ejb-jar.xml?
              -- Rob
              Wayne Highland wrote:
              >
              > I have a cluster of two servers and a Admin server. Both servers are running NT
              > 4 sp6 and WLS6 sp1.
              > When I stop one of the servers, the client does n't automatically failover to
              > the other server, instead it fails unable to contact server that has failed.
              >
              > My bean is configured to have its home clusterable and is a stateful bean. My
              > client holds onto the remote interface, and makes calls through this. If Server
              > B fails then it should automatically fail over to server A.
              >
              > I have tested my multicast address and all seems to be working fine between servers,
              > my stateless bean work well, load balancing between servers nicely.
              >
              > Does anybody have any ideas, regarding what could be causing the stateful bean
              > remote interface not to be providing failover info.
              >
              > Also is it true that you can have only one JMS destination queue/topic per cluster..The
              > JMS cluster targeting doesn't work at the moment, so you need to deploy to individual
              > servers?
              >
              > Thanks
              Coming Soon: Building J2EE Applications & BEA WebLogic Server
              by Michael Girdley, Rob Woollen, and Sandra Emerson
              http://learnweblogic.com
              

  • Stateful bean clustering

    Hi,
              Does weblogic 5.1 support stateful bean clustering? If not how to achive this?
              Thanks in advance,
              vivek
              

    6.x supports stateful session beans clustering (replication and failover), but not 5.1.
              Vivek <[email protected]> wrote:
              > Hi,
              > Does weblogic 5.1 support stateful bean clustering? If not how to achive this?
              > Thanks in advance,
              > vivek
              Dimitri
              

  • Stateful  bean handle in HttpSession

              Hi ,
              I have environment where i create a pool of stateful EJB's and I store the pool
              in the servlet context. For each requests I obtain the refernce to the ejbhandle
              from the pool and exceute the method on the stateful bean. I use this ejbhandle till
              the session is ended. Is there any problem with this sort of design in the clustering
              environment?
              As per the httpsession replication after the state of the object stored in the sesion
              is changed , setAttribute method has to be called for the replication. So is it the
              same for ejbhandle also?
              After I call some methos on the SFEJB (getting a reference via EJBHandle in the session),
              do I have to call set sttaribute and pass the ejb handle for the replication?
              Any amount of feed back is appreciated.
              Thanks,
              sri
              

    The handle is serializable and portable. You can put it into the HTTP
              session. If you don't use setAttribute, the data won't get replicated. For
              example:
              Object[] ao = new Object[10];
              session.putAttribute("test", ao);
              // replication occurs
              ... later ...
              Object[] ao = (Object[]) session.getAttribute("test");
              ao[3]="hello world";
              // no replication occurs
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com/coherence.jsp
              Tangosol Coherence: Clustered Replicated Cache for Weblogic
              "sri" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Hi ,
              >
              > I have environment where i create a pool of stateful EJB's and I store
              the pool
              > in the servlet context. For each requests I obtain the refernce to the
              ejbhandle
              > from the pool and exceute the method on the stateful bean. I use this
              ejbhandle till
              > the session is ended. Is there any problem with this sort of design in
              the clustering
              > environment?
              >
              > As per the httpsession replication after the state of the object stored in
              the sesion
              > is changed , setAttribute method has to be called for the replication. So
              is it the
              > same for ejbhandle also?
              > After I call some methos on the SFEJB (getting a reference via EJBHandle
              in the session),
              > do I have to call set sttaribute and pass the ejb handle for the
              replication?
              >
              > Any amount of feed back is appreciated.
              >
              > Thanks,
              > sri
              >
              

  • EJB 3.0 Stateful bean not saving state while Stateless bean is !!!

    My Stateless bean is as follow:
    package test;
    import javax.ejb.Stateless;
    @Stateless(mappedName = "StatelessBean")
    public class StatelessBean implements StatelessBeanRemote {
         int counter;
         public void increment(){
              System.out.println("Stateless counter value:"+counter);
              counter++;
    My Stateful bean is as follow:
    package test;
    import javax.ejb.Stateful;
    @Stateful(mappedName = "StateFulBean")
    public class StateFulBean implements StateFulBeanRemote {
         int counter;
         public void increment(){
              System.out.println("Stateful counter value:"+counter);
    Client is as follows:
    package test;
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    public class TestClient {
         public static void main(String[] args) {
              Hashtable hashtable = new Hashtable();
              hashtable.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
              hashtable.put(Context.PROVIDER_URL, "t3://localhost:7001");
              InitialContext ic;
              try {
                   ic = new InitialContext(hashtable);
                   StateFulBeanRemote stateFulBeanRemote = (StateFulBeanRemote)ic.lookup("StateFulBean#test.StateFulBeanRemote");
                   stateFulBeanRemote.increment();
                   StatelessBeanRemote statelessBeanRemote = (StatelessBeanRemote)ic.lookup("StatelessBean#test.StatelessBeanRemote");
                   statelessBeanRemote.increment();
              } catch (Exception e) {
                   e.printStackTrace();
    The output i am getting after running the client twice is as follows:
    //first time
    Stateful counter value:0
    Stateless counter value:0
    //second time
    Stateful counter value:0
    Stateless counter value:1
    Shouldn't the counter values be incremented in case of Stateful bean and remain the same for Stateless bean. But the output that I am getting is the complete opposite !!!
    Can anyone please explain this confusing behavior of stateless and stateful ejb 3.0 beans.

    868664 wrote:
    Can anyone please explain this confusing behavior of stateless and stateful ejb 3.0 beans.It is very simple: a stateless bean is ASSUMED to be stateless; you cannot keep state in a stateless bean as a contractual rule. That doesn't mean that you will fail to keep state in them at least for a little while, they are still only Java objects. Generally stateless EJBs are pooled, so you may get the same instance each time you use such an EJB, but you may just get another one. It is not dependable and the rules say don't do it - so don't do it.
    A stateful bean is tied to a single client, and so can be used by a client to keep state in it. Since You are running the client application twice you are operating with two different clients and so you will get a new stateful bean each time and your code will keep printing 0. However there is also a bug in your code:
    public void increment(){
    System.out.println("Stateful counter value:"+counter);
    }You are not incrementing anything.

  • Help me in Stateless & Stateful Bean

    hi,
    I'm trying to understand to difference between the stateless and stateful bean. I had created an simple application to test it. But both the beans seems to work in the same way. Could some one explain me with an example the difference between the stateful and stateless bean ...
    I'm using J2EE Reference Implementation and Deploytool .
    Please help me .. Urgent ....
    Cheers !!!
    Prabs

    Thanks!!
    The State Session Bean tries to hold data , even after the client has finished execution. Moreover, the ejbCreate() get fired only once and not for different client.
    Is there anything that I should do to make it stateless.
    this is my code
    Session Bean
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.util.*;
    public class cartEJB implements SessionBean {
         private Map m;
         public cartEJB() { }
         public void ejbCreate() {
         m = new HashMap();
         System.out.println("ejbCreate()");
         public void ejbActivate() { }
         public void ejbPassivate() { }
         public void ejbRemove() { }     
         public void setSessionContext(SessionContext sc) { }
         public void addCart(String product, String price) {
         System.out.println("Its here Man 1");
         m.put(product, price);
         public void showCart() {
              System.out.println("Its here Man 2");
              Set s = m.entrySet();
              Iterator it = s.iterator();
              while(it.hasNext()) {
                   System.out.println(it.next());
    REMOTE
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    public interface cart extends EJBObject {
         public void addCart(String product , String price) throws RemoteException;
         public void showCart() throws RemoteException;
    HOME
    import javax.ejb.EJBHome;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    public interface cartHome extends EJBHome {
         public cart create() throws CreateException, RemoteException;
    client application is an web based application ..
    Client code. ... (jsp:useBean)
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import javax.servlet.http.*;
    public class cartJSP implements HttpSessionBindingListener{
         String Product = new String();
         String Price = new String();
         HttpSession session;
         public cartJSP() {
         public void setProduct(String p){
              this.Product = p;
         public void setPrice(String price) {
              this.Price=price;
         public String getPrice() {
              return Price;
         public String getProduct() {
              return Product;
         public void addIt(String product , String price ) {
         try {
              System.out.println("Comes here");
              Context ic = new InitialContext();
              Object objref = (Object)ic.lookup("ejb/cartJNDI");
              cartHome home = (cartHome)PortableRemoteObject.narrow(objref, cartHome.class);
              cart remote = home.create();          
              remote.addCart(product, price);
              System.out.println("Comes here");
              remote.showCart();     
         catch(Exception e) {
              e.printStackTrace();
         public void showIt() {
         try {
              Context ic = new InitialContext();
              Object objref = (Object)ic.lookup("ejb/cartJNDI");
              cartHome home = (cartHome)PortableRemoteObject.narrow(objref, cartHome.class);
              cart remote = home.create();
              remote.showCart();          
              System.out.println("Comes here 1");
         catch(Exception e) {
              e.printStackTrace();
         public void valueBound(HttpSessionBindingEvent e) {
              session = e.getSession();
              session.setMaxInactiveInterval(60);
              System.out.println("Value Bound");
         public void valueUnbound(HttpSessionBindingEvent e) {
              System.out.println("Value UnBound");
    I'm using J2EE RI 1.3 and I'm deploying components using deploytool.
    Please help me,
    Check the code is wrong or is it a bug in the EJB container.
    regards
    prabu.

  • Handling disconnections in stateful beans

    i have a stateful bean with some resources that it has to close after closing. I programed a close () method, marked as +@Remove+, that clients call to close the resources; and a exiting () method, marked as @PreDestroy to finish the work.
    but, how can i handle unexpected disconnections, for clients frozen, cable network disconnected or the like, when the client () can't call the close method?
    It thought that +@PreDestroy+ method should replace finalize method's, but it doesn't.
    What can i do?

    Ok... Here it goes...
    You can do it in the following manner.
    As you said you have got 2 private methods doing d/b updates and these are called from a public method.
    Stateful session beans since associated with a client across methods, you can take advantage of it. Write your own user defined transaction.
    Begin the transaction scope in your public before calling the 1st private method. Call the 2 methods in a try block. Once you are done with these methods, you can commit and end the transaction. If you get any exception, rollback the transaction in the catch block. Otherwise if u get any exception in the 2nd method, you can rollback the transaction there itself.
    Stateful session beans lets u allow to spawn the bean managed transaction across methods. you can begin your transaction in one method and end it in a differnt method or you can end the transaction after calling the methods.
    The problem you are dealing with can typically very well handled by writing bean managed transaction.
    Hope this helps. If you need anymore clarity on my solution, please let me know.
    -amit

  • Problem with Maintaining State with EJB3 Stateful Bean

    I'm a newbie in EJB3. I've wrote a Stateful bean together with JSF as the UI tier. Below is my Stateful bean.
    package com.dhydrated.business;
    import com.dhydrated.entity.User;
    import java.io.Serializable;
    import javax.ejb.Remove;
    import javax.ejb.Stateful;
    @Stateful
    public class LogonBean
            implements LogonRemote, Serializable {
        private User user;
        public void setUser(User user) {
            this.user = user;
        public User getUser() {
            return user;
    }In above code, I'm storing User object as the private variable. The problem is, whenever I set the User object in the 1st page, I'm unable to retrieve the same user object in the 2nd page. Seems like my Stateful bean does not saved the state or conversation of the bean.
    Appreciate if someone could tell me on how to save the state of above Stateful bean. Is there some other conf. that I might missed out?

    I was find good solution! =)
    *** JScript ***
    <script TYPE="text/javascript">
    <!--
    function popup(myform)
    if (! window.focus) return true;
    var d = new Date();
    windowname = d.getTime();
    window.open('', windowname, 'top=100,left=100,height=200,width=200,location=no,resizable=no,scrollbars=no,status=no');
    myform.target=windowname;
    return true;
    -->
    </script>
    *** JSF ***
    <h:form onsubmit="popup(this)">
    <h:commandButton value="Press Me" actionListener="#{sessionBean.resetCursor}" action="selectElemList" />
    </h:form>
    But it work only with <h:commandButton> tag. If you try to use <h:commandLink>, then 'onsubmit' attribute by <form> tag don't work.
    If you know how make necessary functional with <h:commandLink> tag, please let me know.

  • Stateful beans in cache doesn't seem to work

    I have a stateful bean that I have set max beans in cache to "1". When I deploy it, no errors reported or so, the Weblogic console still states "8" in the column "Cached Beans Current Count" when monitoring the bean.
    When I view the descriptor in the console it looks fine. What can be wrong here?
    Using Weblogic 8.1 SP4, here's the statueful descriptor:
    <weblogic-enterprise-bean>
    <ejb-name>MyStatefulBean</ejb-name>
    <stateful-session-descriptor>
    <stateful-session-cache>
    <max-beans-in-cache>1</max-beans-in-cache>
    </stateful-session-cache>
    <allow-concurrent-calls>True</allow-concurrent-calls>
    </stateful-session-descriptor>
    <reference-descriptor>
    </reference-descriptor>
    <enable-call-by-reference>True</enable-call-by-reference>
    <jndi-name>test.mystatefulbean/MyStatefulBean/Home</jndi-name>
    <local-jndi-name>test.mystatefulbean/MyStatefulBean/LocalHome</local-jndi-name>
    </weblogic-enterprise-bean>

    I agree with you about the host not being able to install (or at least don't want to install/upgrade) their servers to php5.4...  Unfortunately, I can't change that...  but by shutting them off took care of all the quotes (single & double) and any other characters which would basically function like an addslashes() command.  I'll paste the script below...  It's still pretty much the same as when you helped me out with the script...  Just minor adjustments:::  If you can show me (even though I fixed the problem) how I would integrate the stripslashes() function to the comment field it would be helpful to know for future reference.
    <?php // Script 1.0 - contactlist.php
    if (isset($_POST['submit']) && !empty($_POST['submit'])) // Test if submit button named submit was clicked and not empty
              if (!empty($_POST['first']) && !empty($_POST['last'])  && !empty($_POST['email']) && !empty($_POST['phone']) && !empty($_POST['comment'])) {
    $comment=stripslashes($_POST[comment]);
                        $body = "First Name: {$_POST['first']}\nLast Name: {$_POST['last']}\nEmail Address: {$_POST['email']}\nContact Phone Number: {$_POST['phone']}\nContact Preference: {$_POST['contactvia']}\n\nBest Time To Contact: {$_POST['timepref']}\n\nComments:\n {$_POST['comment']}";
                        $body = wordwrap($body, 70);
                        mail([email protected]', 'NEW Customer Inquiry Submission',$body, "From: {$_POST['email']}");
                        header('Location: index.html');  //Redirect to new url if form submitted
    ?>

  • Stateless and Stateful beans.

    Please tell me what are the important differences between stateless, and stateful beans.
    Thanks in advance.

    See this thread
    http://forum.java.sun.com/thread.jsp?forum=13&thread=529706&tstart=15&trange=15

  • Stateful bean and cursor

    Is a stateful bean maintaining a reference to a ResultSet an acceptable design?
    The concern is that the resultset might need to be closed after each Stateful
    Bean access such that we don't hold on resources on the database.
    Stefan

    Thanks Bob,
    That's exactly what I was asking and it seems more clear now. Interesting if multiple
    ResultsSet kept around open could share same db connection in which case this
    could somehow scale. My concern was more directed towards number of Open Cursors
    in the database, but overall it does not look like a proper design ...
    Stefan
    "Bob Lee" <[email protected]> wrote:
    Not if the ResultSet will be kept open accross multiple web requests.
    The
    result set is most likely tied to a database connection. If too many
    are
    kept open, you database connection pool will get maxed out, and other
    users
    won't be able to access the site.
    You can handle the paging by running the query every time. You can also
    keep
    an index of the column you are sorting on and use this to pick out exact
    pages in your query. Memory is cheap.
    Bob
    "Stefan" <[email protected]> wrote in message
    news:3c7be741$[email protected]..
    Is a stateful bean maintaining a reference to a ResultSet an acceptabledesign?
    The concern is that the resultset might need to be closed after eachStateful
    Bean access such that we don't hold on resources on the database.
    Stefan

  • WL 7.0 Fault-tolerant stateful beans. (Newbie)

    Hello,
    I was wondering if in WL 7.0 there is a way to make a stateful session
    bean automatically persist its state without having to be passivated
    as a whole.
    The bean that I need to build would persist its state to a DB each
    time a remote method call is executed in it. The purpose is to make
    this bean fault tolerant without having to serialize the whole object
    graph by using passivation.
    I heard that WL 7.0 has a new feature that can make this happen but I
    can't seem to find any info on this. Could anyone point me into the
    right search path?
    Thanks in advance.
    Mateo.

    I'm not aware of such feature in WLS 7.0 EJB container.
    Where did you heard about it? If at all there's a feature you should
    be able to locate at our online docs.
    Here's the link
    http://e-docs.bea.com/wls/docs70/ejb/index.html
    Kumar
    Mateo wrote:
    Hello,
    I was wondering if in WL 7.0 there is a way to make a stateful session
    bean automatically persist its state without having to be passivated
    as a whole.
    The bean that I need to build would persist its state to a DB each
    time a remote method call is executed in it. The purpose is to make
    this bean fault tolerant without having to serialize the whole object
    graph by using passivation.
    I heard that WL 7.0 has a new feature that can make this happen but I
    can't seem to find any info on this. Could anyone point me into the
    right search path?
    Thanks in advance.
    Mateo.

  • Cluster Server: Session bean replication

    I am using JDeveloper 11.1.1.6.0
    I am currently trying to prepare our application for a clustered environment, and I was following section 20.4.3 of the following document: http://docs.oracle.com/cd/E23943_01/web.1111/b31974/web_getstarted.htm#CHDIJCIE
    The document mentions that I need to make view, pageflow, and session scope beans as "serializable" and that view and pageflow scope beans need to be marked as dirty when they are updated. However, session bean was not included in needing to be marked. Do I need to do something else in order to ensure that the changes made to the session scope are replicated across the cluster? Or does ADF somehow detect that there was a change and handle this replication for me?
    Thank you.

    The reason you only need to do this for view and pageflow scope beans is the way they are stored. These scopes are stored as maps in the session scope. If you alter a bean inside the map the session scope don't know it as it only knows the reference and not the value.
    Changes to session scope objects are tracked by the framework.
    Timo

  • Question about operations allowed in methods of stateless and stateful bean

    Hello,
    Can anyone tell me why ejbRemove and ejbCreate are allowed entreprise beans and resource manager access in stateful session beans and not in stateless session beans?
    Thanks in advance,
    Julien Martin.

    Salut Julien,
    Can anyone tell me why ejbRemove and ejbCreate are
    allowed entreprise beans and resource manager access
    in stateful session beans and not in stateless session
    beans?I'm not sure I fully understand your question, but here is some information that may answer it.
    The user is the one who creates and removes a stateful session bean. The container is the one who creates and removes a stateless session bean. So the user can pass any parameters to the create of a SFSB because he theorically knows what to pass. The container doesn't, and doesn't want to. It just wants to create SLSB to pool them, but it doesn't pool SFSB.
    Maybe it doesn't answer your question. Can you reformulate?
    Kexkey

  • Stateful bean storing its state.

    how will a stateful session bean stores its state.?

    In stateful session beans we will store the state using the instance variables used in the bean. so, that instance variables can be used between methods.In stateless session beans also we will be using the instances variables but the state will not be available. since it is valid for the one method only.

Maybe you are looking for

  • External Hard Disc won't show

    My iMac hard disc is getting full so I bought an external hard disk. I changed my iTunes folder over to the external hard disc without any trouble and removed the old iTunes music folder as per directions. After that iTunes played fine, the next day

  • Cannot Update Keynote to 4.0.3

    Here we go aghain, this happens every time. Apple seems to be getting like Microsoft. I downloaded the update, but it doesn't "see" my application, therefore it won't update it. Okay, WHERE does the app have to be, and WHAT should its TITLE be? Can s

  • Hi help needed in Smart form using BAdi ( please any one help me )

    Hi,     I am working in SRM.I am new to SRM and smartforms .My problem is I need to change the stndard smarform for BBP_BIDINV_BID into zprogram for The text for Published Bid Invitation email should read as:xxxxwith emp name and date,The text for em

  • Source of supply for material

    Hi! Is it possible to have the supplier defaulted based on the inforecord when I enter a material number in the shopping cart? If possible, is there a difference between classic and extended classic in this case? Regards SF

  • Encode Failed message during transcode attempts

    Hey guys, I've got a 45 minute video shot at 1920x1080i on a Everio GZ-HD7-B camera that's due for a review in only a couple of days. I've got the project to a near-final draft in Adobe Premiere Pro CS4, and have been working on authoring a DVD in Ad