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
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 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 !!!
PrabsThanks!!
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
?> -
Trying to build a web application with stateful ejb clustering
Hi to everyone,
I'd like to know if someone gets to work a stateful ejb clustering. The stateful ejbs are called from a servlet so i'm not using RMI.
The ejb clustering sample works! but It is using RMI and this is not use for me.
My application already works but not in a cluster. Is this possible? I supose yes AND HOW???
Thanks in advanced.Might look at: https://jsfportletbridge.dev.java.net to get started.
-
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 -
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.
StefanThanks 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 -
Help!!! Stateful session bean clustering
I posted this message on interest.clustering.in-memory-replication. But there is
no answer at all. Could anyone give me
some hints? Thanks a lot. I am a student and this work is part of my course project.
It is due soon.
=================================================================
I have a big problem to get stateful session bean in-memory replication run on
clustering. I have three server instances on three nodes and there is always errors
from the server instance like this when I run the client to invoke the bean methods:
<Jan 4, 2002 6:47:31 PM EST> <Error> <EJB> <Failed to update the secondary copy
of a stateful session bean from home:stateful.ejb.AgentSTF>
Besides, the load balancing can not work probably too. Below is what I get.
Statistics for different servers:
"myserver" processed 160 (12%) of 1311 invocations "ejbperf-3" processed 1151
(88%) of 1311 invocations
End Client...
Load balancing works fine with stateless and entity bean.
Any comments are greatly appreciated.
Jenny
Hi Jenny,
Please could you open a case to the customer support ([email protected]) There is a Cr
on this issue CR059046
Description of the CR
WLS 6.1SP1 - Accessing Stateful Session Bean from Stateless Session Bean in a
cluster fails with errors
<Oct 5, 2001 5:08:25 PM GMT+00:00> <Error> <EJB> <Failed to update the
secondary copy of a stateful session bean from home:UserState>
Regards
Stephane
Jenny Liu wrote:
> I posted this message on interest.clustering.in-memory-replication. But there is
> no answer at all. Could anyone give me
> some hints? Thanks a lot. I am a student and this work is part of my course project.
> It is due soon.
>
> =================================================================
>
> I have a big problem to get stateful session bean in-memory replication run on
> clustering. I have three server instances on three nodes and there is always errors
> from the server instance like this when I run the client to invoke the bean methods:
>
> <Jan 4, 2002 6:47:31 PM EST> <Error> <EJB> <Failed to update the secondary copy
> of a stateful session bean from home:stateful.ejb.AgentSTF>
>
> Besides, the load balancing can not work probably too. Below is what I get.
>
> Statistics for different servers:
> "myserver" processed 160 (12%) of 1311 invocations "ejbperf-3" processed 1151
> (88%) of 1311 invocations
> End Client...
>
> Load balancing works fine with stateless and entity bean.
>
> Any comments are greatly appreciated.
>
> Jenny
>
Regards,
Stephane Kergozien
BEA Support
-
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. -
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
-
CPU Upgrade on Satellite L30?
Tried searching but didn't get an answer. Bought a laptop from ebuyer the other week, and so far so good, but good do with a bit more juice. Currently running a CoreDuo 1.73 processor, wondering if Core2 or something a bit better will suit. Heard som
-
i unlocked my iphone 4 factory and i upgrade to 6.1 when i connect it to itunes it apears The SIM card inserted in this iPhone does not appear to be supported This iPhone is not currently setup to work with carrier you're attempting to use. Please in
-
Can i use iCloud with one apple id but app store with another; especially on iOS 6?
My household has multiple devices. I own iPhone and iPod, both on iOS 5.1.1, and iCloud (used for apps, iMessage, and backup.) I almost never buy music, but I buy some apps. My SO has iPhone (also on 5.1.1), and she uses my apple id for purchases (m
-
ITSmobile standalone - F8 logoff doesn't work
Hi, in our ITSmobile standalone scenario the logoff doesn't work. It is also not working in the ITS webgui transactions using the standard logoff button. It is a ITS 6.20 standalone SP64, with a 4.70 SP65. Many things regarding logoff only work for i
-
X-Fi audio cleanup not available
I just bought a new computer, running XP Pro 32 bit on an Asus P5Q mb, and I added a PCI X-Fi soundcard from my old computer. I disabled the onboard Realtek sound card in the bios, and it does not show up anywhere in device manager. I installed all t