Hi,
I am facing one strange problem.
I am calling two functions of same session bean one by one from the client.
In one function I am doing some processing and populating one hashtable,
this hashtable is the data memeber of the class.
But when I am getting this hashtable refrence from the other method the populated
data is not comming. Its size is zero.
Can anybody have the solution ?
My client calling following method first -
readConfiguredWorkFlows(int userId)
//this method populating hashtable.
then taking refrence of the hashtable from the other method
getAllEccsCommandsHashtable()
but hashtable size is zero though its size is >0.
You can see the code below -
Code is like this -
public class WorkflowXmlManipulatorBean
implements SessionBean {
SessionContext sessionContext;
ArrayList workflowsJaxbArrayList = null;
Hashtable eccCommandsHashTable = new Hashtable();
Hashtable workflowPathHashTable = new Hashtable();
final
String TOPDIRPATH = "config" + File.separator + "cm" + File.separator +
"ecc";
final String COMMANDDIRNAME = "commandxml";
final String WORKFLOWXMLDIRNAME = "workflowxml";
public void ejbCreate() throws CreateException {
}
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
/**
*
* @param sessionContext SessionContext
*/
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
}
/**
* This function will read all xml file and put dom into arraylist
* @param userId int
* @return ArrayList
*/
public ArrayList readConfiguredWorkFlows(int userId) {
this.workflowsJaxbArrayList = new ArrayList();
visitAllDirsAndXMLFiles(new File(this.TOPDIRPATH));
return this.workflowsJaxbArrayList;
}
/**
* This function will visit all folders and subfolders and read workflows
* and make dom bjects and store it into the xml.
* @param dir File
*/
public void visitAllDirsAndXMLFiles(File dir) {
String dirName = dir.getName();
if (dir.isDirectory()) {
print("dir name =", dirName, '#');
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
visitAllDirsAndXMLFiles(new File(dir, children[i]));
}
}
else {
if (dirName.endsWith(".xml")) {
print("xml file name =", dirName, '&');
print("xml file path name =", dir.getPath(), '%');
print("Parent name", dir.getParentFile().getName(), '^');
if (dir.getParentFile().getName().equals(this.WORKFLOWXMLDIRNAME)) {
Unmarshaller ui = new Unmarshaller(Workflow.class);
ui.setValidation(false);
try {
Workflow workflow = (Workflow) ui.unmarshal(Workflow.class,
new FileReader(dir));
this.workflowsJaxbArrayList.add(workflow);
}
catch (FileNotFoundException ex) {
ex.printStackTrace();
}
catch (ValidationException ex) {
ex.printStackTrace();
}
catch (MarshalException ex) {
ex.printStackTrace();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
else if (dir.getParentFile().getName().equals(this.COMMANDDIRNAME)) {
Unmarshaller ui = new Unmarshaller(Ne_root.class);
ui.setValidation(false);
try {
Ne_root ne_root = (Ne_root) ui.unmarshal(Ne_root.class,
new FileReader(dir));
ArrayList commandAl = new ArrayList();
for (int i = 0; i < ne_root.getOperationCount(); i++) {
Operation op = ne_root.getOperation(i);
System.out.println("op.getOperation_output()=" + op.getOperation_output());
commandAl.add(op.getOperation_output());
}
String eccname = dir.getParentFile().getParentFile().getName();
print("Eccname = ", eccname, '@');
this.eccCommandsHashTable.put(eccname, commandAl);
System.out.println("###::: hastable size =" + eccCommandsHashTable.size());
}
catch (FileNotFoundException ex) {
ex.printStackTrace();
}
catch (ValidationException ex) {
ex.printStackTrace();
}
catch (MarshalException ex) {
ex.printStackTrace();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}
public Hashtable getAllEccsCommandsHashtable() {
return this.eccCommandsHashTable;
}
}
Thanx in advance-
Vikas Kumar Sahu