Stateless bean instance cache and usage algorithm

I have two clients C1 and C2 which call the same bean B1. Is it possible to control
the instance that gets bound to each client. I dont want to use stateful beans
as it affects performance and the beans are inherantly stateless.

Why do you want to do that? If you use SFSB and have no state most of the overhead
associated with state management would not be there. However the scaling that
comes with spraying would be gone. You would not have it with SLSB either if you
tie it to the client.
However if you implement a custom call router you might be able to bind SLSB to
a client. Keep in mind DGC might collect your bean.
S
S
"Ashok" <[email protected]> wrote:
>
I have two clients C1 and C2 which call the same bean B1. Is it possible
to control
the instance that gets bound to each client. I dont want to use stateful
beans
as it affects performance and the beans are inherantly stateless.

Similar Messages

  • Restrict number of stateless bean instances

    i need to restrict number of stateless bean instances. Am working on EJB3.0 and jboss.
    I have even modified the following in standardjboss.xml but, still am not able to restrict.......
    <container-pool-conf>
    <MaximumSize>10</MaximumSize>
    <strictMaximumSize>true</strictMaximumSize>
    </container-pool-conf>
    Is there any other way?
    Thank in advance

    all the config files are different in jboss for the ejb3 stuff (rather annoying). assuming you want to make this change globally, you need to alter the deploy/ejb3-interceptors-aop.xml file. at the end of the "Stateless Bean" domain there is an annotation element which defines the pool configuration (it's basically a copy of the java annotation embedded in the xml file).

  • Max-beans-in-cache and getting mail

    Hi,
    Here is the situation. I am currently using the
    max-beans-in-cache option in the stateful-session-cache . What I want to do is when the max bean amount has been reached and the bean is removed. At this point I would like to have an email or some kind of notification that this happened.
    Does anybody have any idea how to do this?
    thanks,
    Marc

    Hi,
    Here is the situation. I am currently using the
    max-beans-in-cache option in the stateful-session-cache . What I want to do is when the max bean amount has been reached and the bean is removed. At this point I would like to have an email or some kind of notification that this happened.
    Does anybody have any idea how to do this?
    thanks,
    Marc

  • How Stateless Session Bean instances in pool

    Hi,
    I am not clear about , stateless bean having "pool" of objects to be used by multiple clients.when those instances will be created or who will generate them.
    Is this pool specific to ejb container or any vendor container.
    thanks in advance,

    Hi , my question is about Stateless Session Bean ,
    how StatelessSession bean will behave when some 100
    clients wil call homeObject simultaneously.The EJBs(including stateless) are single threaded so one client can access one Bean at a time. As per your question if some 100 clients are invoking home.create() method then it has to invoke on 100 EJBs. The instance pool size can be specified while deploying. In the descriptor (application server speific). So if the number of simultaneous clients is more than the pool size then some clients have to wait.
    Now my second question is how and who will create
    these instance .The container will create the pool as per the application server spcific deployment descriptor.

  • Stateless Bean - scope of instance variable in EJB Timer call back function

    Hi,
    I would like to know on the scope of an instance variable of a Stateless Bean object,
    when used in a EJB Timer call back.Let me explain this in more detail below.
    I have a requirement to use a EJB Timer.
    For this, I have created a stateless object since Timer creation needs to be done
    from a stateless bean. I have a member variable "count" of the stateless bean class.
    In the timer call back(ejbTimeout), I am able to use this count variable during
    each time of the call back, and the value of this variable is also updated properly.
    I have a few queries with respect to the above behaviour:
    1) Does stateless bean object not get destroyed once the Timer is created from the Bean?
    2) If the Bean object is not destroyed, then when does the bean object get destroyed?
    3) If both (1) and (2) are not true, then can anyone explain on how the above behaviour is possible?
    Thanks in advance,
    Ulrich

    Hi Ulrich,
    The ejb timer is associated with the stateless session bean component, not with a particular bean instance. There is no formal relationship between the bean instance that called createTimer() and the bean instance on which the timer callback happens. If they're the same in your test run that's just a coincidence and not something your application should be depending on.
    In the stateless session bean model, the container can create and destroy stateless session bean instances at any time. The container is free to pick any stateless session bean instance to service any client invocation or timer callback. If you need to pass context into a timer callback, one way to do it is via the timer "info" object. However, the info object is immutable so it wouldn't be a good match for a counter. You could of course always just use a database for any necessary coordinated state.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Exception while getting the server instance. Stateless bean problem

    Hi,
    New to OC4J, I'm moving an ear that was running ok under jboss.
    1- The wep app deploys. This is a piece of code inside the init() method of a struts plugin:
         System.out.println("0");
         AddressFacadeHome addressFacadeHome = HomeFactory.getAddressFacadeHome();
         System.out.println("1.0");
         AddressFacade addressFacade = addressFacadeHome.create();
         System.out.println("1.5");
    2- The code is run when the web app is initialized. This is the error message I get. system.out show that the error occurs on addressFacadeHome.create().
    AddressFacade is a remote/local stateless bean. HomeFactory returns the jndi lookup/narrow of the remote object.
    0
    1.0
    caught exception while getting the server instance null
    java.lang.NullPointerException
    com.evermind.security.User com.evermind.server.ThreadState.getCurrentUser()
    ThreadState.java:637
    com.evermind.security.User com.evermind.server.ThreadState.getUser()
    ThreadState.java:371
    fda.common.address.ejb.interfaces.AddressFacade AddressFacadeHome_StatelessSessionHomeWrapper7.create(
    AddressFacadeHome_StatelessSessionHomeWrapper7.java:66
    void fda.web.oaa.struts.plugin.ApplicationInit.init(org.apache.struts.action.ActionServlet, org.apache
    .struts.config.ModuleConfig)
    void org.apache.struts.action.ActionServlet.initModulePlugIns(org.apache.struts.config.ModuleConfig)
    ActionServlet.java:1105
    void org.apache.struts.action.ActionServlet.init()
    ActionServlet.java:468
    void javax.servlet.GenericServlet.init(javax.servlet.ServletConfig)
    GenericServlet.java:258
    com.evermind.server.http.ServletInstanceInfo com.evermind.server.http.HttpApplication.loadServlet(com.
    evermind.util.ByteString)
    HttpApplication.java:1956
    com.evermind.server.http.ServletInstanceInfo com.evermind.server.http.HttpApplication.findServlet(com.
    evermind.util.ByteString)
    HttpApplication.java:4355
    void com.evermind.server.http.HttpApplication.initPreloadServlets()
    HttpApplication.java:4455
    void com.evermind.server.http.HttpApplication.initDynamic(com.evermind.server.http.HttpApplicationConf
    ig)
    HttpApplication.java:662
    void com.evermind.server.http.HttpApplication.<init>(com.evermind.server.Application, com.evermind.ser
    ver.http.HttpSite, com.evermind.server.http.HttpApplicationConfig, java.lang.String, java.lang.String, boolean
    My guess is that it's a jaas issue (because i see security and getCurrentUser), but at init time, no user is authenticated.
    Any clue would be very much appreciated. Let me know if I can provide anything else, such as deployment descriptors.
    Thanks,
    Christophe.

    After spending some time on this, I looked at the source code for com.evermind.server.ThreadState
    This is the code that throws the exception:
    if(applicationThread != null && applicationThread.httpHandler != null && applicationThread.servletInfo != null)
    try
    server = applicationThread.httpHandler.request.getApplication().getApplication().getServer();
    catch(Throwable t)
    System.out.println("caught exception while getting the server instance " + t.getMessage());
    t.printStackTrace(System.out);
    It looks like this method expects a httpRequest, and would find null because I'm in the servlet.init()
    (at least, that's my interpretation)
    I tested my code (the remoteFacade.create()) inside of a jsp, and it worked...
    So, the next logical question is:
    Can I make EJB calls from within the init method of a servlet? (or more specifically from a struts plugin, which I believe should be more or less the same thing)
    If so, do I need to take extra steps?
    Again, any experience/help on this will be much appreciated.
    Thanks,
    Christophe.

  • JAAS and stateless bean

    i have a very simple stateless bean with a single "hello" method running in WL 8.1 sp3. to test out Weblogic's behavior, i ran 2 seaparate scenarios on 2 separate occasions. in the first one, i secured all bean methods. in the 2nd one, i secured only the home's "create" mthod, while explicitely denoting all remote methods as "unchecked". next, i wrote a standalone client class where the aforemention bean's EJBHome.create() is called from within a PrivilegedAction-inherited class, while hello() method is called straight up without the use of PrivilegedAction. moreover, the hello() method also prints out the SessionContext.getCallerPrincipal().getName(). finally, an UNsecured servlet utilizing that class was deployed in Tomcat5 and another instance of Weblogic. this is where is gets interesting. when executing the standalone class or the Tomcat's servlet in both scenarios, the results are the same: both create() and hello() get called without a problem, while the latter method prints out correct principal name. however, Weblogic hosting the unsecured servlet behaves differently (and undesirably). in the first scenario where all methods are secured, create() is allowed to be executed, but calling hello() results in an insufficient privileges error. in the 2nd scenario, where only create() method is secured, Weblogic allows hello() to be called without a problem. however, the principal that it returns is "anonymous". my question is how is it possible for not only Tomcat, but even a standalone class to call a secured method without the use of PrivilegedAction and get back a correct principal? yet when absolutely identical code is called from another Weblogic instance, i cannot even obtain a correct principal despite the use of PrivilegedAction!!!
    thanks!

    Hi "werwer" (or is that "wer" :-),
    I haven't checked the forum archives, so I may have already mentioned
    this to you (or I may have already mentioned it to someone else
    on this forum), but there are many resources available on the
    Internet that can answer nearly all your J2EE related questions!
    I would like to mention two. (If you already know about them, then
    I suggest you study them. If you have already studied them and
    still don't know the difference between a stateful and a stateless
    session bean, then perhaps you can be a bit more specific about
    what, in particular, you are having difficulty with.)
    1. "Mastering Enterprise JavaBeans" by Ed Roman
    A book that you can download as a PDF file.
    http://www.theserverside.com/books/masteringEJB/index.jsp
    (Also look for the companion book -- at the same URL -- "EJB
    Design Patterns")
    Note that you need to become a "member" in order to download
    these books -- but registration is free.
    2. "Enterprise Java Beans, 3rd Edition" by Richard Monson-Haefel
    This is an online book -- that you cannot download!
    http://safari.informit.com/main.asp?bookname=entjbeans3
    Note that "Safari" (at "InformIT") are offering a free, two-week
    trial subscription.
    Hope this helps you.
    Good Luck,
    Avi.

  • Max-beans-in-cache, transactions and passivation

    WLS 6.1 sp4
    database concurrency, oracle
    I compute max-beans-in-cache as:
    (max # fetched in a transaction) * (number of worker threads)
    therefore if I think that a table with have at most 500 rows and the
    server is configured with 20 worker threads I have 500 * 20 = 10000 as
    my max-beans-in-cache.
    In my test the table has 7 rows. In our load test I see the Beans In
    Use Count go up to 9999 instances and then start passivation.
    I have two questions:
    1) What does 'Beans In Use Count' really mean
    2) why is weblogic using much more memory than it should to store 7 unique entities?
    thanks

    See my comments below.
    S
    Chad Urso McDaniel <[email protected]> wrote:
    >
    I understand this, but WebLogic should either reuse objects in the
    cache/pool or not cache them at all. There are cases where the objects in the cahce are used. For e.g. with entity
    beans and Read-Only concurrancy, when cache-between-tx is set. However I noticed
    this behavior for other cases too and therefore the caching is not all that intellegent.
    Also the beans in the pool are reused.
    The current situation results in
    objects being allocated, referenced by the cache so they will never be
    garbage collected, but the objects are never used again once their
    transaction completes. This is very, very wasteful with memory.
    In some cases as mentioned above.
    S
    "Sri" <[email protected]> writes:
    Hi,
    The reason for having so many entries is due to fact that there isno way WLS
    would know there are only 7 rows in the db everytime an entity beanis created/modified/accessed.
    For e.g., if you run a test where you do 'findAll' the first run wouldhave 7
    beans and the next most likely (There is another parameter that youcould use
    to control number of beans in the cache, idle-timeout-seconds. Thoughits not
    clear from the doc how the entity beans are handled wrt this parameter,it might
    passivate entity beans if this timeout occurs) 14 and so on. If thisis a overhead
    for your system then reduce this number.
    S
    container start removing beans before Chad Urso McDaniel <[email protected]>
    wrote:
    WLS 6.1 sp4
    database concurrency, oracle
    I compute max-beans-in-cache as:
    (max # fetched in a transaction) * (number of worker threads)
    therefore if I think that a table with have at most 500 rows and the
    server is configured with 20 worker threads I have 500 * 20 = 10000as
    my max-beans-in-cache.
    In my test the table has 7 rows. In our load test I see the BeansIn
    Use Count go up to 9999 instances and then start passivation.
    I have two questions:
    1) What does 'Beans In Use Count' really mean
    2) why is weblogic using much more memory than it should to store7 unique
    entities?
    thanks

  • Remote and local interface on same ejb 3.0 bean instance

    Hi,
    Is it posible to get remote and local interface on same ejb 3.0 bean instance.
    For example get local interface of a bean and than pass it as remote to client.
    Both interfaces must operate on same bean instance.
    Thanks
    Zlaja

    yes. You can implement multiple interfaces on a single class, so you can add a local and a remote interface. One trick to avoid duplicate code is to simply make the remote interface extend the local interface; then you only have to add the @Remote annotation and you're done.
    For example get local interface of a bean and than pass it as remote to client.You don't pass an instances to a client, a client looks up a remote instance of the bean through JNDI.

  • How to get all property names and values of an bean instance at runtime?

    How can I get all property names and values of an bean instance at runtime?
    (The class of the bean instance is dynamic and I can not know before I write the code .)

    Look at Class. It has a way to get at all public methods and attributes.
    If you need to get to private attributes you can do what the Introspector does and expect the methods to follow the Bean pattern and pull the attributes out based upon that. Privates are all hidden from direct access but through the Bean Pattern they can be figured out.

  • Difference between(Usage) instance.properties and bootstrap.properties

    Hi every one,
    Might be the basic Q but unable to locate the exact forum for the same.
    What is the usage/diff between instance.properties and bootstrap.properties and instance.properties.vmprop and instance.properties.vmprop.XX
    Thanks in advance.

    Hello,
    Instance.properties contain all the values which you set in the config tool for memory parameters . This file is created every time when the J2EE engine is started . The information which stored in DB is written into this file and placed on the server at the cluster directory .
    bootstrap.properties contains all the basic j2ee profile parametrs whicha re needed for the server process to start .
    the vmprop.xx file is also used for keeping a record of the memory parametrs .
    Thanks

  • Instance of ejb2 stateless bean

    InitialContext ctx = new InitialContext();
    Object objref = ctx.lookup(PARAMCTRL_IJNDIName.SBAppComboDb);
    homeAppComboDb = (SBAppComboDbHome) PortableRemoteObject.narrow(objref, SBAppComboDbHome.class);
    remoteAppComboDb = homeAppComboDb.create();
    1)How many instance of that particular stateless bean is created in ejb container?
    2)Does instance of stateless being destroy after ejbRemove()? which mean can be garbage colletion.
    3)can other user sharing use the same instance of the stateless bean after remove?
    4)is stateless bean thread safe?

    Please read tutorial for EJB 2.0 Stateless Session Bean

  • Keeping alive an instance of a Stateless Bean

    Hello Weblogic comunity:
    I'm deploying a stateless bean with initial-beans-in-free-pool element in '1' (Weblogic 7.0). According with the EJB spec, at some moment of EJB lifecicle ejbRemove() will be called by the container removing the instance :(
    Is there a way to keep 1+ instances always alive?

    Hans,
    "Hans Nemarich" <[email protected]> wrote in message news:19065530.1096384306132.JavaMail.root@jserv5...
    Hello Weblogic comunity:
    I'm deploying a stateless bean with initial-beans-in-free-pool element in '1' (Weblogic 7.0). According with the EJB spec, at somemoment of EJB lifecicle ejbRemove() will be called by the container removing the instance :(
    >
    Is there a way to keep 1+ instances always alive?Please check this:
    http://www.viewtier.com/newsgroups/thread.jspa?threadID=23&tstart=0
    Regards,
    Slava Imeshev

  • EJB 3.0 Stateful - Limiting number of bean instances

    Hello EJB Experts,
    I have just started to learn EJB 3.0 and have some basic queries. The application server that I am using is Glassfish. Please find my queries below:
    1. To remove an bean instance from the container, we can use the annotation '@Remove'. I basically had 2 methods and annotated the 2nd method with '@Remove'. Whenever the 2nd method is called, the container is removing this instance also in my program. My problem is that, i might get some invalid parameter values in the 2nd method, so in that case I have to just log the error message and whenever the input parameters are correct, then only the instance should be removed. But lets say, if someone calls my 2nd method with invalid parameters, I log the message and the container removes it, but after some time if the 2nd method is called with correct parameters, then the instance will not be available. Can we programatically tell the container when to remove a bean instance?
    2. From the docs, I am clear that pooling works only for 'Stateless' beans. I however (I am using 'Statuful' bean), wanted to limit the max number of instance to 2. I did below mentioned configuration in the 'sun-ejb-jar.xml' file:
    <bean-cache>
                        <is-cache-overflow-allowed>false</is-cache-overflow-allowed>
                        <cache-idle-timeout-in-seconds>1</cache-idle-timeout-in-seconds>
                        <max-cache-size>2</max-cache-size>
                        <resize-quantity>0</resize-quantity>
                        <removal-timeout-in-seconds>2</removal-timeout-in-seconds>
                        <victim-selection-policy>LRU</victim-selection-policy>
              </bean-cache>
    But i think, it is still creating more that 2 instances of this bean.
    Please help me in getting answers to these questions. I will be very thankful for your replies.
    Regards,
    San
    Edited by: SolarisUser1 on Jun 27, 2010 11:00 PM

    @Remove is used for stateful EJBs and you call it when your client has finished using that instance of the stateful EJB.
    If you are passing in parameters to the method and letting it do some work with your parameters then perhaps it should not be a remove method at all. Make it a normal method and only put cleanup related logic in the remove method. You can also throw some application exception and rollback if the parameters are not correct.

  • How can I make WL 8.1 flush the cache and/or pool for 1.1 EJBs

    Hi,
    I'm using 1.1 deployment descriptors for my CMP entity bean that were previously
    used in the WL 5.1 version of my project.
    Things do get deployed but I've observed confusing information when monitoring
    the EJB via Admin Console.
    What appears is that the Weblogic container is not flushing the cache and/or pool
    after the bean has finished processing and also a sufficient time has expired
    (i.e. the idle-timeout-seconds)
    From what I've understood via the on-line information is that each EJB has its
    own cache (since I've not done anything special for that) and the instance in
    cache is only passivated when the cache is full and the server need to activate
    another instance. On passivation, it appears to be returning the instance to the
    pool. But its unclear/undocumented when the pool is cleared, if at all.
    What I want is that:
    1. A way to get my cached instance passivated
    2. A way to get my pooled instance flushed.
    The reason I'm looking into this is becasue in my case it appears that the cached/pooled
    instance are contributing to OutOfMemory errors and because of the nature of requirements,
    etc. we need to have the cache size be high for certain processing.
    Thanks
    Parasher

    I think it's probably best to contact technical support about this.
    There are different patches for different versions of WLS.
    I'd mention 'CR128026' to them to get started.
    -thorick
    "Parasher" <[email protected]> wrote:
    >
    Hi,
    Thank you for your reply !
    How can I get more information about this patch and the patch itself
    Is there a way I can look it up online or do I have to contact the support
    folks
    and if so what should I need to tell them to convey which patch I'm talking
    about.
    Thank you in advance.
    Parasher
    "thorick" <[email protected]> wrote:
    Hi,
    If you use 'Database' concurrency, then there is a patch available for
    some 8.1
    service
    packs to enable idle-timeout-seconds on the cache. I believe that this
    will be
    standard
    feature with the next service pack. There is no comparable mechanism
    for the
    pool in 8.1,
    this is a feature that is coming with the next major release of WLS.
    If the
    8.1 patch works
    for you, it can save you memory during off peak usage times. Notethat
    this
    patch does not
    work for 'Exclusive' concurrency.
    -thorick

Maybe you are looking for