stateless-session-bean

Stateless session bean with instance variables

倖福魔咒の 提交于 2019-12-17 22:41:23
问题 I have a stateless session bean that contains one public method, several private methods, and some instance level variables. Below is a pseudo code example. private int instanceLevelVar public void methodA(int x) { this.instanceLevelVar = x; methodB(); } private void methodB() { System.out.println(instanceLevelVar); } What I'm seeing is that methodB is printing values that weren't passed into MethodA. As best I can tell it's printing values from other instances of the same bean. What would

EJB3. How JNDI lookup works

元气小坏坏 提交于 2019-12-11 16:51:58
问题 I'm building little framework for data processing with EJB 3. I have Entity Access Object tier which abstracts from data source. Now I need some kind of factory which will give me right bean to query entities. Is it safe to pass looked up through JNDI local bean interfaces as parameters to another local beans? Will each method invocation from this local interface be addressed to the same bean or each call will be passed to different stateless beans as in @EJB occasion? 回答1: You don't have any

synchronized method in stateless session bean not working as expected in glassfish

左心房为你撑大大i 提交于 2019-12-11 10:45:20
问题 I have a war file deployed in glassfish. We have some stateless session beans and we have 1 synchronized method in it. However, I am noticing that more than 1 thread is able to enter the synchronized method concurrently. Is it possible that glassfish is instantiating 2 instances of this bean class? Is there any way around this? 回答1: Yes, of course it's possible. The spec even mandates that concurrent calls are handled by different instances.: this is one of the services offered by the

Can i make my own Singleton Stateless Bean with EJB 3.0?

家住魔仙堡 提交于 2019-12-08 07:51:09
问题 Now, with EJB 3.1, we can find the javax.ejb.Singleton annocation that can ensure that this bean is going to be singleton. Is there a way that i can ensure singleton using stateless beans in EJB 3.0 with some modifications in my code (use of the keyword static, or other way to do that....) 回答1: If you're able to limit your @Stateless bean pool size to exactly 1, then you can get pretty close to an @Singleton . The effect would be like having an @Singleton that uses @Lock(WRITE) for all calls

Transaction TimeOut EJB impact on the thread

巧了我就是萌 提交于 2019-12-07 13:42:08
问题 A question on EJB: Let's say I have a session bean which has an infinite loop. It is running under a EJB transaction. Now when the transaction of the EJB times out, will that cause the infinite loop thread to break or container will stop the thread running the infinite loop. 回答1: Now when the transaction of the EJB timesout, will that cause the infinite loop thread to break or container will stop the thread running the infinte loop. This answer is based on reverse-engineering that I performed

Any thread safety benefits of exposing a web service as a stateless session bean?

主宰稳场 提交于 2019-12-07 12:18:36
问题 Are there are any thread safety related benefits of exposing a web service as a stateless session bean? (Correct me if i am wrong) but I think web services are not thread safe and like Servlets only one instance of a web service class is created by the server (not one instance per request). What I don't know whether they are assigned from a pool of beans like stateless beans are - by the app server. I am trying to find if I use @Stateless annoation with a web service that's already annotated

Transaction TimeOut EJB impact on the thread

梦想的初衷 提交于 2019-12-06 03:09:25
A question on EJB: Let's say I have a session bean which has an infinite loop. It is running under a EJB transaction. Now when the transaction of the EJB times out, will that cause the infinite loop thread to break or container will stop the thread running the infinite loop. Now when the transaction of the EJB timesout, will that cause the infinite loop thread to break or container will stop the thread running the infinte loop. This answer is based on reverse-engineering that I performed a couple of years back on OC4J 10.3.x, WebSphere 6.x and WebLogic 10.x, and might apply to other containers

why pool stateless bean?

十年热恋 提交于 2019-12-05 21:29:30
Normally we use singleton instance for business / dao layer. What is the reason behind pooling stateless session beans in case of EJBs? The "stateless" in the name refers to session conversation state, i.e. state that persists between invocations of the bean, retained for the duration of the session. However, stateless session beans are still permitted to have instance variables. Those instance variables should not relate to the conversation state, but are "shared" between clients. In other words, stateless session beans are not guaranteed thread safe. As a result, the container should ensure

NameNotFoundException when calling a EJB in Weblogic 10.3

风格不统一 提交于 2019-12-03 13:08:32
问题 I have a EJB defined as this: package com.foo; @Stateless (mappedName="HelloWorld") public class HelloWorldBean implements HelloWorld, HelloWorldLocal .... When it's deployed to Weblogic (WL), it gets the name myBean. I'm not sure if this is important. I try to call the bean with this code: Hashtable ht = new Hashtable(); ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); ht.put(Context.PROVIDER_URL, "t3://localhost:7001"); ic = new InitialContext(ht); tp =

NameNotFoundException when calling a EJB in Weblogic 10.3

时光怂恿深爱的人放手 提交于 2019-12-03 03:24:29
I have a EJB defined as this: package com.foo; @Stateless (mappedName="HelloWorld") public class HelloWorldBean implements HelloWorld, HelloWorldLocal .... When it's deployed to Weblogic (WL), it gets the name myBean. I'm not sure if this is important. I try to call the bean with this code: Hashtable ht = new Hashtable(); ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); ht.put(Context.PROVIDER_URL, "t3://localhost:7001"); ic = new InitialContext(ht); tp = (HelloWorld) ic.lookup("HelloWorld#com.foo.HelloWorldBean"); Anyone know why I get the following error?