Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Cannot retrieve definition for form bean null

Posted on 2006-05-03
4
Medium Priority
?
1,894 Views
Last Modified: 2008-01-16
Help please!.

I have been debugging my application time and time again but I can´t find
where is the error.
What displayed by tomcat is: Cannot retrieve definition for form bean null.
I appreciate all the help you guys can give me. I´m really stuck on this.

About my IDE is:

Netbeans 5.0 with tomcat Apache using Struts 1.2.7 and jdk1.5.0_06

All the code and configuration are down this lines:

Customized Action:
package sistema.struts.Actions;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.servlet.*;
import java.sql.*;
import javax.servlet.http.*;
import java.io.*;
import sistema.modelo.Modelo;


public class CustomizedAction extends org.apache.struts.action.Action{
   
  protected ServletContext application;
  private Modelo modelo;
     
    public CustomizedAction() {
    }

    public Modelo getModelo() {
        return modelo;
    }

    public void setModelo(Modelo modelo) {
        this.modelo = modelo;
    }
   
}


The action:
package sistema.struts.Actions;

import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import javax.servlet.*;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


import sistema.struts.actionforms.AutenticacionForm;
import sistema.modelo.gestion.usuario.GestionUsuario;
import sistema.modelo.gestion.cliente.GestionCliente;
import sistema.modelo.busquedas.cliente.*;
import sistema.sitioweb.modelo.*;


public class AutenticacionAction extends CustomizedAction {
   
    /** Creates a new instance of AutenticacionAction */
    public AutenticacionAction() {
    }
   
      public ActionForward execute(ActionMapping mapping,
                                   ActionForm form,
                                   HttpServletRequest request,
                                   HttpServletResponse response)throws IOException, ServletException{        
          String target = new String("success");
          if (form != null){//A                          
             
              AutenticacionForm autenticacionForm = (AutenticacionForm)form;//Se obtienen los datos desde el formulario mostrado en el browser.
             
            /////////////////////////////
            //Empieza logica de la accion
            /////////////////////////////        
            if (autenticacionForm.getUsuario() != null && autenticacionForm.getClave() != null) {
            try {
                   
                    Usuario usuario = new Usuario(autenticacionForm.getUsuario(),autenticacionForm.getClave());                    
                    GestionUsuario gestionUsuario = new GestionUsuario(this.getModelo().getConexion());
                    gestionUsuario.autenticar(usuario);
                    if (usuario.isAutenticado()) {
                            if (usuario.isEmpleado()) {
                                ClaveEmpleado claveEmpleado = new ClaveEmpleado(usuario.getLogin(),usuario.getClave());
                                request.getSession().setAttribute("claveEmpleado",claveEmpleado);
                                target = new String("menuEmpleado");
                            }
                            else {                                
                            if (usuario.isActivo()) {                                
                                GestionBusquedaCliente gc = new GestionBusquedaCliente(this.getModelo().getConexion());
                                Cliente cliente= gc.obtenerCliente(usuario);
                                ClaveCliente claveCliente = new ClaveCliente(usuario.getLogin(), usuario.getClave());
                                request.getSession().setAttribute("claveCliente", claveCliente);
                                request.getSession().setAttribute("cliente", cliente);
                                target = new String("inicialCliente");
                            }
                            else {
                                target = new String("solicitarActivacion");
                            }
                            }
                    }
                    else {
                        target = new String("failure");
                        }
                }
            catch (Exception e) {
                throw new ServletException("Autenticacion de Usuario:Ejecución:"+e.getMessage());
            }
            }
          }//A
            /////////////////////////////
            //Termina logica de la accion
            /////////////////////////////
           return(mapping.findForward(target));// Se redirecciona a la siguiente pagina correspondientemente.
      }
}//Termina AutenticacionAction

The bean:


package sistema.struts.actionforms;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
       

public class AutenticacionForm extends ActionForm{
    private String usuario=null;
    private String clave=null;

    public AutenticacionForm() {          
    }

    public String getUsuario() {
        return usuario;
    }

    public void setUsuario(String usuario) {
        this.usuario = usuario;
    }

    public String getClave() {
        return clave;
    }

    public void setClave(String clave) {
        this.clave = clave;
    }    
}


THE JSP:
<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="/errorPage.jsp" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ page import ="java.util.*"%>
<%@ include file ="/WEB-INF/InitModelo.jsp"%>
<%@ page import ="sistema.modelo.*"%>
<%@ page session="true"%>

