Accessing the same stateful session bean from multiple clients in a clustered environment
I am trying to access the same stateful session bean from multiple
clients. I also want this bean to have failover support so we want to
deploy it in a cluster. The following description is how we have tried
to solve this problem, but it does not seem to be working. Any
insight would be greatly appreciated!
I have set up a cluster of three servers. I deployed a stateful
session bean with in memory replication across the cluster. A client
obtains a reference to an instance of one of these beans to handle a
request. Subsequent requests will have to use the same bean and could
come from various clients. So after using the bean the first client
stores the handle to the bean (actually the replica aware stub) to be
used by other clients to be able to obtain the bean. When another
client retrieves the handle gets the replica aware stub and makes a
call to the bean the request seems to unpredictably go to any of the
three servers rather than the primary server hosting that bean. If the
call goes to the primary server everything seems to work fine the
session data is available and it gets backed up on the secondary
server. If it happens to go to the secondary server a bean that has
the correct session data services the request but gives the error
<Failed to update the secondary copy of a stateful session bean from
home:ejb20-statefulSession-TraderHome>. Then any subsequent requests
to the primary server will not reflect changes made on the secondary
and vice versa. If the request happens to go to the third server that
is not hosting an instance of that bean then the client receives an
error that the bean was not available. From my understanding I thought
the replica aware stub would know which server is the primary host for
that bean and send the request there.
Thanks in advance,
Justin
If 'allow-concurrent-call' does exactly what you need, then you don't have a problem,
do you?
Except of course if you switch ejb containers. Oh well.
Mike
"FBenvadi" <[email protected]> wrote:
>I've got the same problem.
>I understand from you that concurrent access to a stateful session bean
>is
>not allowed but there is a
>token is weblogic-ejb-jar.xml that is called 'allow-concurrent-call'
>that
>does exactly what I need.
>What you mean 'you'll get a surprise when you go to production' ?
>I need to understand becouse I can still change the design.
>Thanks Francesco
>[email protected]
>
>"Mike Reiche" <[email protected]> wrote in message
>news:[email protected]...
>>
>> Get the fix immediately from BEA and test it. It would be a shame to
>wait
>until
>> December only to get a fix - that doesn't work.
>>
>> As for stateful session bean use - just remember that concurrent access
>to
>a stateful
>> session bean is not allowed. Things will work fine until you go to
>production
>> and encounter some real load - then you will get a surprise.
>>
>> Mike
>>
>> [email protected] (Justin Meyer) wrote:
>> >I just heard back from WebLogic Tech Support and they have confirmed
>> >that this is a bug. Here is their reply:
>> >
>> >There is some problem in failover of stateful session beans when its
>> >run from a java client.However, it is fixed now.
>> >
>> >The fix will be in SP2 which will be out by december.
>> >
>> >
>> >Mike,
>> >Thanks for your reply. I do infact believe we are correctly using
>a
>> >stateful session bean however it may have been misleading from my
>> >description of the problem. We are not accessing the bean
>> >concurrently from 2 different clients. The second client will only
>> >come into play if the first client fails. In this case we want to
>be
>> >able to reacquire the handle to our stateful session bean and call
>it
>> >from the secondary client.
>> >
>> >
>> >Justin
>> >
>> >"Mike Reiche" <[email protected]> wrote in message
>news:<[email protected]>...
>> >> You should be using an entity bean, not a stateful session bean
>for
>> >this application.
>> >>
>> >> A stateful session bean is intended to be keep state (stateful)
>for
>> >the duration
>> >> of a client's session (session).
>> >>
>> >> It is not meant to be shared by different clients - in fact, if
>you
>> >attempt to
>> >> access the same stateful session bean concurrently - it will throw
>> >an exception.
>> >>
>> >> We did your little trick (storing/retrieving handle) with a stateful
>> >session bean
>> >> on WLS 5.1 - and it did work properly - not as you describe. Our
>sfsb's
>> >were not
>> >> replicated as yours are.
>> >>
>> >> Mike
>> >>
>> >> [email protected] (Justin Meyer) wrote:
>> >> >I am trying to access the same stateful session bean from multiple
>> >> >clients. I also want this bean to have failover support so we want
>> >to
>> >> >deploy it in a cluster. The following description is how we have
>tried
>> >> >to solve this problem, but it does not seem to be working. Any
>> >> >insight would be greatly appreciated!
>> >> >
>> >> >I have set up a cluster of three servers. I deployed a stateful
>> >> >session bean with in memory replication across the cluster. A client
>> >> >obtains a reference to an instance of one of these beans to handle
>> >a
>> >> >request. Subsequent requests will have to use the same bean and
>could
>> >> >come from various clients. So after using the bean the first client
>> >> >stores the handle to the bean (actually the replica aware stub)
>to
>> >be
>> >> >used by other clients to be able to obtain the bean. When another
>> >> >client retrieves the handle gets the replica aware stub and makes
>> >a
>> >> >call to the bean the request seems to unpredictably go to any of
>the
>> >> >three servers rather than the primary server hosting that bean.
>If
>> >the
>> >> >call goes to the primary server everything seems to work fine the
>> >> >session data is available and it gets backed up on the secondary
>> >> >server. If it happens to go to the secondary server a bean that
>has
>> >> >the correct session data services the request but gives the error
>> >> ><Failed to update the secondary copy of a stateful session bean
>from
>> >> >home:ejb20-statefulSession-TraderHome>. Then any subsequent requests
>> >> >to the primary server will not reflect changes made on the secondary
>> >> >and vice versa. If the request happens to go to the third server
>that
>> >> >is not hosting an instance of that bean then the client receives
>an
>> >> >error that the bean was not available. From my understanding I
>thought
>> >> >the replica aware stub would know which server is the primary host
>> >for
>> >> >that bean and send the request there.
>> >> >
>> >> >Thanks in advance,
>> >> >Justin
>>
>
>
Similar Messages
-
Context.lookup in a Servlet always returns the same Stateful Session Bean
Hi,
I am working on an application in which a Servlet should obtain one StateFul Session Bean per client. I read in EJB 3.0 in Action that to do so I should use a jndi lookup and save the result of the lookup in an HttpSession. This works fine for me when I have a single client.
My issue is that when I have several clients, context.lookup returns the same SFSB for each client. This means that I end up having a single SFSB for the whole application. I've been browsing the web for a while now trying to find a solution but haven't had any luck yet.
The code I use to obtain and save the SFSB is the following:
HttpSession session = request.getSession(true);
DFMServiceRemote service = (DFMServiceRemote) session.getAttribute("DFMService");
if (null == service)
service = (DFMServiceRemote) new InitialContext().lookup("DFMService");
session.setAttribute("DFMService", service);
}Using different browser, I end up with different HttpSession but a single SFSB. The only workaround I found is to create the context with environment variables or properties. It then returns different SFSBs for different HttpSession. The workaround code is as below:
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "oc4jadmin");
env.put(Context.SECURITY_CREDENTIALS, "welcome");
env.put(Context.PROVIDER_URL, "ormi://localhost:23791/DriverFatigue");
service = (DFMServiceRemote) new InitialContext(env).lookup("DFMService");My question is the following. How can I get a different instance of an SFSB every time I execute context.lookup without specifying properties.
Thanks in advance for any help,
Matthieu SiggenI just did something similar in another project using JBoss instead of oc4j and didn't have any problem. I expect I missed a configuration file in oc4j or there is a conflict somewhere.
-
Initialize a stateful session bean from another
Hi,
I am trying to create and initialize a stateful session bean from another stateful session bean. The code is as follows
This method belongs to DefaultSessionBean where it creates the AdminSessionBean based on few checks and returns it to the client.
public AdminSession getAdminSession() throws UnknownException, WarningException {
checkSessionUser("getAdminSession");
if (isAdmin()) {
AdminSession adminSession;
try {
final Context context = IToolsUtil.getInitialContext();
adminSession = (AdminSession)context.lookup("AdminSession");
System.out.println("Successfully created the adminsession bean");
} catch (NamingException ne) {
ne.printStackTrace();
throw new UnknownException (new CatalogHelper("ITOOLS_100019", new Object[]{"Admin", ne.getMessage()}));
System.out.println("adminsession will be returned");
return adminSession;
} else {
throw new WarningException (new CatalogHelper("ITOOLS_000042", sessionUser.getUserhandle()));
}Another method in DefaultSessionBean, creates its local interface and returns it.
public DefaultSessionLocal getDefaultSessionLocal() {
DefaultSessionLocal dsl = (DefaultSessionLocal)context.getBusinessObject(DefaultSessionLocal.class);
System.out.println("local created.");
return dsl;
}Client call initialize method of the AdminSessionBean which is mentioned below:
public void initialize(DefaultSession ds) throws WarningException, UnknownException {
this.ds = ds.getDefaultSessionLocal();
this.rfl = ReadFieldList.getInstance();
this.fm = new FinderMethods();
}The client code where it gets the adminSession and initializes is
public static AdminSession getAdminSession(DefaultSession ds) throws ViewException {
AdminSession as;
try {
as = ds.getAdminSession();
System.out.println("got admin session");
} catch (WarningException we) {
we.printStackTrace();
throw new ViewException(we.getCatalogHelper());
} catch (UnknownException ue) {
ue.printStackTrace();
throw new ViewException(ue.getCatalogHelper());
} catch (OracleRemoteException ore) {
ore.printStackTrace();
throw new ViewException(new CatalogHelper("ITOOLS_050003", ore.getMessage()));
// Initialize Admin Session
try {
System.out.println("before getting it.");
as.initialize(ds);
System.out.println("adminsession is initialized");
} catch (WarningException we) {
as.remove();
as = null;
throw new ViewException(we.getCatalogHelper());
} catch (UnknownException ue) {
as.remove();
as = null;
throw new ViewException(ue.getCatalogHelper());
} catch (OracleRemoteException ore) {
as.remove();
as = null;
throw new ViewException(new CatalogHelper("ITOOLS_050003", ore.getMessage()));
System.out.println("got admin session");
return as;
}Apart from this I am using OC4J 10.1.3.1 tool test my application.
When I am calling initialize method of the AdminSession I am getting the following error.
06/10/24 12:26:08 Entered
06/10/24 12:26:08 got default session
06/10/24 12:26:08 Successfully created the adminsession bean
06/10/24 12:26:08 adminsession will be returned
06/10/24 12:26:08 got admin session
06/10/24 12:26:08 before getting it.
2006-10-24 12:26:08.156 WARNING J2EE RMI-00009 Exception returned by remote server: {0}
06/10/24 12:26:08 com.itools.vs.view.exception.ViewException
06/10/24 12:26:08 at com.itools.vs.view.util.ViewUtil.getAdminSession(ViewUtil.java:71)
06/10/24 12:26:08 at com.itools.vs.view.backing.Admin.CreateUser.submit_action(CreateUser.java:182)
06/10/24 12:26:08 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
06/10/24 12:26:08 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
06/10/24 12:26:08 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
06/10/24 12:26:08 at java.lang.reflect.Method.invoke(Method.java:585)
06/10/24 12:26:08 at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:146)
06/10/24 12:26:08 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:92)
06/10/24 12:26:08 at org.ajax4jsf.framework.ajax.AjaxActionComponent.broadcast(AjaxActionComponent.java:88)
06/10/24 12:26:08 at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:274)
06/10/24 12:26:08 at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:250)
06/10/24 12:26:08 at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:405)
06/10/24 12:26:08 at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:95)
06/10/24 12:26:08 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
06/10/24 12:26:08 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
06/10/24 12:26:08 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
06/10/24 12:26:08 at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
06/10/24 12:26:08 at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:67)
06/10/24 12:26:08 at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:223)
06/10/24 12:26:08 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
06/10/24 12:26:08 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
06/10/24 12:26:08 at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
06/10/24 12:26:08 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
06/10/24 12:26:08 at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
06/10/24 12:26:08 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
06/10/24 12:26:08 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
06/10/24 12:26:08 at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
06/10/24 12:26:08 at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
06/10/24 12:26:08 at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
06/10/24 12:26:08 at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
06/10/24 12:26:08 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
06/10/24 12:26:08 at java.lang.Thread.run(Thread.java:595)
06/10/24 12:26:08 ITOOLS_050003: Failed to get Admin Session.
Exception is "Error marshalling objects, Not Serializable: java.io.NotSerializableException: DefaultSession_RemoteProxy_6nein01; nested exception is:
java.io.NotSerializableException: DefaultSession_RemoteProxy_6nein01".
[b/Your remote client passes a DefaultSession to AdminSession.initialize(..). This DefaultSession has to be a remote type. In your client, how does it get DefaultSession?
Did your client look up DefaultSession, and have it return a (sessionContext.getBusinessObject(DefaultSession.class))? If so, it should work. -
Creating multiple stateful session beans from a java client. (EJB 3.0)
I'm having difficulties with the following:
To access the ShoppingCartBean, I have to put the following annotation in my standalone java client:
@EJB
private static ShoppingCartRemote shoppingCartBean;
The static must be there, thus only one ShoppingCartBean will exist within my java client. But as the ShoppingCartBean is a stateful session bean, I want to be able to get different beans of the same type.
What is the correct way to do this in EJB 3.0?Great question. Because Home interfaces have been removed for the EJB 3.0 simplified
API, stateful session bean creation happens as a side-effect of injection. However, the
same is true of EJB 3.0 business interface lookups. The easiest way to create additional
stateful session beans is to lookup the same dependency that was declared via your
@EJB annotation.
E.g.,
// Assuming the declaring class is pkg1.ShoppingCartClient.java
InitialContext ic = new InitialContext();
ShoppingCartRemote scr1 = (ShoppingCartRemote)
ic.lookup("java:comp/env/pkg1.ShoppingCartClient/shoppingCartBean");
Note that the name relative to java:comp/env is the default associated with your
@EJB annotation since the name() attribute wasn't used. Alternatively, you
could have used :
@EJB(name="scb") private static ShoppingCartRemote shoppingCartBean;
InitialContext ic = new InitialContext();
ShoppingCartRemote scr1 = (ShoppingCartRemote) ic.lookup("java:comp/env/scb");
Yet another alternative is to declare the @EJB at the class-level. This just defines
the dependency without any injection, which is fine if you want to create a bunch of
them via lookup anyway.
@EJB(name="scb", beanInterface=ShoppingCartRemote.class)
public class .... { -
What are the advantages stateful session beans takes over than HttpSession
Hi
We can use HttpSession to maintain the conversational state with the client.
Then why we need to go for stateful session beans to maintain conversational state with the client.
What are advantages we can have while using stateful session beans ratherthan HttpSession????.
Regards
Dhinesh kumar RI think we can use the magic word in the software development "seperation of concerns" ;-)
HttpSession is in the Servlet/JSP tier and is mainly used in the presentation logic tier (UI, page flows, navigation etc..)
where the stateful session bean's concern is to maintain a conversational state in a business logic tier.
Through this seperation its possible, that the business tier's state is undependant from the HttpSession and you dont create a hardlink that could cause problems later. Imagine having a desktop client accessing your business logic etc. not every client needs to be a web client ;-)
I hope that the answer helps you understanding the topic :-)
Brgds,
Nail -
Error in looking up a session bean from simple client
Hi,
I have the following problem: (*+{color:#008000}Urgent problem my project depends on this problem to solve please help{color}+*)
I completed the "Create a Simple EJB Session Bean" example from cue cards tutorials from jdeveloper 11 g final release, and run the "HelloWorldSession" and waiting for server to finish its initialization.
Note:
Session bean code:
import javax.ejb.*;
+@Stateless(name = "HelloWorldSession", mappedName = "SessionEJB-SessionEJB")+
+@Remote+
+public class HelloWorldSessionBean implements HelloWorldSession {+
+public HelloWorldSessionBean() {+
< <em>public String sayHello(String name) {+
return "Hello " name;+
+}+
HelloWorldSessionClient code:
+public class HelloWorldSessionClient {+
< <em>public static void main(String[] args) {+
+try {+
final Context context = getInitialContext();
HelloWorldSession helloWorldSession =
+(HelloWorldSession)context.lookup("*SessionEJB-SessionEJB#eg.com.efinance.HelloWorldSession*");+
System.out.println(helloWorldSession.sayHello("world"));
+} catch (Exception ex) {+
ex.printStackTrace();
< <em>+
< <em>private static Context getInitialContext() throws NamingException {+
Hashtable env = new Hashtable();
+// WebLogic Server 10.x connection details+
env.put(Context.INITIAL_CONTEXT_FACTORY,
+"weblogic.jndi.WLInitialContextFactory");+
env.put(Context.PROVIDER_URL, "t3://127.0.0.1:7101");
return new InitialContext(env);
+}+
Then on HelloWorldSessionClient right click then run I got the following errors:
*{color:#ff0000}"C:\Program Files\Java\jdk1.6.0_06\bin\javaw.exe" -client -classpath "C:\Documents and Settings\Mohamed_Taman.HEADQ\Desktop\SessionEJB\Project1\classes;C:\Oracle_Middleware_11g\modules\javax.ejb_3.0.1.jar;C:\Oracle_Middleware_11g\wlserver_10.3\server\lib\weblogic.jar" -DproxySet=false eg.com.efinance.HelloWorldSessionClient{color}*
*{color:#ff0000}Exception in thread "main" java.lang.AssertionError: java.lang.ClassNotFoundException: eg.com.efinance.HelloWorldSession{color}*
*{color:#ff0000} at weblogic.ejb.container.internal.RemoteBusinessIntfGenerator.generateRemoteInterface(RemoteBusinessIntfGenerator.java:57){color}*
*{color:#ff0000} at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.readObject(RemoteBusinessIntfProxy.java:205){color}*
*{color:#ff0000} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method){color}*
*{color:#ff0000} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39){color}*
*{color:#ff0000} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25){color}*
*{color:#ff0000} at java.lang.reflect.Method.invoke(Method.java:597){color}*
*{color:#ff0000} at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974){color}*
*{color:#ff0000} at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849){color}*
*{color:#ff0000} at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753){color}*
*{color:#ff0000} at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329){color}*
*{color:#ff0000} at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947){color}*
*{color:#ff0000} at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871){color}*
*{color:#ff0000} at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753){color}*
*{color:#ff0000} at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329){color}*
*{color:#ff0000} at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351){color}*
*{color:#ff0000} at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:197){color}*
*{color:#ff0000} at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:564){color}*
*{color:#ff0000} at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:193){color}*
*{color:#ff0000} at weblogic.rmi.internal.ObjectIO.readObject(ObjectIO.java:62){color}*
*{color:#ff0000} at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:240){color}*
*{color:#ff0000} at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348){color}*
*{color:#ff0000} at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259){color}*
*{color:#ff0000} at weblogic.jndi.internal.ServerNamingNode_1030_WLStub.lookup(Unknown Source){color}*
*{color:#ff0000} at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:392){color}*
*{color:#ff0000} at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:380){color}*
*{color:#ff0000} at javax.naming.InitialContext.lookup(InitialContext.java:392){color}*
*{color:#ff0000} at eg.com.efinance.HelloWorldSessionClient.main(HelloWorldSessionClient.java:12){color}*
*{color:#ff0000}Caused by: java.lang.ClassNotFoundException: eg.com.efinance.HelloWorldSession{color}*
*{color:#ff0000} at weblogic.ejb.container.deployer.RemoteBizIntfClassLoader.getClassBytes(RemoteBizIntfClassLoader.java:151){color}*
*{color:#ff0000} at weblogic.ejb.container.deployer.RemoteBizIntfClassLoader.loadClass(RemoteBizIntfClassLoader.java:96){color}*
*{color:#ff0000} at weblogic.ejb.container.internal.RemoteBusinessIntfGenerator.generateRemoteInterface(RemoteBusinessIntfGenerator.java:54){color}*
*{color:#ff0000} ... 26 more{color}*
*{color:#ff0000}Process exited with exit code 1.{color}*Hello
The problem is beacause weblogic doesn't allow blank spaces in the CLASS PATH, so try that in your path doesn't exit blank spaces like these:
C:\Documents and Settings -
Stateful Session Bean accesed by two JSPs.
Hi there,
We are having quite an issue; we have an application that stores session
state in an stateful session bean. And we have noticed some parts of the
application create a situation where is possible that two frames -and so two
jsp- access the session bean at the same time. And, of course, it´s going to
be the same instance of the session bean..... what will be the behaviour in
this case?. Will the requests be serialized, an exception will be thrown or
the EJB will be destroyed?. Not very sure of what would happen. I suppose
there could be some problems with this-. I would appreciate any help.
Many thanks. Best regards.Hrm. EJB spec is quite clear on what will happen (RemoteException thrown) if
the second client attempts to use Stateful Session bean which is already in
use (and the bean will not be destroyed - container will simply throw an
exception after failing to acquire a lock on the bean instance without waiting
(allow-concurrent-calls option in WebLogic allows client call to wait to acquire
lock - this was probably added as a convinience feature for applications which
use frames)).
So, normally your application has to ensure that no 2 clients are able to use
the same stateful session bean concurrently, or use allow-concurrent-calls option,
which will do that for you, but the application will become non portable.
Dimitri
PS: Thanks. Maine Coon cats are the best. Ours is a 22-pound giant ;-)
Pinklon Thomas <[email protected]> wrote:
Hi Dimitri,
Thnaks a lot for the help:one thing that I do not know if it´s an issue is
that calls come from different JSPs; the strategy I have seen in another Web
application servers is trying to activate the EJB in the middle of another
transaction... In this situation, the container cannot activate the EJB,
roolback the transaction and destroys the EJB.... Would Weblogic feature
avoid this?. I will investigate on my part....
Many many thnaks. Nice cats.
"Dimitri Rakitine" <[email protected]> wrote in message
news:[email protected]...
In 6.1 you can set allow-concurrent-calls to true in this situation:
<!--
The allow-concurrent-calls specifies whether a stateful session bean
instance will allow concurrent method calls. The value of this
element may be either "True" or "False". The default value is
"False". When a stateful session bean instance is currently in a
method call and another (concurrent) method call arrives on the
server, the EJB specification requires that the server throw a
RemoteException. By default, allow-concurrent-calls is false, and the
EJB container will follow the EJB specification. When this value is
set to true, the EJB container will block the concurrent method call
and allow it to proceed when the previous call has completed.
Used in: stateful-session-descriptor
-->
Pinklon Thomas <[email protected]> wrote:
Hi there,
We are having quite an issue; we have an application that stores
session
state in an stateful session bean. And we have noticed some parts of the
application create a situation where is possible that two frames -and sotwo
jsp- access the session bean at the same time. And, of course, it´sgoing to
be the same instance of the session bean..... what will be the behaviourin
this case?. Will the requests be serialized, an exception will be thrownor
the EJB will be destroyed?. Not very sure of what would happen. Isuppose
there could be some problems with this-. I would appreciate any help.
Many thanks. Best regards.--
Dimitri -
Deploy multiple instances of the same stateless session EJB
I have a stateless session bean.
The methods on the bean operate against DB tables.
Q: Can I deploy multiple instances of the same stateless session bean, but specify a different JNDI/datasource name in the deployment descriptor?
The method calls are all enclosed within a single invocation, just that I need to hit different databases (all with the same schema), and Id like to be able to lookup the EJB via a different JNDI name, and have the exact same functionality, just against different deployed datasources.
Does the spec allow/support this?
If not, any suggestions as to how to achieve this sort of functionality?
Im using JBoss 3.2.1 on Solaris, so Im not sure whether or not this is a JBoss "issue" or a limitation of the EJB Spec (or me being just plain wrong and trying to do something the "wrong way")
NickI have a stateless session bean.
The methods on the bean operate against DB tables.
Q: Can I deploy multiple instances of the same
stateless session bean, but specify a different
JNDI/datasource name in the deployment descriptor?
The method calls are all enclosed within a single
invocation, just that I need to hit different
databases (all with the same schema), and Id like to
be able to lookup the EJB via a different JNDI name,
and have the exact same functionality, just against
different deployed datasources.
Does the spec allow/support this?
If not, any suggestions as to how to achieve this sort
of functionality?
Im using JBoss 3.2.1 on Solaris, so Im not sure
whether or not this is a JBoss "issue" or a limitation
of the EJB Spec (or me being just plain wrong and
trying to do something the "wrong way")
NickI haven't done it but judging from the deployment descriptors yes.
For example if I have two bounded datasources java:/Database1 and java:/Database2
Lets say I have a session bean called MySession, then in your ejb-jar.xml you would have (notice that the desc, display, and ejb-name are the only differences)
<session>
<description>MySessionAlpha</description>
<display-name>MySessionAlpha</display-name>
<ejb-name>MySessionAlpha</ejb-name>
<home>com.mycorp.MySessionRemoteHome</home>
<remote>com.mycorp.MySessionRemote</remote>
<local-home>com.mycorp.MySessionLocalHome</local-home>
<local>com.mycorp.MySessionLocal</local>
<ejb-class>com.mycorp.MySessionFacadeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref>
<res-ref-name>jdbc/DataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</session>
<session>
<description>MySessionBeta</description>
<display-name>MySessionBeta</display-name>
<ejb-name>MySessionBeta</ejb-name>
<home>com.mycorp.MySessionRemoteHome</home>
<remote>com.mycorp.MySessionRemote</remote>
<local-home>com.mycorp.MySessionLocalHome</local-home>
<local>com.mycorp.MySessionLocal</local>
<ejb-class>com.mycorp.MySessionFacadeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref>
<res-ref-name>jdbc/DataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</session>
But now in the jboss.xml, we will have the following elements. What you may notice is that are bound to different remote and local jndi names. But the resource bindings are very different. The res-ref-name stays the same, but the jndi-name are different. I think this will work for you.
<session>
<ejb-name>MySessionAlpha</ejb-name> <jndi-name>ejb/com/mycorp/MySessionAlphaRemoteHome</jndi-name> <local-jndi-name>ejb/com/mycorp/MySessionAlphaLocalHome</local-jndi-name>
<resource-ref>
<res-ref-name>jdbc/datasource</res-ref-name>
<jndi-name>java:/Database1</jndi-name>
</resource-ref>
</session>
<session>
<ejb-name>MySessionBeta</ejb-name> <jndi-name>ejb/com/mycorp/MySessionBetaRemoteHome</jndi-name> <local-jndi-name>ejb/com/mycorp/MySessionBetaLocalHome</local-jndi-name>
<resource-ref>
<res-ref-name>jdbc/datasource</res-ref-name>
<jndi-name>java:/Database2</jndi-name>
</resource-ref>
</session> -
Reentrant call to a stateful session bean
Hi,
I have a problem that seems to be a very common problem but I
steel didn't find any solution for it.
We have a jsp page that call to stateful session been, the
problem occur when I click twice on any link/button then I get
java.rmi.RemoteException: Illegal attempt to make a reentrant call to a stateful
session bean from home:....
I have tried to set the <allow-concurrent-calls> to true but it doesn't help,
I am getting this exception no matter the value of this tag.
I am using WL61 sp2 (the last version) , Does anybody find a solution for that,
I don't want to use javascript in order to work around this problem.
Thanks,I think this is a different error from concurrent access (when client's
attempt to access the same bean concurrently WebLogic throws LockTimedOut error
(or client blocks if allow-concurrent-calls is true)).
This error probably means that your code attempetd to reenter bean in the same
transaction - how do you invoke it and what is the stack trace?
Haim Cohen <[email protected]> wrote:
Hi,
I have a problem that seems to be a very common problem but I
steel didn't find any solution for it.
We have a jsp page that call to stateful session been, the
problem occur when I click twice on any link/button then I get
java.rmi.RemoteException: Illegal attempt to make a reentrant call to a stateful
session bean from home:....
I have tried to set the <allow-concurrent-calls> to true but it doesn't help,
I am getting this exception no matter the value of this tag.
I am using WL61 sp2 (the last version) , Does anybody find a solution for that,
I don't want to use javascript in order to work around this problem.
Thanks, --
Dimitri -
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
-
Error in updating secondary stateful session bean
Hi all,
I have set up a cluster of 2 managed servers with WebLogic 6.1. I have a
stateful session bean and several stateless session beans. the stateful
session bean keeps user info and limited cached objects, all are
serializable. it seems working fine, even after killing any one of the
servers, as long as one is alive. a java application client creates a
stateful session bean first, then calls stateless session beans with the
remote interface of the stateful bean as a method parameter. No problem
when stateful session bean is created. However, each stateless bean method
generates the following error message if I turn the debug on (level 64). No
exception stack traces, and all methods execute successfully.
<Error> <EJB> <Failed to update the secondary copy of a stateful session
bean from home:clientsession>
I wonder what causes the error, and why it tries to update the stateful
session bean. in all stateless session beans, only read into the stateful
bean.
Thank you,
Fujin
This has been fixed in WLS 6.1 SP2.
jagdip Talla wrote:
> Hi Fujin,
> please let me know, if u were able to solve the problem..
>
> hi guys,
> appreciate if you could give me some clues
> how to solve this problem ?
>
> i hv 2 WLS instances in a cluster,
> when one server instance is shut down, i keep getting these errors ?
> is it normal ?
> <Feb 19, 2002 2:57:53 PM SGT> <Error> <EJB> <Failed to update the secondary copy of a stateful session bean from home:ejb/xyzrel1_2/xxxxHome>
>
> appreciate if u can let me know, if u could solve it..?
>
> thanks n regads
> jagdip
Rajesh Mirchandani
Developer Relations Engineer
BEA Support
-
Cannot remove stateful session bean when transaction timed out
The transaction timeout is set to 5 minutes. After several operations on the transactional
stateful session bean(implements SessionSynchronization), the transaction timed out
after 5 minutes and I got the IllegalStateException when calling another business
method. After the transaction rolled back, weblogic.ejb20.locks.LockTimedOutException
was thrown when attempting to remove the bean. It seems the lock on the bean was
not released even though the transaction had been rolled back. Does anyone know how
to remove the bean in this kind of situation?
Here is the stacktrace:
####<Jun 11, 2002 2:39:35 PM PDT> <Notice> <EJB> <app1x.zaplet.cc> <server25044server>
<ExecuteThread: '11' for queue: 'default'> <> <23168:7b09681c532dc7e3> <010015> <Error
marking transaction for rollback: java.lang.IllegalStateException: Cannot mark the
transaction for rollback. xid=23168:7b09681c532dc7e3, status=Rolled back. [Reason=weblogic.transaction.internal.TimedOutException:
Transaction timed out after 299 seconds
Xid=23168:7b09681c532dc7e3(3203140),Status=Active,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds
since begin=299,seconds left=60,activeThread=Thread[ExecuteThread: '11' for queue:
'default',5,Thread Group for Queue: 'default'],ServerResourceInfo[weblogic.jdbc.jts.Connection]=(state=ended,assigned=none),SCInfo[server25044+server25044server]=(state=active),properties=({weblogic.jdbc=t3://10.0.100.93:7001}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=server25044server+10.0.100.93:7001+server25044+,
Resources={})],CoordinatorURL=server25044server+10.0.100.93:7001+server25044+)]>
java.lang.IllegalStateException: Cannot mark the transaction for rollback. xid=23168:7b09681c532dc7e3,
status=Rolled back. [Reason=weblogic.transaction.internal.TimedOutException: Transaction
timed out after 299 seconds
Xid=23168:7b09681c532dc7e3(3203140),Status=Active,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds
since begin=299,seconds left=60,activeThread=Thread[ExecuteThread: '11' for queue:
'default',5,Thread Group for Queue: 'default'],ServerResourceInfo[weblogic.jdbc.jts.Connection]=(state=ended,assigned=none),SCInfo[server25044+server25044server]=(state=active),properties=({weblogic.jdbc=t3://10.0.100.93:7001}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=server25044server+10.0.100.93:7001+server25044+,
Resources={})],CoordinatorURL=server25044server+10.0.100.93:7001+server25044+)]
at weblogic.transaction.internal.TransactionImpl.throwIllegalStateException(TransactionImpl.java:1486)
at weblogic.transaction.internal.TransactionImpl.setRollbackOnly(TransactionImpl.java:466)
at weblogic.ejb20.manager.BaseEJBManager.handleSystemException(BaseEJBManager.java:255)
at weblogic.ejb20.manager.BaseEJBManager.setupTxListener(BaseEJBManager.java:215)
at weblogic.ejb20.manager.StatefulSessionManager.preInvoke(StatefulSessionManager.java:371)
at weblogic.ejb20.internal.BaseEJBObject.preInvoke(BaseEJBObject.java:117)
at weblogic.ejb20.internal.StatefulEJBObject.preInvoke(StatefulEJBObject.java:169)
at mypackage.MyBean_wbr3eg_EOImpl.addRecipients(MyBean_wbr3eg_EOImpl.java:450)
####<Jun 11, 2002 2:39:37 PM PDT> <Info> <EJB> <app1x.zaplet.cc> <server25044server>
<ExecuteThread: '11' for queue: 'default'> <> <> <010049> <EJB Exception in method:
remove: weblogic.ejb20.locks.LockTimedOutException: The lock request from EJB:AppmailBean
with primary key:21,775,960,933,010,237 timed-out after waiting 0 ms. The transaction
or thread requesting the lock was:Thread[ExecuteThread: '11' for queue: 'default',5,Thread
Group for Queue: 'default'].>
weblogic.ejb20.locks.LockTimedOutException: The lock request from EJB:AppmailBean
with primary key:21,775,960,933,010,237 timed-out after waiting 0 ms. The transaction
or thread requesting the lock was:Thread[ExecuteThread: '11' for queue: 'default',5,Thread
Group for Queue: 'default'].
at weblogic.ejb20.locks.ExclusiveLockManager$LockBucket.lock(ExclusiveLockManager.java:448)
at weblogic.ejb20.locks.ExclusiveLockManager.lock(ExclusiveLockManager.java:258)
at weblogic.ejb20.manager.StatefulSessionManager.acquireLock(StatefulSessionManager.java:226)
at weblogic.ejb20.manager.StatefulSessionManager.acquireLock(StatefulSessionManager.java:216)
at weblogic.ejb20.manager.StatefulSessionManager.preInvoke(StatefulSessionManager.java:310)
at weblogic.ejb20.manager.StatefulSessionManager.remove(StatefulSessionManager.java:754)
at weblogic.ejb20.internal.StatefulEJBObject.remove(StatefulEJBObject.java:86)
at mypackage.MyBean_wbr3eg_EOImpl.remove(MyBean_wbr3eg_EOImpl.java:7308)If a stateful session throws a RuntimeException (your rollback) the container destroys the instance of the bean and all
associated state information is lost, as required by the EJB specification.
If you want to maintain client state it is generally best to use HttpSession objects (if you have a web application)
for short-lived, client-specific data and JPA entities or other database backed storage for long-lived data. -
Accessing the same database file using different handles/cursors
Will there be any problems accessing the same database file using different DB handles in a transactional environment? We have implemented a process which have multiple transient threads coming up and initiating DB opens and read/write operations to the same database file using different handles and cursors?
Can this potentially create any problems/bottlenecks? Can someone suggest the best way to deal with this scenario?
Thanks in advance.
SBHi,
Berkeley DB is well suited to the scenario you describe. You need to ensure that Berkeley DB is configured correctly for transactional access, the best information describing the requirements is in the Reference guide here:
http://download.oracle.com/docs/cd/E17076_02/html/programmer_reference/transapp.html
If there will be multiple threads operating concurrently, then you will need to design your application to detect and deal with deadlock situations.
Regards,
Alex Gorrod
Oracle Berkeley DB -
Call existing stateful session bean in different servlets
hello,
we are implementing a shopping cart for our online dvd store in netbeans 5.5.1 and ejb 3.0.
for that we use a stateful session bean, which is created when a user is logging in for connecting the user-entity to the bean.
after logging in, the list servlet, which displays a list of all available dvds, is shown. after clicking the "add to shopping cart" button, the cart servlet with a list of all added dvds is shown. in this servlet we want to reactivate the existing stateful session bean. is this possible? and when it's possible, how is it possible? ;)
our sessionbean with initialize() method:
@Stateful
public class CartBean implements Cart {
UserEntity user;
List<DVDEntity> contents;
public void initialize(UserEntity user){
System.out.println("Warenkorb erstellt");
this.user = user;
contents = new ArrayList<DVDEntity>();
}thx!
Edited by: licherpremium on Nov 8, 2007 6:35 AMhello,
we are implementing a shopping cart for our online dvd store in netbeans 5.5.1 and ejb 3.0.
for that we use a stateful session bean, which is created when a user is logging in for connecting the user-entity to the bean.
after logging in, the list servlet, which displays a list of all available dvds, is shown. after clicking the "add to shopping cart" button, the cart servlet with a list of all added dvds is shown. in this servlet we want to reactivate the existing stateful session bean. is this possible? and when it's possible, how is it possible? ;)
our sessionbean with initialize() method:
@Stateful
public class CartBean implements Cart {
UserEntity user;
List<DVDEntity> contents;
public void initialize(UserEntity user){
System.out.println("Warenkorb erstellt");
this.user = user;
contents = new ArrayList<DVDEntity>();
}thx!
Edited by: licherpremium on Nov 8, 2007 6:35 AM -
Stateful session bean purpose?
Currently I am struggling with the purpose of stateful session beans. Any client program should be able to maintain the state itself. Why am I using a session bean for this and loading the server with something that is really not of much value?
Can anyone give me a good example of when I need a stateful session bean, or at least a good use for one?
Thanks!The jsp can certainly save the info in the "session" object. But I can see how this would be easier.
I have come to believe that stateful session beans just allow you to commonize your web interfaces with your non-web interfaces by abstracting lots of functionality into the EJBs.
Maybe you are looking for
-
I'm trying to open a small .pdf file Photoshop is telling me it wont open, that there is not enough ram. It's not on all files, I tried re-saving the file it is messing up on but it still does it. I'm running the newest macbook pro with 16g ram 300gi
-
Hi Team, i do need support for my iPhone 4s IOS 6.0 i'm using a new notebook, iTunes already installed. 1. i want to import the musik from my iphone to iTunes, my mediathek named "klaus" 2. i want to synchronize my iPhone contacts with my goolge acco
-
Customization forms display message Query options
Is there any way to eliminate or change the message 'Query Options' in a report customization form?
-
Hi, I am running a program in Background job. But it was giving dump. Could any one let me know how can i do debug in background mode. Thanks Gopi.
-
LB configuration - Keep Alive.
I need to help configure proper load balancing between 2 building modules of Portal server. SetUp: Server A - Portal 1,Access Manager 1 , Directory 1 Server B - Portal 2, Access Manager 2, Directory 2 Logical Architecture. -------- Server A User Requ