tags:

views:

130

answers:

1

When i run my JSF i am getting the following exception...

exception

 org.apache.jasper.JasperException: javax.servlet.ServletException:
 javax.servlet.jsp.JspException: javax.faces.el.EvaluationException: 
 javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: ''.
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)

MY JSF code

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%&gt;
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%&gt;
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
  </head>
  <body>
    <f:view>
      <f:loadBundle var="msg" basename="property.menu"/>
      <h:form>
        <h:selectOneMenu id="Name" value="#{myBean.input}">
          <f:selectItem itemLabel="#{msg.Arun}" itemValue="#{msg.Arun}"/>
          <f:selectItem itemValue="#{msg.Hari}" itemLabel="#{msg.Hari}"/>
          <f:selectItem itemValue="#{msg.Jeya}" itemLabel="#{msg.Jeya}"/>
          <f:selectItem itemValue="#{msg.Radhika}" itemLabel="#{msg.Radhika}"/>
          <f:selectItem itemValue="#{msg.Karthik}" itemLabel="#{msg.Karthik}"/>
        </h:selectOneMenu>
      </h:form>
    </f:view>
  </body>
</html>

MY faces-config.xml

<faces-config>
  <managed-bean>
    <managed-bean-name>myBean</managed-bean-name>
    <managed-bean-class>mypackage.bean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
  </managed-bean>
</faces-config>

Web.xml

<servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  <load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.faces</url-pattern>
</servlet-mapping>
+1  A: 

There are at least two flaws:

First in your faces-config:

<managed-bean-class>mypackage.bean</managed-bean-class>

Not sure if this is a typo, but class names ought to start with an upper case. This is just the standard Sun Java Naming Convention. so fix it by:

<managed-bean-class>mypackage.Bean</managed-bean-class>

And rename the actual class to Bean as well, if necessary. This is however not per-se the cause of this particular problem, but bad practices should be cleaned up as soon as possible ;)

Second in your JSF page:

<h:selectOneMenu id="Name" value="#{myBean.input}">

It says myBean, but you only have declared bean in faces config.

<managed-bean-name>bean</managed-bean-name>

Which one is it now? :)

BalusC
its Mybean only... While editing the question i made that mistake...i accept the first correction that u have mention..
Hari