1
RMI 서블릿에서 객체를 조회 할 수 없습니다!서블릿에서 RMI 서버를 검색 할 수 없습니다.
오류가 없습니다 : (더 Security Manager를 사용할 RMI 클래스 로더)
서버 코드 :
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, RemoteException, NotBoundException, ParseException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
Registry reg = LocateRegistry.getRegistry("127.0.0.1", 7700);
Metodo metodo = (Metodo) reg.lookup("RMI");
String nome = request.getParameter("nome");
String sexo = request.getParameter("sexo");
String dtNascimento = request.getParameter("dtNascimento");
String cpf = request.getParameter("cpf");
String telefone = request.getParameter("tel");
String logradouro = request.getParameter("logradouro");
String quadra = request.getParameter("quadra");
metodo.CadastroResponsavel(nome, sexo, dtNascimento, cpf, telefone, logradouro, quadra);
request.setAttribute("url", "sucesso");
RequestDispatcher r = request.getRequestDispatcher("index.jsp");
r.forward(request, response);
}
}
내가 인터페이스와 클래스가 : 클라이언트에
public class CrecheServer {
/**
* @param args the command line arguments
* @throws java.rmi.RemoteException
* @throws java.rmi.AlreadyBoundException
*/
public static void main(String[] args) throws RemoteException, AlreadyBoundException {
Registry registry = LocateRegistry.createRegistry(7700);
Metodo metodo = new Metodo();
registry.bind("RMI", metodo);
System.out.println("Servidor Ativo!");
}
}
서블릿 클라이언트 및 서버. 이것은 작동하지 않는 라인입니다.
Metodo metodo = (Metodo) reg.lookup("RMI");
이는 오류가 아닙니다. 그것은 오류에 관한 괄호 안의 주석 *입니다. 게시하고 실제로 * 실제 * 오류 메시지와 스택 추적을 읽습니다. 귀하의 질문에 그들을 편집하십시오. – EJP