aspose file tools*
The moose likes Other Application Frameworks and the fly likes issues in calling the ejbcontroller (EJB 3.o ) from the controller using spring Frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "issues in calling the ejbcontroller (EJB 3.o ) from the controller using spring Frame" Watch "issues in calling the ejbcontroller (EJB 3.o ) from the controller using spring Frame" New topic
Author

issues in calling the ejbcontroller (EJB 3.o ) from the controller using spring Frame

prajesh kunimal
Greenhorn

Joined: Dec 10, 2008
Posts: 2
HI,
i am new to Spring framework.right now in our project we are working in spring framewok(Mvc Architecture layer).
The issues which i am facing here is i don't know how to call the "EJB CONTROLLER"(which is another layer) from the controller (which is nothing but the servlet) using the "Spring Framwork"

can anybody guide me to foundout the solution for this issue.So that i can proceed further.....Below are the details of my codings

Controller(servlet)
package com.trctc.login.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;
import org.springframework.validation.*;

import com.trctc.login.bd.LoginBD;
import com.trctc.login.bd.Logindelegate;
import com.trctc.login.dto.LoginDTO;
import com.trctc.login.ejbctrl.LoginEJBCtrl;
import com.trctc.login.form.LoginForm;
import com.trctc.login.bd.LoginBD;
import org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean;

//import com.trctc.login.form.LoginForm;

/**
* Servlet implementation class for Servlet: LoginController
*
*/
public class LoginController extends AbstractCommandController{
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/

private LoginBD loginBD;


public LoginController() {
setCommandClass(com.trctc.login.form.LoginForm.class);
}

@Override
protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object command, BindException error) throws Exception {
try {

System.out.println("Control in Controller");
LoginDTO loginDTO = new LoginDTO();
LoginForm loginForm=(LoginForm)command;
System.out.println("Value of User name : " + loginForm.getUsername());
System.out.println("Value of Password : " + loginForm.getPassword());
loginDTO.setUserName(loginForm.getUsername());
loginDTO.setPassword(loginForm.getPassword());
System.out.println("Value of User name : " + loginDTO.getUserName());
System.out.println("Value of Password : " + loginDTO.getPassword());
//Variable userFlag holds the status of the user.
String userFlag = "Fail";
userFlag = loginBD.verifyLogin(loginDTO);
//LoginBD loginBD = null;
/*Logindelegate logindelegate=new Logindelegate();
userFlag=logindelegate.verifyLogin(loginDTO);*/

System.out.println("user Status.."+userFlag);
} catch (Exception e) {
System.out.println("Exception in Controller");
e.printStackTrace();
}
return new ModelAndView("welcome.jsp");
}

public void setLoginBD(LoginBD loginBDImpl){
this.loginBD=loginBDImpl;
}



}
=======================================================================

TRCTC_Servlet.xml Dispatcher File for the Springs)
------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!-- the application context definition for the springapp DispatcherServlet -->
<!-- <bean name="/hello.htm" class="springapp.web.HelloController" /> -->

<bean name="/login.trs"
class="com.trctc.login.controller.LoginController">
<property name="loginBD" ref="loginBDImpl" />
</bean>
<bean id="loginBDImpl" class="com.trctc.login.bd.LoginBDImpl" />

<!--<bean id="loginEJBCtrl" class="com.trctc.login.bd.LoginBDImpl">
<property name="loginEJBCtrl" ref="LoginEJBref" />
</bean>

<bean id="LoginEJBref" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
<property name="jndiName" value="ejb.LoginSLEJBRemoteHome"/>
<property name="businessInterface" value="com.trctc.login.ejbctrl.LoginEJBCtrl"/>
</bean>
-->


</beans>
===========================================================================
 
 
subject: issues in calling the ejbcontroller (EJB 3.o ) from the controller using spring Frame