Finalize() method being called multiple times for same object?

I got a dilly of a pickle here.
Looks like according to the Tomcat output log file that the finalize method of class User is being called MANY more times than is being constructed.
Here is the User class:
package com.db.multi;
import java.io.*;
import com.db.ui.*;
import java.util.*;
* @author DBriscoe
public class User implements Serializable {
    private String userName = null;
    private int score = 0;
    private SocketImage img = null;
    private boolean gflag = false;
    private Calendar timeStamp = Calendar.getInstance();
    private static int counter = 0;
    /** Creates a new instance of User */
    public User() { counter++;     
    public User(String userName) {
        this.userName = userName;
        counter++;
    public void setGflag(boolean gflag) {
        this.gflag = gflag;
    public boolean getGflag() {
        return gflag;
    public void setScore(int score) {
        this.score = score;
    public int getScore() {
        return score;
    public void setUserName(String userName) {
        this.userName = userName;
    public String getUserName() {
        return userName;
    public void setImage(SocketImage img) {
        this.img = img;
    public SocketImage getImage() {
        return img;
    public void setTimeStamp(Calendar c) {
        this.timeStamp = c;
    public Calendar getTimeStamp() {
        return this.timeStamp;
    public boolean equals(Object obj) {
        try {
            if (obj instanceof User) {
                User comp = (User)obj;
                return comp.getUserName().equals(userName);
            } else {
                return false;
        } catch (NullPointerException npe) {
            return false;
    public void finalize() {
        if (userName != null && !userName.startsWith("OUTOFDATE"))
            System.out.println("User " + userName + " destroyed. " + counter);
    }As you can see...
Every time a User object is created, a static counter variable is incremented and then when an object is destroyed it appends the current value of that static member to the Tomcat log file (via System.out.println being executed on server side).
Below is the log file from an example run in my webapp.
Dustin
User Queue Empty, Adding User: com.db.multi.User@1a5af9f
User Dustin destroyed. 0
User Dustin destroyed. 0
User Dustin destroyed. 0
User Dustin destroyed. 0
User Dustin destroyed. 0
USER QUEUE: false
INSIDE METHOD: false
AFTER METHOD: false
User Dustin destroyed. 1
User Dustin destroyed. 1
User Dustin destroyed. 1
User Dustin destroyed. 1
USER QUEUE: false
INSIDE METHOD: false
AFTER METHOD: false
User Dustin destroyed. 2
User Dustin destroyed. 2
User Dustin destroyed. 2
User Dustin destroyed. 2
User Dustin destroyed. 2
User Dustin destroyed. 2
User Dustin destroyed. 2
User Dustin destroyed. 2
USER QUEUE: false
INSIDE METHOD: false
AFTER METHOD: false
User Dustin destroyed. 3
User Dustin destroyed. 3
User Dustin destroyed. 3
User Dustin destroyed. 3
User Dustin destroyed. 3
User Dustin destroyed. 3
User Dustin destroyed. 3
User Dustin destroyed. 3
User Dustin destroyed. 3
USER QUEUE: false
INSIDE METHOD: false
AFTER METHOD: false
User Dustin destroyed. 4
User Dustin destroyed. 4
User Dustin destroyed. 4
User Dustin destroyed. 4
User Dustin destroyed. 4
User Dustin destroyed. 4
User Dustin destroyed. 4
User Dustin destroyed. 4
User Dustin destroyed. 4
USER QUEUE: false
INSIDE METHOD: false
AFTER METHOD: false
User Dustin destroyed. 5
User Dustin destroyed. 5
User Dustin destroyed. 5
User Dustin destroyed. 5
User Dustin destroyed. 5
User Dustin destroyed. 5
User Dustin destroyed. 5
User Dustin destroyed. 5
User Dustin destroyed. 5
USER QUEUE: false
INSIDE METHOD: false
AFTER METHOD: false
User Dustin destroyed. 6
User Dustin destroyed. 6
User Dustin destroyed. 6
User Dustin destroyed. 6
User Dustin destroyed. 6
User Dustin destroyed. 6
User Dustin destroyed. 6
User Dustin destroyed. 6
User Dustin destroyed. 6
User Dustin destroyed. 6
Joe
USER QUEUE: false
INSIDE METHOD: false
AFTER METHOD: false
User Dustin pulled from Queue, Game created: Joe
User Already Placed: Dustin with Joe
User Dustin destroyed. 7
User Dustin destroyed. 7
User Dustin destroyed. 7
User Dustin destroyed. 7
User Dustin destroyed. 7
User Dustin destroyed. 7
User Dustin destroyed. 7
User Dustin destroyed. 7
User Dustin destroyed. 7
User Dustin destroyed. 7
INSIDE METHOD: false
INSIDE METHOD: false
USER QUEUE: true
INSIDE METHOD: false
INSIDE METHOD: false
User Dustin destroyed. 9
User Joe destroyed. 9
User Dustin destroyed. 9
User Dustin destroyed. 9
User Dustin destroyed. 9
User Dustin destroyed. 9
INSIDE METHOD: true
INSIDE METHOD: false
USER QUEUE: true
INSIDE METHOD: false
INSIDE METHOD: false
INSIDE METHOD: true
INSIDE METHOD: false
USER QUEUE: true
INSIDE METHOD: false
INSIDE METHOD: false
It really does seem to me like finalize is being called multiple times for the same object.
That number should incremement for every instantiated User, and finalize can only be called once for each User object.
I thought this was impossible?
Any help is appreciated!

Thanks...
I am already thinking of ideas to limit the number of threads.
Unfortunately there are two threads of execution in the servlet handler, one handles requests and the other parses the collection of User objects to check for out of date timestamps, and then eliminates them if they are out of date.
The collection parsing thread is currently a javax.swing.Timer thread (Bad design I know...) so I believe that I can routinely check for timestamps in another way and fix that problem.
Just found out too that Tomcat was throwing me a ConcurrentModificationException as well, which may help explain the slew of mysterious behavior from my servlet!
The Timer thread has to go. I got to think of a better way to routinely weed out User objects from the collection.
Or perhaps, maybe I can attempt to make it thread safe???
Eg. make my User collection volatile?
Any opinions on the best approach are well appreciated.

Similar Messages

  • LoginModule login() method being called multiple times

    I have a J2EE application that is deployed in Oracle 10g 10.1.2.0.2 that implements a cutom login module. The custom class (MyClassLoginModule) implements the LoginModule interface. Everything works great if the username and password entered by an end user are correct. However, it appears that if a user enters an incorrect password after failing authentication the container executes the MyClassLoginModule.login() method again. In some cases, it calls it serveral time each failing authentication.
    This wouldn't be a problem however, the username and password are also the end users workstation accounts. This behaviour is capable of locking their accounts in one failed attempt.
    Any help or insight would be greatly appreciated.

    We're using FORM based authentication. The problem is not with multiple requests, but appears to be an issue with the container. See the following for more info:
    LoginModule login method called twice on unsuccessful logins

  • On Execute operation, the bean getter is being called multiple times

    Hi,
    I have a JCR data control, i am trying to write a method that returns predicate, but this method is being called multiple times, when executing the advanced search operation.
      public List<Predicate> getPredicates() {
      ArrayList<Predicate> predicates = new ArrayList<Predicate>();
       // predicates.add(new Predicate("jcr:content/idc:metadata/idc:xScope",Operator.EQUALS,"GLOBAL"));
      DCBindingContainer bc=(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
      JUCtrlListBinding attrBinding=(JUCtrlListBinding)  bc.findCtrlBinding("StateId");
      Object stateId= attrBinding.getSelectedValue();
      if(stateId instanceof Row){
      predicates.add(new Predicate("jcr:content/idc:metadata/idc:xState"
      , Operator.EQUALS
      ,((Row)stateId).getAttribute("StateId").toString()));
      attrBinding=(JUCtrlListBinding)  bc.findCtrlBinding("DistrictId");
      Object districtId=attrBinding.getSelectedValue();
      if(districtId instanceof Row){
          predicates.add(new Predicate("jcr:content/idc:metadata/idc:xDistrict",Operator.EQUALS,((Row)districtId).getAttribute("DistrictId").toString()));
        attrBinding=(JUCtrlListBinding)  bc.findCtrlBinding("Scope");
        Object scopeId=attrBinding.getSelectedValue();
        if(scopeId instanceof Row){
            predicates.add(new Predicate("jcr:content/idc:metadata/idc:xScope",Operator.EQUALS,((Row)scopeId).getAttribute("ScopeType")));
        AttributeBinding tempAttrBinding=(AttributeBinding)bc.findCtrlBinding("CreatedDate");
        Object createdDate=tempAttrBinding.getInputValue();
        if(createdDate!=null){
            predicates.add(new Predicate("jcr:content/jcr:created",Operator.EQUALS,createdDate.toString()));
        if (predicates.size()>0){
          return predicates;
      return Collections.emptyList();
      } The problem is while it's being called multiple times different list's are being returned which is causing the method not to work . The bean is in pageFlowScope .

    That is bc ADF life cicle... Is always executing 2 times...

  • CommandLink in dataTable rendered method is called multiple times

    I have a dataTable in which one of the columns contains a commandLink. The commandLink has the "rendered" option bound to a backing bean method. When the page is submitted, the backing bean method gets called 8 times for each row in the table if the value returned is "true" and 3 times per row if the value returned is "false". Since the page is designed to "navigate" back to itself, I can understand it getting called more than once, but 8 times??? What's up with that?

    Because you have a bug in your code.
    If you want further help post a Short, Self Contained, Compilable and Executable, Example Program ([url http://homepage1.nifty.com/algafield/sscce.html]SSCCE) that demonstrates the problem.
    And don't forget to use [url http://forum.java.sun.com/help.jspa?sec=formatting]code formatting when posting code.

  • Valuechange listener called multiple times for checkbox in table.

    Hi All,
    I'm trying to understand how value change listeners work for checkbox components within a table column. I have a checkbox declared as below
    <af:selectBooleanCheckbox id="sbc1"
    valueChangeListener="#{pageFlowScope.classfiyBean.checkBoxValueChangeListener}"
    immediate="true"
    autoSubmit="true" />
    I notice the value change listener is called multiple times. There are 6 rows in the table within which the checkbox is a component. It is called 6 times for a change. How do I prevent this from happening as it's over writing the values of the other rows as well.
    Scenario : The page is based on a human task, so the outcome button cannot be set to Immediate = true since there are other validations on the page.
    JDev: 11.1.1.4
    Thanks
    PP

    Hi
    Please make sure that Is there any logic being implemented in WD MODIFY VIEW of view controller.
    If yes that may be the cause of your problem because WDModifyView() is being called every time u perform an action.
    or
    Try to Invalidate current context node which is bound to table UI element and actually containing data at run time. I think this node is not being refreshed. Try to refresh it in Search Button action.
    or
    Check your loop code snippet, if you implemented it anywhere.
    Mandeep Virk

  • Listener method is called multiple times

    why is a listener method called multiple times when the user interacted
    with the component just once?

    Because you have a bug in your code.
    If you want further help post a Short, Self Contained, Compilable and Executable, Example Program ([url http://homepage1.nifty.com/algafield/sscce.html]SSCCE) that demonstrates the problem.
    And don't forget to use [url http://forum.java.sun.com/help.jspa?sec=formatting]code formatting when posting code.

  • Init method is called multiple times

    Hi,
    init method in my servlet is called more than 1 time.
    I think it is supposed to be called only 1 time,when the application is loaded.
    anything to do with web.xml ???
    or else what r the situations that init method is called more than 1 time
    thanks

    Hi,
    actually I figured out the problem.
    I am using logger staements for debugging.
    I am also using singlethread model for servlet.
    I came to know that it creates multiple instances of servlet...
    which inturn calls init method multiple times.
    i took out that singlethread model,now it is working perfect.
    Thanks

  • Action method getting called multiple times.

    Hi All,
    The problem that I am facing is pretty weird.
    The issue is the i have an input field that takes date as input field.
    This field is inside a data taable
    FYI: I tried converter still same problem.
    So when ever I enter wrong data as "asda" inside this date field I get a validation error. which is good. So assume it took me 3 submit clicks to fix all my errors on the page.
    So now when I click the submit for the 4th time.
    The action method gets trigerred 4 times.
    Desperately waiting for a fix.
    Thank you in advance.
                                            <h:dataTable id="disbursementTable"
                                                 value="#{certTemplateBean.disbursements}" var="disbursement"
                                                 binding="#{certTemplateBean.disbursementTable}"
                                                 columnClasses="disburseDate,disburseAmt,disburseAction"
                                                 styleClass="disbursementTable" cellspacing="0" cellpadding="1">
                                                 <h:column >
                                                      <h:inputText id="disburseDate" styleClass="#{certTemplatesListBean.errorHolder.disburseDate} ms" size="10"
                                                                value="#{disbursement.date}">
                                                           <f:validator validatorId="RegExp" />
                                                           <f:attribute name="regexp" value="[0-9]{2}/[0-9]{2}/[0-9]{4}" />                                             
                                                           <f:attribute name="fieldRef" value="Disbursement Date :" />
                                                           <f:attribute name="message" value="Invalid Date" />
                                                           <f:attribute name="bean" value="certTemplatesListBean" />
                                                      </h:inputText>
                                                 </h:column>
                                            </h:dataTable>
                                            <h:commandLink id="addPro"
                                                 action="#{certTemplatesListBean.doAddUpdateCertTemplate}">
                                                 <h:outputText value="Add Profile direct"/>
                                            </h:commandLink>

    Probably got to do with the JSF jar files. I am not sure though. Can you check if the below link is useful?
    http://jira.jboss.com/jira/browse/AJSF-127

  • Function being called multiple times

    Hi,
    In my custom workflow, when the user approves a notification, it goes to the next function in the workflow. I have used insert command in that function to insert data into a custom table. I see that the data is inserted 2 times with different values.
    I was wondering how the insert statement is called 2 times when it was supposed to do only once?
    Any suggestions?
    Thanks in advance.

    2 Scenarios that can occur:
    1) Check if you have a post notification function which is also doing an insert into the custom table.
    2) Make sure that the procedure being called by your function activity have proper if conditions for funcmode. Pasting the extract from Workflow Developer Guide:
    Standard API for PL/SQL Procedures Called by Function Activities
    All PL/SQL stored procedures that are called by function or notification activities in an Oracle Workflow process should follow this standard API format so that the Workflow Engine can properly execute the activity.
    Important: The Workflow Engine traps errors produced by function activities by setting a savepoint before each function activity. If an activity produces an unhandled exception, the engine performs a rollback to the savepoint, and sets the activity to the ERROR status. For this reason, you should never commit within the PL/SQL procedure of a function activity. The Workflow Engine never issues a commit as it is the responsibility of the calling application to commit.
    For environments such as database triggers or distributed transactions that do not allow savepoints, the Workflow Engine automatically traps "Savepoint not allowed" errors and defers the execution of the activity to the background engine.
    Oracle Workflow components that continue workflow processing asynchronously, such as background engines and the Notification System, do issue commits when appropriate on behalf of the calling application.
    The example in this section is numbered with the notation (1) for easy referencing. The numbers themselves are not part of the procedure.
    (1) procedure <procedure name>
    (itemtype in varchar2,
    itemkey in varchar2,
    actid in number,
    funcmode in varchar2,
    resultout out varchar2) is
    (2) <local declarations>
    (3) begin
    if ( funcmode = 'RUN' ) then
    <your RUN executable statements>
    resultout := 'COMPLETE:<result>';
    return;
    end if;
    (4) if ( funcmode = 'CANCEL' ) then
    <your CANCEL executable statements>
    resultout := 'COMPLETE';
    return;
    end if;
    (5) if ( funcmode = 'SKIP' ) then
    <your SKIP executable statements>
    resultout := 'COMPLETE:<result>';
    return;
    end if;
    (6) if ( funcmode = 'RETRY' ) then
    <your RETRY executable statements>
    resultout := 'COMPLETE:<result>';
    return;
    end if;
    (7) if ( funcmode = 'VALIDATE' ) then
    <your VALIDATE executable statements>
    resultout := 'COMPLETE';
    return;
    end if;
    (8) if ( funcmode = 'RESPOND' ) then
    <your RESPOND executable statements>
    resultout := 'COMPLETE';
    return;
    end if;
    (9) if ( funcmode = 'FORWARD' ) then
    <your FORWARD executable statements>
    resultout := 'COMPLETE';
    return;
    end if;
    (10) if ( funcmode = 'TRANSFER' ) then
    <your TRANSFER executable statements>
    resultout := 'COMPLETE';
    return;
    end if;
    (11) if ( funcmode = 'QUESTION' ) then
    <your QUESTION executable statements>
    resultout := 'COMPLETE';
    return;
    end if;
    (12) if ( funcmode = 'ANSWER' ) then
    <your ANSWER executable statements>
    resultout := 'COMPLETE';
    return;
    end if;
    (13) if ( funcmode = 'TIMEOUT' ) then
    <your TIMEOUT executable statements>
    if (<condition_ok_to_proceed>) then
    resultout := 'COMPLETE';
    else
    resultout := wf_engine.eng_timedout;
    end if;
    return;
    end if;
    (14) if ( funcmode = '<other funcmode>' ) then
    resultout := ' ';
    return;
    end if;
    (15) exception
    when others then
    WF_CORE.CONTEXT ('<package name>', '<procedure name>',
    <itemtype>, <itemkey>,
    to_char(<actid>), <funcmode>);
    raise;
    (16) end <procedure name>;

  • Call Multiple RTF for same data model

    How call two templates for the same data model.
    what is the logic i have to use in the rtf template.
    Thanks in Advance

    Your RTF template will use the data model you defined.
    So no logic than just inserting the xml elements your data model provides.
    You can associate multiple templates to one data model. At runtime you will have the opportunity to select
    the template of your desire to run the data against.
    If you want this process to be automated then you will have to user bursting and for that you need to read this:
    http://download.oracle.com/docs/cd/E14571_01/bi.1111/e13881/T527073T555155.htm#T555156
    Cheers
    Jorge
    p.s If this answers your question then please grant the points and close the thread

  • How do I get refund for being charged multiple times for single download

    I have just been charged multiples of times for my last three purchases . How do get refunded?

    Click Support at the top of this page, then click the link under Contact Apple Support

  • Webservice being called multiple times throws strange error

    This is something that just started occurring and doesn't make much sense to me.
    Using JDK 1.7 and doing the following:
    FlashlineRegistryTr registry = new FlashlineRegistryTrServiceLocator().getFlashlineRegistryTr(lUrl);
    ((Stub)registry).setMaintainSession(true);
    I can call registry.authTokenCreate(USERNAME, CREDENTIAL);  ONCE and it works fine.  When I immediately call it again, same command, it fails with the exception below.
    The issue has to do with setting the Maintain Session to true.  If I remove that line it works fine, however I need that in there.
    Any thoughts on where to even begin to look? 
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
    faultSubcode:
    faultString: Tried to invoke method public com.flashline.cmee.openapi.databeans.AuthTokenBean com.flashline.cmee.openapi.service.FlashlineRegistry.authTokenCreate(java.lang.String,java.lang.String) throws com.flashline.framework.exception.OpenAPIException with arguments java.lang.String,java.lang.String.  The arguments do not match the signature.; nested exception is:
      java.lang.IllegalArgumentException: object is not an instance of declaring class
    faultActor:
    faultNode:
    faultDetail:
      {http://xml.apache.org/axis/}hostname:slc03rii.us.oracle.com
    Tried to invoke method public com.flashline.cmee.openapi.databeans.AuthTokenBean com.flashline.cmee.openapi.service.FlashlineRegistry.authTokenCreate(java.lang.String,java.lang.String) throws com.flashline.framework.exception.OpenAPIException with arguments java.lang.String,java.lang.String.  The arguments do not match the signature.; nested exception is:
      java.lang.IllegalArgumentException: object is not an instance of declaring class
      at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:221)
      at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:128)
      at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
      at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at javax.xml.parsers.SAXParser.parse(SAXParser.java:392)
      at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
      at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
      at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
      at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
      at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
      at org.apache.axis.client.Call.invokeEngine(Call.java:2765)
      at org.apache.axis.client.Call.invoke(Call.java:2748)
      at org.apache.axis.client.Call.invoke(Call.java:2424)
      at org.apache.axis.client.Call.invoke(Call.java:2347)
      at org.apache.axis.client.Call.invoke(Call.java:1804)
      at com.flashline.registry.openapi.service.v300.FlashlineRegistryTrSoapBindingStub.authTokenCreate(FlashlineRegistryTrSoapBindingStub.java:7676)
      at com.flashline.registry.openapi.MikeTest.setUp(MikeTest.java:131)
      at junit.framework.TestCase.runBare(TestCase.java:125)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:131)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

    One possible solution is store the LOV values in some scope while retrieving it first time from the web service.
    Next time whenever LOV is called then return the LOV values from the scope instead of calling the web service.
    psedo code:
            if (ADFContext.getCurrent() != null &&
                ADFContext.getCurrent().getSessionScope().containsKey("LOV_LIST")) {
                LOVList =
                        (List<SelectItem>)ADFContext.getCurrent().getSessionScope().get("LOV_LIST");
            } else {
                LOVList = this.populateVendorListFromWS();
                ADFContext.getCurrent().getSessionScope().put("LOV_LIST",
                                                              LOVList );
            }Hope it helps.

  • C# Constructo​r being called multiple times when I run my VI

    Hi all,
    We are runing LabVIEW 8.51 in the lab and have been using a bodged together C++ DLL which was crude but got the job done. Now looking at rewriting it in C# to make it easier to maintain and support long term.
    Ive got the C# DLL appearing in Labview and can happily call my test functions from the VI to prove both the DLL inputs and outputs are working fine (the simple input a number, add 1 and return result type of code).
    However, this DLL will end up managing a Serial port connection so the contstructor must only be called once as its responsible for making my .net serial port object. Ive added a text log message in the constructor and have found that just running the VI is causing the constructor to be called at least 5 times a second. There is no user input causing this....just running the VI.
    Both VI and C# source is attached.
    Any ideas folks? Im a complete newbie at LabVIEW having taken this on from another developer.
    The VI is in \Release and this is where the Log file is generated.
    Mat
    Attachments:
    Bus Pirate LabVIEW.zip ‏78 KB

    Ummmm.. yes, loop. That big thing gray rectangle that surrounds your code. Have you done any LabVIEW tutorials? That isn't even a LabVIEW question, but a basic programming question.
    To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. There are also several Technical Resources. You can also take the online courses for free.

  • H:commandLink and an Action being called multiple times.

    Hi everyone. I'm more or less relatively new in terms of JSF, though I've had to do a lot of "catching up" recently.
    I've been reading that with managed-beans, the getters/setters are not gaurenteed to be called once. http://www.jsf-faq.com/faqs/faces-misc.html#106
    My question is, are there any reasons why an action method would get called twice? An example of my jsp page.
    <h:commandLink action="#{exploreCaseAction.exploreCase}" >                    
         <h:outputText value="#{case.caseNumber}"/>
         <f:param name="caseId" value="#{case.caseId}"/>
    </h:commandLink>My faces-config
    <managed-bean>
       <managed-bean-name>exploreCaseAction</managed-bean-name>
       <managed-bean-class>com.unyric.cias.cm.web.action.ExploreCaseAction</managed-bean-class>
       managed-bean-scope>request</managed-bean-scope>
       <managed-property>
          <property-name>caseTreeHelper</property-name>
             <value>#{caseTreeHelper}</value>
       </managed-property>
       <managed-property>
          <property-name>caseId</property-name>
             <value>#{param.caseId}</value>
       </managed-property>     
       <managed-property>
          <property-name>sessionManager</property-name>
             <value>#{sessionManager}</value>
       </managed-property>               
    </managed-bean>When I click on one of the links and set a breakpoint, it comes up twice. Here's the crazy part. if I use <af:commandLink> then it only runs once.
    Personally I'd rather not use oracles components (I know it got donated and is/will be Trinidad).
    Anyone with any ideas?

    Would you be willing to try the RI (1.1_02) [1] to see if you have the same problem?
    [1] https://javaserverfaces.dev.java.net/servlets/ProjectDocumentList?folderID=5225&expandFolder=5225&folderID=0

  • Unwanted behavior: Action method being called several times

    Hello,
    I have a managed bean that calls a session ejb which itself does a search. The problem is that it is supposed to retrieve a resultset ONCE and the displayed behavior is that it never stop doing so. It fetches the resultset N TIMES.
    Here is the managed bean and the method to look at is the performSearch method:
    package arcoiris;
    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.model.SelectItem;
    public class SearchManagedBean {
        //Collected from search form
        private String keyword;
        private String country;
        private Integer[] postcode;
        private boolean commentExists;
        private Integer rating;
        private boolean websiteExists;
        //Used to populate form
        private List<SelectItem> availableCountries;
        private List<SelectItem> availablePostcodes;
        private List<SelectItem> availableRatings;
        //Retrieved from ejb tier
        private List<EstablishmentLocal> retrievedEstablishments;
        //Service locator
        private arcoiris.ServiceLocator serviceLocator;
        //Constructor
        public SearchManagedBean() {
            System.out.println("within constructor SearchManagedBean");
        //Getters and setters
        public String getKeyword() {
            return keyword;
        public void setKeyword(String keyword) {
            this.keyword = keyword;
        public String getCountry() {
            return country;
        public void setCountry(String country) {
            this.country = country;
        public boolean isCommentExists() {
            return commentExists;
        public void setCommentExists(boolean commentExists) {
            this.commentExists = commentExists;
        public Integer getRating() {
            return rating;
        public void setRating(Integer rating) {
            this.rating = rating;
        public boolean isWebsiteExists() {
            return websiteExists;
        public void setWebsiteExists(boolean websiteExists) {
            this.websiteExists = websiteExists;
        public List<SelectItem> getAvailableCountries() {
            List<SelectItem> countries = new ArrayList<SelectItem>();
            SelectItem si_1 = new SelectItem();
            SelectItem si_2 = new SelectItem();
            SelectItem si_3 = new SelectItem();
            si_1.setValue("2");
            si_1.setLabel("ecuador");
            si_2.setValue("1");
            si_2.setLabel("colombia");
            si_3.setValue("3");
            si_3.setLabel("peru");
            countries.add(si_1);
            countries.add(si_2);
            countries.add(si_3);
            return countries;
        public void setAvailableCountries(List<SelectItem> countries) {
            this.availableCountries = availableCountries;
        public List<SelectItem> getAvailablePostcodes() {
            List<SelectItem> postcodes = new ArrayList<SelectItem>();
            SelectItem si_1 = new SelectItem();
            SelectItem si_2 = new SelectItem();
            SelectItem si_3 = new SelectItem();
            si_1.setValue(new Integer(75001));
            si_1.setLabel("75001");
            si_2.setValue(new Integer(75002));
            si_2.setLabel("75002");
            si_3.setValue(new Integer(75003));
            si_3.setLabel("75003");
            postcodes.add(si_1);
            postcodes.add(si_2);
            postcodes.add(si_3);
            return postcodes;
        public void setAvailablePostcodes(List<SelectItem> availablePostcodes) {
            this.availablePostcodes = availablePostcodes;
        public List<SelectItem> getAvailableRatings() {
            List<SelectItem> ratings = new ArrayList<SelectItem>();
            SelectItem si_1 = new SelectItem();
            SelectItem si_2 = new SelectItem();
            SelectItem si_3 = new SelectItem();
            si_1.setValue(new Integer(1));
            si_1.setLabel("1");
            si_2.setValue(new Integer(2));
            si_2.setLabel("2");
            si_3.setValue(new Integer(3));
            si_3.setLabel("3");
            ratings.add(si_1);
            ratings.add(si_2);
            ratings.add(si_3);
            return ratings;
        public void setAvailableRatings(List<SelectItem> availableRatings) {
            this.availableRatings = availableRatings;
        public Integer[] getPostcode() {
            return postcode;
        public void setPostcode(Integer[] postcode) {
            this.postcode = postcode;
        public List<EstablishmentLocal> getRetrievedEstablishments() {
            return retrievedEstablishments;
        public void setRetrievedEstablishments(List<EstablishmentLocal> retrievedEstablishments) {
            this.retrievedEstablishments = retrievedEstablishments;
        //Business methods
        public String performSearch(){
            System.out.println("performSearchManagedBean begin");
            SearchRequestDTO searchRequestDto = new SearchRequestDTO(this.keyword,this.country,this.postcode,this.commentExists,this.rating, this.websiteExists);
            System.out.println("java bean "+this.keyword+" "+this.country+" "+this.postcode+" "+this.commentExists+" "+this.rating+" "+this.websiteExists);
            SearchSessionLocal searchSession = lookupSearchSessionBean();
            List<EstablishmentLocal> retrievedEstablishments = searchSession.performSearch(searchRequestDto);
            this.setRetrievedEstablishments(retrievedEstablishments);
            System.out.println("performSearchManagedBean end");
            return "success";
        private arcoiris.ServiceLocator getServiceLocator() {
            if (serviceLocator == null) {
                serviceLocator = new arcoiris.ServiceLocator();
            return serviceLocator;
        private arcoiris.SearchSessionLocal lookupSearchSessionBean() {
            try {
                return ((arcoiris.SearchSessionLocalHome) getServiceLocator().getLocalHome("java:comp/env/ejb/SearchSessionBean")).create();
            } catch(javax.naming.NamingException ne) {
                java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ne);
                throw new RuntimeException(ne);
            } catch(javax.ejb.CreateException ce) {
                java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ce);
                throw new RuntimeException(ce);
    }Here is the object request passed:
    package arcoiris;
    import java.io.Serializable;
    public class SearchRequestDTO implements Serializable {
        private String keyword;
        private String country;
        private Integer[] postcode;
        private boolean commentExists;
        private Integer rating;
        private boolean websiteExists;
        public SearchRequestDTO() {
        public SearchRequestDTO(String keyword, String country, Integer[] postcode, boolean commmentExists, Integer rating, boolean websiteExists){
            this.keyword=keyword;
            this.country= country;
            this.postcode = postcode;
            this.commentExists = commentExists;
            this.rating = rating;
            this.websiteExists = websiteExists;
        public String getKeyword() {
            return keyword;
        public void setKeyword(String keyword) {
            this.keyword = keyword;
        public String getCountry() {
            return country;
        public void setCountry(String country) {
            this.country = country;
        public Integer[] getPostcode() {
            return postcode;
        public void setPostcode(Integer[] postcode) {
            this.postcode = postcode;
        public boolean isCommentExists() {
            return commentExists;
        public void setCommentExists(boolean commmentExists) {
            this.commentExists = commmentExists;
        public Integer getRating() {
            return rating;
        public void setRating(Integer rating) {
            this.rating = rating;
        public boolean isWebsiteExists() {
            return websiteExists;
        public void setWebsiteExists(boolean websiteExists) {
            this.websiteExists = websiteExists;
    }and here is the session ejb:
    package arcoiris;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.*;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    public class SearchSessionBean implements SessionBean, SearchSessionLocalBusiness {
        private SessionContext context;
        private arcoiris.ServiceLocator serviceLocator;
        // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click the + sign on the left to edit the code.">
        // TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services)
        // TODO Add business methods or web service operations
         * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
        public void setSessionContext(SessionContext aContext) {
            context = aContext;
         * @see javax.ejb.SessionBean#ejbActivate()
        public void ejbActivate() {
         * @see javax.ejb.SessionBean#ejbPassivate()
        public void ejbPassivate() {
         * @see javax.ejb.SessionBean#ejbRemove()
        public void ejbRemove() {
        // </editor-fold>
         * See section 7.10.3 of the EJB 2.0 specification
         * See section 7.11.3 of the EJB 2.1 specification
        public void ejbCreate() {
            // TODO implement ejbCreate if necessary, acquire resources
            // This method has access to the JNDI context so resource aquisition
            // spanning all methods can be performed here such as home interfaces
            // and data sources.
        // Add business logic below. (Right-click in editor and choose
        // "EJB Methods > Add Business Method" or "Web Service > Add Operation")
        public List<EstablishmentLocal> performSearch(SearchRequestDTO searchRequestDto) {
            System.out.println("within performSearch");
            List<EstablishmentLocal> establishments = new ArrayList<EstablishmentLocal>();
            try {
                Context ctx = new InitialContext();
                DataSource ds = (DataSource)ctx.lookup("java:/guia");
                Connection con = ds.getConnection();
                Statement stm = con.createStatement();
                String query = buildQueryFromSearchRequestDTO(searchRequestDto);
                ResultSet rs = stm.executeQuery(query);
                int rowCount = 0;
                while(rs.next()){
                    rowCount = rowCount + 1;
                    System.out.println("while");
                    try {
                        EstablishmentLocal establishment = lookupEstablishmentBean().findByEstablishmentId(rs.getInt("establishment_id"));
                        establishments.add(establishment);
                        System.out.println("est name "+establishment.getEstablishmentName());
                    } catch (FinderException ex) {
                        ex.printStackTrace();
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                System.out.println("rowCount = "+rowCount);
                rs.close();
                stm.close();
                con.close();
            catch (SearchRequestMalformedException ex){
                ex.printStackTrace();
            }catch (NamingException ex) {
                ex.printStackTrace();
            }catch (SQLException ex){
                ex.printStackTrace();
            //TODO implement performSearch
            return null;
        private String buildQueryFromSearchRequestDTO(SearchRequestDTO searchRequestDto) throws SearchRequestMalformedException {
            StringBuffer sb = new StringBuffer();
            //Head of the query
            sb.append("SELECT ");
            sb.append("e.establishment_id, ");
            sb.append("e.establishment_name, ");
            sb.append("avg(r.rating) as avg_rating ");
            sb.append("FROM ");
            sb.append("establishment e, ");
            sb.append("rating r, ");
            sb.append("comment com, ");
            sb.append("establishment_country ec, ");
            sb.append("country_ref cou ");
            sb.append("where ");
            sb.append("e.establishment_id=ec.establishment_id and ");
            sb.append("ec.country_id=cou.country_id and ");
            sb.append("e.establishment_id=com.establishment_id and ");
            sb.append("r.establishment_id=e.establishment_id and ");
            //Conditional parts of the query
            //If user wants comment to be present
            if(searchRequestDto.isCommentExists()){
                sb.append("e.establishment_id=com.establishment_id and ");
            //If user has typed in a keyword
            if(!searchRequestDto.getKeyword().equals("") && !searchRequestDto.getKeyword().equals(" ")&& searchRequestDto.getKeyword()!=null){
                sb.append("e.establishment_name like '%"+ searchRequestDto.getKeyword() +"%' and ");
            //If user has choosen a country
            if(searchRequestDto.getCountry()!=null && !searchRequestDto.getCountry().equals("") && !searchRequestDto.getCountry().equals(" ")&& searchRequestDto.getCountry()!=null){
                sb.append("ec.country_id = " + searchRequestDto.getCountry() + " and ");
            //If user wants website to be present
            if(searchRequestDto.isWebsiteExists()){
                sb.append("e.establishment_website is not null and ");
    /* conditions
    si utilisateur a renseign� un premier code postal "e.establishment_postcode = 'postcode_one' --si racine
            si autre code postal "or e.establishment_postcode = 'postcode_two'
            ainsi de suite
    and--vient de si racine
            //Tail of the query
            sb.append("0=0 ");
            sb.append("group by e.establishment_id ");
            //If the user wants a minimum rating
            if(searchRequestDto.getRating() != null && searchRequestDto.getRating().intValue()!=0){
                sb.append("having avg(r.rating) >= " + searchRequestDto.getRating());
            sb.append(" ");
            sb.append("order by e.establishment_id ");
            System.out.println("****************************");
            System.out.println(sb);
            System.out.println("****************************");
            return sb.toString();
        private arcoiris.ServiceLocator getServiceLocator() {
            if (serviceLocator == null) {
                serviceLocator = new arcoiris.ServiceLocator();
            return serviceLocator;
        private EstablishmentLocalHome lookupEstablishmentBean() {
            try {
                return (arcoiris.EstablishmentLocalHome) getServiceLocator().getLocalHome("java:comp/env/ejb/EstablishmentBean");
            } catch(javax.naming.NamingException ne) {
                java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ne);
                throw new RuntimeException(ne);
    }I just don't understand why it does so. The peformSearch should be executed ONCE only.
    Here is my face config file:
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE faces-config PUBLIC
      "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
      "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
        <managed-bean>
            <managed-bean-name>SearchManagedBean</managed-bean-name>
            <managed-bean-class>arcoiris.SearchManagedBean</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
        <navigation-rule>
           <description></description>
            <from-view-id>/welcomeJSF.jsp</from-view-id>
            <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>index.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
    </faces-config>Can anyone help?
    Thanks in advance,
    Julien.

    Just reactivating my thread hoping someone will reply to it....
    Julien.

Maybe you are looking for

  • SETUP ERROR WHILE INSTALLING SQL SERVER 2008 R2

    Hi , I'm coming across the following error while installing Microsoft SQL Server 2008R2 SQL Server Setup has encountered the following error: The required MSI package 'D:\SQL Sever 2008 R2 Developer Edition\x86\setup\sql_engine_core_shared_msi\sql_en

  • Airport Extreme saying no connection to the internet - cable modem still showing all is good. Airport Extreme light is still green.

    I am having an issue where my airport extreme is saying there is no connection to the internet but still shows a green light and the status lights on the cable modem are all good. This is affecting both wired and wireless connection. Today I had an i

  • How can I sort by file size in smart folders?

    The Apple info says use pop-up menus to select search criteria, but where is that? I wish to have the folder show all documents bigger than a certain size (ie. video) appear in the folder. My next question, is can I then drag to the Trash from that f

  • VDN Return Destination feature in UCCE ?

    Hi, /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt

  • Issue With Moving Hard Drive Icons on My Desktop

    I recently purchased 3 LaCie 1TB D2 quadra hard dives and daisy chained them to my MacBook Pro using the FireWire 800. I use one for the Time Machine, one to store my photos and one for back-up of my photos. This Lacie icon associated with a HD appea