Tag Bean Instance Reuse

Hi, all
          From the compiled code of JSP with TagLib, we found JSP compiler did not do
          any optimization to reuse the instances of TagBeans. It will instantiate a
          new instance everytime it sees a Tag. This will be a serious performance
          problem if we put a tag inside a loop.
          Anybody has any idea about how to optimize it, in weblogic or other servers?
          Thanks.
          Regards
          Zhongling Li
          

Why? Do you honestly think that instantiating a couple of hundred tags
          compares at all to the operations that you have no control of before the
          request even gets to your JSP or after your JSP finishes? Have you seen how
          many million objects WebLogic runs through in no time at all? Honestly,
          instantiating your tags is relatively insignificant, especially with modern
          JVMs that use non-heap allocation. The only exception is if you are doing
          something really heavy in your constructor.
          Cameron Purdy, LiveWater
          "lzl" <[email protected]> wrote in message news:[email protected]..
          > Hi, all
          >
          > From the compiled code of JSP with TagLib, we found JSP compiler did not
          do
          > any optimization to reuse the instances of TagBeans. It will instantiate a
          > new instance everytime it sees a Tag. This will be a serious performance
          > problem if we put a tag inside a loop.
          >
          > Anybody has any idea about how to optimize it, in weblogic or other
          servers?
          > Thanks.
          >
          > Regards
          >
          > Zhongling Li
          >
          >
          

