Hi!!!
I am trying to invoke an
EJB from the Action class. However, the perform method is not called - the println's do not show up on the server console nor is any error thrown.
---------<<<<Struts-config.xml Entry>>>>-------------
<!-- ========== Form Bean Definitions ================= -->
<form-beans>
<form-bean name="submitForm"
type="hansen.playground.SubmitForm"/>
</form-beans>
<!-- ========== Action Mapping Definitions ============ -->
<action-mappings>
<action path="/submit"
type="hansen.playground.SubmitAction"
name="submitForm"
input="/submit.jsp"
scope="request">
<forward name="success" path="/submit.jsp"/>
<forward name="failure" path="/submit.jsp"/>
</action>
</action-mappings>
-----------------------------------
-------<<<Action class's perform method>>>-------
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)throws IOException, ServletException {
System.out.println("perform called !!!");
SubmitForm f = (SubmitForm) form; // get the form bean
// and take the last name value
String lastName = f.getLastName();
// Translate the name to upper case
//and save it in the request object
request.setAttribute("lastName", lastName.toUpperCase());
/***** Calling EJB ***************************/
String op="";
try {
System.out.println("getting initial context");
Context ctx = getInitialContext();
System.out.println("initial context got !!");
DemoHome home = (DemoHome) ctx.lookup("Demo");
System.out.println("home got !!");
Demo ac = null;
try {
ac = (Demo) home.create();
System.out.println("create called!!");
if (ac==null)
System.out.println("ac is null!");
}
catch (Exception ee) {
System.out.print("exception 1");
}
System.out.println("going to call method!");
if (ac!= null)
op = ac.demoSelect();
else
System.out.println("ac is null->error!!");
//out.println(ac.demoSelect());
//out.println("string got!!");
System.out.println("String="+op);
}
catch (Exception e) {
e.printStackTrace();
System.out.println("error 2");
}
/*********************************************/
// Forward control to the specified success target
return (mapping.findForward("success"));
}
---------------------------------------
What is wrong???