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
Similar Messages
-
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. -
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. -
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. -
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 -
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 -
Custom tag library called multiple times
Hi ppl ,
I have a custom tag library which i use to populate some menu components. When i do call my custom tag library though , it is called multiple times, use case is as follows.
I have menu tabs and menu bars which thanks to Mr.Brenden is working splendidly as so:-
<af:menuTabs>
<af:forEach var="menuTab" items="#{bindings.menu.vwUserMenuTabRenderer.rangeSet}">
<af:commandMenuItem text="#{menuTab.MenuLabel}"
shortDesc="#{menuTab.MenuHint}"
rendered="true"
immediate="true"
selected="#{sessionScope.selectedMenuId == menuTab.MenuId }"
onclick="fnSetSelectedValue('#{menuTab.MenuId}')" >
</af:commandMenuItem>
</af:forEach>
</af:menuTabs>
<af:menuBar>
<af:forEach var="menuBar" items="#{bindings.menu.vwUserMenuBarRenderer.rangeSet}">
<af:commandMenuItem onclick="return clickreturnvalue()"
onmouseover="dropdownmenu(this, event,#{menuBar.MenuId}, '150px')"
onmouseout="delayhidemenu()"
text="#{menuBar.MenuLabel}"
action="#{menuBar.MenuUri}"
rendered="#{menuBar.ParentId == sessionScope.selectedMenuId}"
immediate="true" />
</af:forEach>
</af:menuBar>
</afc:cache>
now all of this code is within a subview , and just directly below the subview tag , i have the call to my custom tag library:-
<myCustomTagLib:menuCascade />
only issue now is that assuming i have in all 7 menu bar components, the doStartTag is called 7 times. the relevant code within my custom tag class is as follows :-
public int doStartTag() throws JspException {
return (EVAL_BODY_INCLUDE);
public int doEndTag() throws JspException {
try {
declareVariables();
return EVAL_PAGE;
}catch (Exception ioe) {
throw new JspException(ioe.getMessage());
and within my declareVariables method i do an out of the jscript ( out.print(jscript.toString()); ) which is a simple string generated based on certain conditions...
now it seems to be working fine on the front end , but when i view the source of the page, i notice that the declaration is called multiple times, and this happens because the doStartTag method is called multiple times, i haven't even nested the call to the custom tag within the menu components , any clue as to whats going wrong ?
Cheers
KHi,
if you add the following print statement
System.out.println("rendering "+FacesContext.getCurrentInstance().getViewRoot().getViewId());
Then the output in my case is
07/04/24 08:14:04 rendering /BrowsePage.jsp
07/04/24 08:14:05 rendering /otn_logo_small.gif
The image comes from the file system, which means it is rendered by the JSF lifecycle. If you reference the image with a URL then the lifecycle doesn't render the image but only refrences it.
To avoid your prepare render code to be executed multiple times, just check for jsp and jspx file extensions, which will guarantee that your code only executes for JSF pages, not for loaded files.
The reason why this happens is because the JSF filter is set to /faces , which means all files that are loaded through that path
Frank -
CommandLink Disabled called multiple times
Hello,
I'm developing a brief method to enable/disable af:commandLink on certain condition.
The layout is simple: a table to the left and a panelTabbed to the right. PanelTabbed has a partialTrigger to the table.
In a visible tab there is a commandLink with Disabled attribute bound to a backingBean method.
In this method I placed a System.out.println and I can see that this method is called multiple times.
On pagestart the method is called 2 times.
On table current row change the method is called 3 times.
On tab change out of first tab 1 time.
On tab change to first tab 2 times.
I wen through all the way from commandLink to top component and there are no additional partialTriggers.
Could someone explain this to me, please?
Thanks.
ADF 11.1.1.4Ilya,
Have you tried using the ADF logger (see [url http://blogs.oracle.com/groundside/entry/adventures_in_logging_index]this blog for lots of details, especially part 5)? Replace your System.out.println calls with calls to the logger, crank up the logging level and use the log analyser to see by ADF/JSF phase when things are called.
John -
Why a getter method of a managed bean WILL be called multiple times
Why a getter method of a managed bean WILL be called multiple times during the JSF lifecycle?Why this designed?
This is by design indeed. Each step in the JSF lifecycle can call a getter to get the required information.
-
ADF Faces Tree - getChildren() called multiple times
Hi,
I have a simple tree based on the demo's 'tree.jspx'. Each time I click on a node in this tree, I see that TreeNodeImpl.getChildren() gets called multiple times for each node. This is not an issue in tree.jspx where the tree is static. However in a case where tree is constructed dynamically based on the back end state, it is going to hurt performance. Each getChildren() call then invokes backend methods which could be remote. So multiple getChildren() will invoke backend methods multiple times.
Is this behavior of calling getChildren() multiple times per node a bug? Is there any way for me to avoid it?this is expected behaviour.
Your tree model should cache data and prevent the multiple calls to the back end. -
Backing Bean constructor getting called multiple times
I have a List of records in the Table with a link Add.
When i click Add i show a popup dialog which is attached to the dialogListener.
On clicking OK on the dialog i want to add a record in the List in the backing Bean, but the Bean constructor is getting called multiple times.
and the list to which the table is attached is also getting called multiple times.
is there a way in which the method gets called only once?
Message was edited by:
user607056Hi!
af:table have property ContentDelivery. When <default> (lazy), the table "frame" iz rendered in first page cycle, and content (rows in table) are fetched lazy i.e. in second cycle. Thus, your backing bean is constructed twice.
If you set ContentDelivery to immediate, the table including data rows is generated in single page cycle thus your backing bean is constructed only once.
Hope this helps,
PaKo -
ValidateEntity getting called multiple times
Hi,
There is a parent EO and a child EO. There is a composite association between the parent and child.Association accessors are generated for both source and destination. In the ChildEO's doDML method , the following code is added.
Long abc = getPArentEO().getAttr1();
Long xyz = getPArentEO().getAttr2();
setAttr3(abc);
setAttr4(xyz);
super.doDML();
getParentEO() is the association accessor .
After the addition of this code, all the method validators of the parent are getting fired more than once. The validateEntity of the parentEO is getting called more than once if I set some attribute of the childEO in childEO's doDML . Is this the expected behaviour?
Thanks.Even on adding the setter in prepareForDML (either in parent or child) , the validateEntity is getting called multiple times. In fact ,validateEntity is getting called once before prepareForDML and again after. One of my method validators fail on the subsequent call giving an error ..Please help.
-
ItemEditEnd called multiple times
Hi.
Am using a datagrid and using an item editor and item render for that. Item Renderer --> To give background color and Item Editor - to show a date picker. While implementing this, my need is to open a popup when we enter date. But, am getting the popup thrice , sometimes during "on change" and sometimes, when I press "Enter" or "Tab out" . When analyzed further, I noticed that itemEditEnd event is called thrice. Can anyone let me know the alternative for this please ? Here is my code.
<mx:AdvancedDataGrid width="1000" height="300" horizontalScrollPolicy="auto"
id="dProvider" creationComplete="init()" verticalScrollPolicy="auto" editable="true" itemEditBeginning="checkIfAllowed(event)" selectionMode="singleCell" itemEditEnd="onEditEnd(event)">
private function onEditEnd(event:AdvancedDataGridEvent):void
var oTaskPopupObj:TaskPopUp = new TaskPopUp();
PopUpManager.addPopUp(oTaskPopupObj,this,true);
//This part is called thrice !!!
I have been struggling to get rid of this issue. Would be very happy if I get a help quickly !
Thanks
BalaThanks for being patient and answering my questions.
And yes, the itemEditEnd is called multiple times, even for other scenarios. Find below a sample code, where-in, iam using date editor to validate the field entered. Here too, the itemEditEnd is called thrice( you can notice that the alert creeps up thrice). Let me know if you need anything else
Main mxml
[[ [Bindable]
private var compManDataDef:XML =<CompManData>
<row>
<Phase>Program Start</Phase>
<Date>Plan</Date>
<Gate>Enter Date</Gate>
<WBP>TBD</WBP>
</row>
<row>
<Phase></Phase>
<Date>Actual</Date>
<Gate>TBD</Gate>
<WBP>TBD</WBP>
</row>
private function onEditEnd(event:AdvancedDataGridEvent):void
Alert.show("in date validate");
<mx:AdvancedDataGrid width="100%" height="72%" horizontalScrollPolicy="auto" id="
dProvider" creationComplete="init()" dragEnabled="true" lockedColumnCount="5" editable="true" itemEditBeginning="checkIfAllowed(event)" selectionMode="singleCell" itemEditEnd="onEditEnd(event)">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="
Phase"headerText="" width="
137" wordWrap="true" textAlign="center" itemRenderer="renderer.ColorwithLable" editable="false">
</mx:AdvancedDataGridColumn>
<mx:AdvancedDataGridColumn dataField="
Date"headerText="" width="
120" itemRenderer="renderer.ColorwithLable" editable="false"/>
<mx:AdvancedDataGridColumn id="
Gate" dataField="Gate"headerText="
Gate" width="120" editorDataField="newEmployeeType" labelFunction="dglfFormatDate" itemEditor="dateEditing" itemRenderer="renderer.ColorwithLable" />
<mx:AdvancedDataGridColumn id="
WBP" dataField="WBP"headerText="
WBP" width="120" itemRenderer="renderer.ColorwithLable"/>
</mx:AdvancedDataGrid>
editingDate.mxml......
<?xml version="1.0" encoding="utf-8"?><mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initMe()" >
<mx:Script><![CDATA[
import mx.managers.PopUpManager;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
import mx.controls.AdvancedDataGrid;
import mx.controls.advancedDataGridClasses.AdvancedDataGridListData;
Bindable]
public var tempVal:String = "";
public var newEmployeeType:String = "";
public var newEmployeeType1:String = "";
private function dateChanged(date:Date):void {
if (date == null)newEmployeeType =
elsenewEmployeeType = (date.getMonth()+1).toString() +
'/' + date.getDate().toString() + '/' + date.getFullYear().toString() ;}
private function initMe():void{tempVal = data.Gate;
if (tempVal != null) {dateField1.text =tempVal.toString();
]]>
</mx:Script><mx:DateField id="dateField1" yearNavigationEnabled="true" change="dateChanged(DateField(event.target).selectedDate)"/></mx:HBox
> -
PrepareRender() called multiple times if I have HTML/Images on a JSF page
I have extended ADFPhaseListener and also FacesPageLifecycle. I am overriding the prepareRender() method in the CustomFacesPageLifecycle.
When I insert an image on to the page in the branding facet or add any html using verbatim tag, the prepareRender() method is called two times. I am not sure why?
If I remove the images/html, the method is only executed once.
If I have image/html in the page, another strange thing is that the first time all the custom lines of code gets executed in prepareRender() method. But the second time only first few lines of code in the prepareRender() method. This seems to me a very wierd behaviour.
Any inputs from ADF product dev team?
Thanks
- Amit KocharHi,
if you add the following print statement
System.out.println("rendering "+FacesContext.getCurrentInstance().getViewRoot().getViewId());
Then the output in my case is
07/04/24 08:14:04 rendering /BrowsePage.jsp
07/04/24 08:14:05 rendering /otn_logo_small.gif
The image comes from the file system, which means it is rendered by the JSF lifecycle. If you reference the image with a URL then the lifecycle doesn't render the image but only refrences it.
To avoid your prepare render code to be executed multiple times, just check for jsp and jspx file extensions, which will guarantee that your code only executes for JSF pages, not for loaded files.
The reason why this happens is because the JSF filter is set to /faces , which means all files that are loaded through that path
Frank -
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...
Maybe you are looking for
-
Convert Multiple Rows in a single Comma Seprated value
Is is possible to convert miltiple rows in a single value by concatenating each row value in OBIEE. I think OI had seem a blog post relted to this by I'm not able to to find it again. Basically Here is what I would like to do: Customer number Locatio
-
New @ RMI need help with java.rmi.UnmarshalException: error unmarshalling
Hi @ all out there, I'm new with Java RMI and have to write a EventSystem for an college project where clients can subscribe to a topic and get notified when someone publishes a message to the subscribed topic. At server-side I have a class called Ev
-
Can I use attunity CDC to propagate changes from sql server to a sybase database
can i use attunity cdc components in sql server to propagate changes to a sybase destination. I did some experimenting with cdc in ssis 2012 and got it working to send changes to sybase, but I need to do this for approx 5000 tables. so looking for a
-
Hi My IPhone 4 Is Stuck on The Screen With THe ITunes Logo And The USB This Happened After I Updated From IOS 4.3 To IOS 5 It Is Not Appearing In Itunes Devices. Please Help
-
Handling dust and scratches in Aperture
Hi all, I have been looking for some kind of tool within Aperture that might be able to help dealing with dust and scratches on scanned film. For dust spots, the spot and patch tool seems to help, but for scratches and other fine blemishes that take