Similar Messages

  • Too many bean instances

    Hi
    We've been struggling with this issue for a while and were wondering
    if anyone has had similar exp's. reading this group and other weblogic
    ones I see that entity bean instance counts have been(sic) causing
    problems however we are having similar problems with stateless session
    beans.
    Here is our pool tag
    <pool>
    <max-beans-in-free-pool>2</max-beans-in-free-pool>
    <initial-beans-in-free-pool>1</initial-beans-in-free-pool>
    </pool>
    Now, when the server starts JProbe is reporting anything up to 30
    instances of EJB implementation Objects on the heap when we expect to
    see at most 2.
    This situation arises when the profiler invokes weblogic with no heap
    switches.
    if we use -ms64m -mx64m then we get even more instances on the heap.
    If we set the switches to -ms128m -mx256m then the counts are up in
    the hundreds and JProbe/weblogic takes as long as 30 minutes to start
    up.
    We are running the software on Win2000 with an 800Mhz intel processor
    running in 512 MB RAM.
    We have tried to get this working on Solaris8 but the server fell over
    after 2.5 hours having consumed 600 MB of virtual memory.
    Has any one suffered the same problem.
    Also are we alone in experiencing these huge delays when starting the
    server via the profiler.
    Oh yes, if we start the server 'standalone' it comes up in about 1
    minute.
    Any help greatly appreciated
    Cheers
    Duncan L strang

    Did you take a thread dump to see what the server was doing? I would start
    there ... hopefully it is a bug in your code (those are easy to get a fix
    for ;-)
    Peace,
    Cameron Purdy
    Tangosol Inc.
    Tangosol Coherence: Clustered Coherent Cache for J2EE
    Information at http://www.tangosol.com/
    "Duncan L" <[email protected]> wrote in message
    news:[email protected]..
    Hi
    We've been struggling with this issue for a while and were wondering
    if anyone has had similar exp's. reading this group and other weblogic
    ones I see that entity bean instance counts have been(sic) causing
    problems however we are having similar problems with stateless session
    beans.
    Here is our pool tag
    <pool>
    <max-beans-in-free-pool>2</max-beans-in-free-pool>
    <initial-beans-in-free-pool>1</initial-beans-in-free-pool>
    </pool>
    Now, when the server starts JProbe is reporting anything up to 30
    instances of EJB implementation Objects on the heap when we expect to
    see at most 2.
    This situation arises when the profiler invokes weblogic with no heap
    switches.
    if we use -ms64m -mx64m then we get even more instances on the heap.
    If we set the switches to -ms128m -mx256m then the counts are up in
    the hundreds and JProbe/weblogic takes as long as 30 minutes to start
    up.
    We are running the software on Win2000 with an 800Mhz intel processor
    running in 512 MB RAM.
    We have tried to get this working on Solaris8 but the server fell over
    after 2.5 hours having consumed 600 MB of virtual memory.
    Has any one suffered the same problem.
    Also are we alone in experiencing these huge delays when starting the
    server via the profiler.
    Oh yes, if we start the server 'standalone' it comes up in about 1
    minute.
    Any help greatly appreciated
    Cheers
    Duncan L strang

  • Performance Test resulting in more EJB bean instances

    Hi Guys,
    I am trying to profile my application using OptimizeIT.
    If I conduct a load test using Load Runner , But for the test I am using only
    virtual client continously repeating the same operation for a period of an hour
    or so. I expect only entity bean instance to cater to the needs . What I observe
    from OptimizeIT is the number of instances of entity bean continously increases
    My question is when the same thread is doing the operation the Entity Bean instance
    which catered to the need during the first round should be able to process client
    request second time. Why should the bean instance continously increase?
    Thanks in advance,
    Kumar

    Kumar Raman wrote:
    Hi Rob,
    I am unable to send the .snp file as the file size is coming out to be 6 MB which
    our mail server is not allowing to send thorough (we have a corporate limit of
    3MB). If U have any other way across please let me know.Did you try compressing it? Or, just split it in multiple files and
    send them separately. If none of that works, send me a private email,
    and I can get you a FTP upload.
    >
    As regards to 2 questions
    1) I know as to why two instances are getting created as I can see the code here.
    But I really wanted to know as to when these instances be released from the memory
    ? They'll be kept in the cache at least until the transaction ends. Since
    you're deleting them, they'll be removed from the cache and sent to the
    pool when the tx completes.
    Is this going to be there till the pool size defined is filled? I haven,t defined
    any pool size in our configuration. I feel the default size is 1000.
    Yes, they will be in the pool, and the default pool size is 1000.
    2) As regards to 2nd question , the add/delete are running in different transaction.
    I wanted to know as to whether the instances created during add , be used for
    delete operation as well.
    They can/should be the same instance. What is your concurrency-strategy
    setting for this bean? I know in the past that exclusive concurrency
    was not reusing bean instances as well as some of the other concurrency
    strategies (eg database / optimistic).
    3) Also for each of the bean instance will there be corresponding home instances
    also floating in memory. I feel the home instances should be reusable.
    There's just 1 home instance for the deployment, not 1 per bean.
    In case of simple Entity bean creation in weblogic, how many objects will be
    created vis. a vis , home object , remote object so on...
    You'll need a bean interface (local and/or remote) and a bean
    implementation class.
    As the number of instances which OptimizeIT shows is beyond my understanding.
    I wanted to ensure is there any configuration to help me optimize these creations.
    Ok, let's try to get the snapshot to me so I can help you out.
    -- Rob
    >
    Thanks,
    Kumar
    Rob Woollen <[email protected]> wrote:
    Kumar Raman wrote:
    Hi,
    Actually we are running a scenario using Load Runner tool to add arow onto a
    DB using an Container managed Entity Bean. This Bean is getting instantiated
    using a Session Bean. In the workflow after creation we are deletingthe row in
    the table by using the remove method of the same entity bean.
    If we analyze using the profiler, the number of EJB instances increasesby 2 during
    add and increases by another 2 after delete.Is your session bean only creating one bean?
    There seems to be 2 questions:
    1) Why are you getting 2 beans on add/delete? I'm not sure if you
    expect this or not.
    2) Why are the beans used for the creation not being used again when
    you
    issue the delete?
    For #2, my first question is if the create and remove are both running
    in the same transaction?
    I am sending the OptimizeIT (ver5.5) snapshots to you by mail.
    Haven't received them yet, but they would be very helpful.
    -- Rob
    Please let me know as to why the instances are increasing inspite explicitlycalling
    the remove method in the code.
    Thanks,
    Kumar
    Rob Woollen <[email protected]> wrote:
    We'd need a little more information to diagnose this one.
    First off, if you have an OptimizeIt snapshot file (the .snp extension
    not the HTML output file), I'd be willing to take a look at it and
    give
    you some ideas. If you're interested, send me an email at rwoollenat
    bea dot com.
    If you're using a custom primary key class (ie not something like
    java.lang.String), make sure it's hashCode and equals method are correct.
    Otherwise, it'd be helpful if you gave us some more info about yourtest
    and what you're doing with the entity bean(s).
    -- Rob
    Kumar Raman wrote:
    Hi Guys,
    I am trying to profile my application using OptimizeIT.
    If I conduct a load test using Load Runner , But for the test I amusing only
    virtual client continously repeating the same operation for a periodof an hour
    or so. I expect only entity bean instance to cater to the needs .
    What
    I observe
    from OptimizeIT is the number of instances of entity bean continouslyincreases
    My question is when the same thread is doing the operation the EntityBean instance
    which catered to the need during the first round should be able toprocess client
    request second time. Why should the bean instance continously increase?
    Thanks in advance,
    Kumar

  • 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.

  • 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.

  • Creating a bean instance in another bean

    hi pals, i need your help on this. i'm havin this compiler error i.e. the bean instance(LoginBean) i created in another bean(LoginDataBean) which is for my database connection for client profile.this is the code & error message:
    CODE:
    package webclass;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import webclass.LoginBean.*;
    public class LoginDataBean
         private Connection cn;
         private PreparedStatement addRecord;
         public LoginDataBean()throws Exception
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              cn = DriverManager.getConnection("jdbc:odbc:portal");
         public void addClient(LoginBean log)throws SQLException
              addRecord.executeUpdate("insert into clientprofile(firstname,middlename,lastname,address,occupation,organisation,gender,email,username,password)values('"+log.getFNfield()+"','"+log.getMDfield()+"','"+log.getLNfield()+"','"+log.getAdresfield()+"','"+log.getOrgfield()+"','"+log.getEmail()+"','"+log.getUsername()+"','"+(String)log.getPasword()+"'");
              addRecord.close();
              cn.close();
    ERROR:
    cannot resolve symbol class LoginBean
    Location LoginDataBean public void addClient(LoginBean log)throws SQLException

    thanks, but look at the new code i modified still given error on not resolving the class LoginBean in the class LoginDataBean. here is the new code.
    package webclass;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    public class LoginDataBean
         private Connection cn;
         private PreparedStatement addRecord;
         public LoginDataBean()throws Exception
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              cn = DriverManager.getConnection("jdbc:odbc:portal");
         public void addClient(LoginBean log)throws SQLException
              addRecord.executeUpdate("insert into clientprofile(firstname,middlename,lastname,address,occupation,organisation,gender,email,username,password)values('"+log.getFNfield()+"','"+log.getMDfield()+"','"+log.getLNfield()+"','"+log.getAdresfield()+"','"+log.getOrgfield()+"','"+log.getEmail()+"','"+log.getUsername()+"','"+(String)log.getPasword()+"'");
              addRecord.close();
              cn.close();

  • EJB skeleton tied to a specific bean instance?

    Is a EJB skeleton tied to a specific EJB instance? For example, if in an application every access to the EJB was done via the same skeleton, would they have to queue or would the skeleton share the pool of beans amongst the requests.
    I'm assuming by skeleton to mean the remote RMI reference to the EJB returned from the create() method.
    Thanks

    Hi,
    It partly depends on what kind of ejb we're talking about. In the case of a stateful session bean, it doesn't make sense to have concurrent invocations of the same bean. If we're talking about stateless session beans, then the container typically dispatches concurrent requests to different bean instances on different threads.
    Note that strictly speaking, it would be within the
    rights of the container to serialize even stateless session bean
    invocations. This would certainly be a dumb thing to do, but the
    application would still work.
    Regards,
    Ken

  • How to obtain the manage beans instance to oprate it in javacode

    in the faces,there is some manage bean, but i what to operate it ,eg: carbean.carName = "xxxx"; carbean is a managed bean:
    How to obtain the manage beans instance to oprate it in javacode

             ActivityContentBean activityContentBean = (ActivityContentBean) FacesContext
                        .getCurrentInstance().getApplication().createValueBinding(
                                  "#{currentActivity}").getValue(
                                  FacesContext.getCurrentInstance());

  • How exchange messages between two user-bean instances?

    Hi,
    I would like to let several user to log-in my web site (I'm using tomcat) and then let them exchange some messages until they are logged-in. Is there a way using JSF?
    I was thinking about implementing a list of messages inside each user-bean. The user should know that other users are logged-in, that could be listed in a table, and click on its name. I would like that the click action create an item in the list valiable of the selected user. Is that possible using JSF? I didn't find any of such kind of communication between two user-bean instances.
    Do you have any hints? Is that the right way or is there other possibilities?
    Thanks

    You could get hold of a map of sessions in the application scope. Make use of HttpSessionListener to add/remove sessions to/from the map.
    JSF is just another component based MVC framework on top of JSP/Servlet. Everything which you can do in JSP/Servlet is just still possible. You only need to understand how JSF works under the hood.

  • 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).

  • How can I create a java bean instance from servlet, at runtime?

    Will anybody help me?
    I want to send bean (class) name to a servlet through parameter and I need servlet to create specified bean instance and run its method that I will send through another parameter, at runtime.

    Thanks. I found answer

  • NAccess from a pojo datacontrol method to a bean instance

    Hi I'm using this code to get my bean instance
    FacesContext fctx = FacesContext.getCurrentInstance();
    ELContext elctx = fctx.getELContext();
    ExpressionFactory exprFactory =
    fctx.getApplication().getExpressionFactory();
    ValueExpression ve =
    exprFactory.createValueExpression(elctx, "#{backingBeanScope.ConsumeBean}",
    Object.class);
    ConsumeBean cb = (ConsumeBean)ve.getValue(elctx);
    cb.setName("Daniel");
    and then from ConsumeBean
    private String Name;
    public String cb1_action() {
    System.out.println("Name: " + getName());
    return null;
    public void setName(String Name){
    this.Name = Name;
    public String getName(){
    return Name;
    and it prints null, it seem like i didn't capture the instance...
    I hope you can help me, thanks...
    Edited by: Daniel Almaguer on 23-abr-2012 16:38

    What scopes do you use each of the bean's in ?

  • Message Driven Bean -- Instance Creation..

    As we know MDB (inJMS) acts as a listener to a message coming from either a topic/queue. The instance of MDB is created by the EJB Container and the no. of instances created depend upon the corresponding values specified in the Deployment-Descriptor. So we never have to create instance of MDB bcoz container takes care of itself. MDB is eventDriven and the method onMessage is fired when topic/queue receives a message.
    Now, can I have a scenario where my client creates an instance of MDB explicitly. Say I have an MDB by name TestMDB, I create an instance of MDB using new keyword something like the below code:
    TestMDB testMDB = new TestMDB();
    The client grabs messages which are recd. using onMessage of TestMDB. I put the msgs recd. in onMessage method into some kind of HashMap and return it to the client. This for sure satisfies my requirement, but EJB specification says MDB instances are created by the EJB Container itslef and that does not give me an easy feeling.
    Are there any caveats of creating instances of Message Driven Bean ??

    Hi,
    Why would you like to create your own MDB instance?
    Is it because you don�t want to use an EJB container?
    Otherwise, you should know that the container is doing a lot of work under the cover. It is not that simple to achieved concurrent message processing.
    I would really recommend you to either use an EJB container or to redesign your application. If you really don�t want to use a heavy weight EJB container you can have a look at Arjuna�MDS that provides you with a light weight container allowing to deploy MDBs like applications.
    Hope this helps,
    Arnaud
    www.arjuna.com

  • How to get the Stateful Session bean instance in the second call

    Hi,
    I am new to EJBs. I have made a Stateful session bean on the first jsp page. In this page i am setting certain member variables of the EJB. Now in the second page i want to get these stored values in the EJB.
    In the second page do I...
    1. Store the instance of Remote Interface in the Session Context of the first JSP page and then in the second page get the Remote interface stored in its session context and call the business functions to get the values. If this is the case then what do u mean by Stateful Session beans??
    P.S.- This works fine.
    2. Try to get the Remote interface of that particular instance of the EJB(in which the values were stored) and call its business functions. IF this is possible. How do i do it??
    thanks in advance
    Anurag

    Hi,
    thanks for information. But i have one question. In a stateful session bean why do we have to store the Remote Interface on the client side.
    I expected in the second jsp page when i do a lookup or create, the container/server should find out whether there is a session bean already created for this session if yes, then return that particular instance of the session bean else create a new one.
    If this is not a possible case then a stateful session bean is nuthing but an instance of an object in the EJB container which does not get destroyed unless there is a time out or the remove method is called. It has nuthing to do with session because throughout the session I have to store the remote interface in the session context of the client( the client here means the jsp).
    thanks in advance
    Anurag

Maybe you are looking for