<html>
    <head>

    <script language="javascript">
        function verificaFormulario(){
        var esValido=true;
        if(document.forms[0].usuario.value=="" || document.forms[0].clave.value==""){
        return false;
        else
        return true;
        }

    </script>
 
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <body bgcolor="#292829" link="#FFBE6B" vlink="#FFCC33" alink="#FFFF00">
        <p align="center"><img src="imagenesDestino/top_sitio_V5.png" width="790" height="155"></p>

        <html:form action="Autenticacion">

            <table width="400" border="0" align="center">
                <tr>
                    <td colspan="2" bgcolor="#292829">
                    <div align="center">
                        <p><font color="#FFFFFF" face="Verdana">Autenticaci&oacute;n
                        de usuario</font></p>
                    </div></td>
                </tr>
                <tr>
                    <td width="41%"><div align="right"><font color="#FFFFFF" face="Verdana">Login</font></div></td>
                    <td width="59%"><div align="left"><font color="#FFFFFF" size="5" face="Courier">
                    <html:text property="usuario"/>
                    &nbsp;</font></div></td>
                </tr>
                <tr>
                    <td><div align="right"><font color="#FFFFFF" face="Verdana">Password</font></div></td>
                    <td>
                    <div align="left">
                        <html:password property="clave"/>
                    </div></td>
                </tr>
                <tr>
                    <td height="8" colspan="2"><div align="center"><font color="#FFFFFF" size="5" face="Courier">      
                        <input name="Limpiar" type="reset" id="Limpiar" value="Limpiar">
                    </font><font color="#FFFFFF" size="5" face="Courier">&nbsp;
                        <input type="submit" name="Submit" value="Ingresar">
                    </font></div></td>
                </tr>
                <tr>
                    <td height="8" colspan="2" bgcolor="#4D4A4D"><div align="center"><font color="#FFFFFF" face="Verdana">Digite
                    sus datos para ingresar al sitio </font></div></td>
                </tr>
            </table>
        </html:form>
        <p align="center">&nbsp;</p>
    </body>
</html>



THE STRUTS CONFIG:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>
      <form-beans>
            <form-bean name="autenticacionForm"
                       type="sistema.struts.actionforms.AutenticacionForm">
                  <form-property name="usuario"
                                 type="java.lang.String"
                                 initial="lleno"
                                 size="50"/>
                  <form-property name="clave"
                                 type="java.lang.String"
                                 initial="lleno"
                                 size="50"/>
            </form-bean>
      </form-beans>
      <global-exceptions/>
      <global-forwards>
            <forward name="autenticacion" path="/Autenticacion.do"/>
      </global-forwards>
       
      <action-mappings>
            <action path="/Autenticacion"
                    type="sistema.struts.actionforms.AutenticacionAction"
                    input="/autenticacion.jsp">
                  <forward name="menuEmpleado"
                           path="/menuEmpleado.html"
                           redirect="false"/>
                        <forward name="inicialCliente"
                                path="/inicialCliente.html"/>
                        <forward name="solicitarActivacion"
                                path="/solicitarActivacion.html"/>
                        <forward name="failure"
                                path="/autenticacion.jsp"/>
            </action>
      </action-mappings>
      <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
      <message-resources parameter="com/myapp/struts/ApplicationResource"/>
      <plug-in className="org.apache.struts.tiles.TilesPlugin">
            <set-property property="definitions-config"
                          value="/WEB-INF/tiles-defs.xml"/>
            <set-property property="moduleAware"
                          value="true"/>
      </plug-in>
      <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
            <set-property property="pathnames"
                          value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
      </plug-in>
</struts-config>


AND.. The web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <context-param>
        <param-name>jdbcDriver</param-name>
        <param-value>com.mysql.jdbc.Driver</param-value>
    </context-param>
    <context-param>
        <param-name>databaseURL</param-name>
        <param-value>ninguno</param-value>
    </context-param>
    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
            <param-name>config</param-name>
            <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>2</param-value>
        </init-param>
        <init-param>
            <param-name>detail</param-name>
            <param-value>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
        </servlet>
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <session-config><session-timeout>
            30
        </session-timeout></session-config><welcome-file-list><welcome-file>
            index.jsp
        </welcome-file></welcome-file-list>
</web-app>



0
Comment
Question by:tarkust
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:evnafets
ID: 16601715
In your struts-config, you are not specifying which form to use with your /Autenticacion action

 <action path="/Autenticacion"
     
-->               name = "autenticacionForm"        <--    // specifies which form to use with this action

                  type="sistema.struts.actionforms.AutenticacionAction"
                  input="/autenticacion.jsp">
               <forward name="menuEmpleado"
                        path="/menuEmpleado.html"
                        redirect="false"/>
                        <forward name="inicialCliente"
                                path="/inicialCliente.html"/>
                        <forward name="solicitarActivacion"
                                path="/solicitarActivacion.html"/>
                        <forward name="failure"
                                path="/autenticacion.jsp"/>
          </action>

Cheers,
evnafets
0
 

Author Comment

by:tarkust
ID: 16606382

Thanks evnafets by your response, however now I get another error: No action instance for path /Autenticacion could be created....  This even when I already verify that the classes folder in web-inf is filled with the right classes.

What could it be?

Thanks in advance.
0
 
LVL 4

Accepted Solution

by:
evnafets earned 2000 total points
ID: 16609795
The class for your action type is wrong.
You have entered  : type="sistema.struts.actionforms.AutenticacionAction"
You declared the class as "sistema.struts.Actions.AutenticacionAction"

0
 

Author Comment

by:tarkust
ID: 16610001
Right!!!!, that was the error then the solution, thank you very much. Now I can debug the Action and verify my code.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you a startup company? Being a startup, you may be using shared hosting, or maybe even dedicated hosting. But have you ever given a thought to using cloud computing now? Yes, don’t be surprised, it is possible for startups to opt for cloud compu…
Ready to kick start your career in 2018? Add app developer skills to your resume. January’s Course of the Month features Android App Development training with hands-on learning.  Read on to learn why these skills are important.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question