1 Reply Latest reply on Feb 27, 2011 7:05 PM by Tim Evers

    getting Could not instantiate Seam component

    dhanaraja rajendiran Newbie
      while calling my action class i am getting following error

      12:08:06,406 ERROR [viewhandler] Error Rendering View[/employeeManagement/general.jsp]
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: admAppraisalsAction
              at org.jboss.seam.Component.newInstance(Component.java:2144)
              at org.jboss.seam.Component.getInstance(Component.java:2021)
              at org.jboss.seam.Component.getInstance(Component.java:1983)
              at org.jboss.seam.Component.getInstance(Component.java:1977)
              at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
              at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
              at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
              at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
              at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
              at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
              at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
              at org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
              at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
              at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
              at javax.faces.component.UIData.getValue(UIData.java:609)
              at org.ajax4jsf.component.UIDataAdaptor.getValue(UIDataAdaptor.java:1624)
              at org.ajax4jsf.component.SequenceDataAdaptor.getDataModel(SequenceDataAdaptor.java:65)
              at org.ajax4jsf.component.SequenceDataAdaptor.createDataModel(SequenceDataAdaptor.java:59)
              at org.richfaces.component.UIDataTable.createDataModel(UIDataTable.java:120)
              at org.ajax4jsf.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:621)
              at org.ajax4jsf.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:339)
              at org.richfaces.renderkit.AbstractTableRenderer.encodeTableStructure(AbstractTableRenderer.java:138)
              at org.richfaces.renderkit.html.DataTableRenderer.doEncodeBegin(DataTableRenderer.java:160)
              at org.richfaces.renderkit.html.DataTableRenderer.doEncodeBegin(DataTableRenderer.java:148)
              at org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:100)
              at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
              at javax.faces.component.UIData.encodeBegin(UIData.java:962)
              at org.ajax4jsf.component.UIDataAdaptor.encodeBegin(UIDataAdaptor.java:1202)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:934)
              at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
              at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
              at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
              at org.richfaces.renderkit.TabRendererBase.encodeChildren(TabRendererBase.java:113)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
              at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
              at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:285)
              at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:280)
              at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
              at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
              at org.jboss.seam.ui.renderkit.ValidateAllRendererBase.doEncodeChildren(ValidateAllRendererBase.java:33)
              at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
              at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:106)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
              at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:106)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
              at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:178)
              at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:126)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
              at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
              at org.jboss.seam.ui.renderkit.FragmentRendererBase.doEncodeChildren(FragmentRendererBase.java:29)
              at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
              at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
              at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
              at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.InstantiationException: com.sec.ezeeAdmin.employeeManagement.AdmAppraisalsAction
              at java.lang.Class.newInstance0(Unknown Source)
              at java.lang.Class.newInstance(Unknown Source)
              at org.jboss.seam.Component.instantiateJavaBean(Component.java:1438)
              at org.jboss.seam.Component.instantiate(Component.java:1359)
              at org.jboss.seam.Component.newInstance(Component.java:2122)


      this is my action class-->>


      package com.sec.ezeeAdmin.employeeManagement;

      import java.text.DateFormatSymbols;
      import java.text.SimpleDateFormat;
      import java.util.ArrayList;
      import java.util.Calendar;
      import java.util.Date;
      import java.util.GregorianCalendar;
      import java.util.HashMap;
      import java.util.List;
      import java.util.Map;

      import javax.faces.application.FacesMessage;
      import javax.faces.context.FacesContext;
      import javax.persistence.EntityManager;
      import javax.persistence.Query;

      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Begin;
      import org.jboss.seam.annotations.FlushModeType;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.core.Conversation;
      import org.jboss.seam.core.ResourceBundle;

      import com.sec.ezeeAdmin.Status;
      import com.sec.ezeeAdmin.SystemUtils;
      import com.sec.ezeeAdmin.User;
      import com.sec.ezeeAdmin.employeeManagement.AdmAppraisals;
      import com.sec.ezeeAdmin.officeManagement.FixedCosts;
      import com.sec.ezeeAdmin.structure.AttendaceReport;


      @Name("admAppraisalsAction")
      @Scope(ScopeType.CONVERSATION)
      public class AdmAppraisalsAction {

              private Date startDate;
              private boolean history;
              private AdmEmployees employee;

              private AdmAppraisals admAppraisal ;

              @In
              EntityManager entityManager;
              @In(required = true, scope = ScopeType.SESSION)
              User user;
              AdmEmployees admEmployee = new AdmEmployees();
              Date date = new Date();
              private Attendance attendance = new Attendance();
              List<AttendaceReport> report;
              private int recordsPerPage=10;
              @In(required = false, scope = ScopeType.PAGE)
              @Out(required = false, scope = ScopeType.PAGE)
              private List<AdmAppraisals> apprailsHistory;
              private List<AdmEmployeeSalary> salaryHistory;
              private List<Integer> day = new ArrayList<Integer>();
              private Map<Integer, String> days;
              private int selectedMonth = -1;
              private int selectedYear;
              AttendaceReport aReport;;
              private List<AttendaceReport> attendaceReportList = new ArrayList<AttendaceReport>();
              private List<Attendance> attendanceList = new ArrayList<Attendance>();
              private List<AdmEmployeeSalary> employeeSalary;
              private List<Attendance> att;
              AdmEmployeeSalary admSal ;

             
             
              public AdmAppraisalsAction(EntityManager entityManager){
                      this.entityManager=entityManager;
              }
              public String confirmAppraisals() {

                      if (validate()) {
                              if (this.admAppraisal.getId() == 0) {
                                      this.admAppraisal.setCreateDate(date);
                                      this.admAppraisal.setCreateUser(this.user.getUsername());
                                      this.admAppraisal.setEmployee(employee);
                                      entityManager.persist(this.admAppraisal);
                                     
                             
                              } else {
                                      admAppraisal.setModifyDate(date);
                                      admAppraisal.setModifyUser(admAppraisal.getModifyUser());
                                      entityManager.merge(admAppraisal);
                              }

                              AdmAppraisals admAppraisalsHistory = admAppraisal.clone();
                              admAppraisalsHistory.setParentAdmAppraisals(admAppraisal);
                              admAppraisalsHistory.setHistory(true);
                              entityManager.merge(admAppraisalsHistory);
                              Conversation.instance().end();
                              employeeSalaryReport(employee);
                              return "appraisals";
                      } else
                              return "";

              }

              public boolean validate() {
                      boolean result = true;
                      java.util.ResourceBundle resourceBundle = ResourceBundle.instance();
                      if (this.admAppraisal.getAmount() < 0.0) {
                              String message = resourceBundle
                                              .getString("validationMessage.amount");
                              validationMessage("addappraisalsform", "amountid", "amount",
                                              message);
                              result = false;
                      }
                      return result;
              }

              public void validationMessage(String formId, String decorateId,
                              String fieldId, String errorMessage) {
                      FacesMessage message = new FacesMessage();
                      message.setSeverity(FacesMessage.SEVERITY_ERROR);
                      message.setSummary(errorMessage);
                      message.setDetail(errorMessage);
                      FacesContext.getCurrentInstance().addMessage(
                                      formId + ":" + decorateId + ":" + fieldId, message);
              }

              public List<AdmAppraisals> retrieveAdmAppraisalsHistory(AdmAppraisals adm) {

                      return entityManager
                                      .createQuery(
                                                      "from AdmAppraisals aa where  aa.parentAdmAppraisals = :id and aa.history = 1 ")
                                      .setParameter("id", this.admAppraisal).getResultList();
              }

              public List<AdmAppraisals> historyOfAdmAppraisals(
                              AdmAppraisals admAppraisals) {
                      this.apprailsHistory = this.retrieveAdmAppraisalsHistory(admAppraisals);
                      return this.apprailsHistory;
              }

              @In(required = false, scope = ScopeType.PAGE)
              @Out(required = false, scope = ScopeType.PAGE)
              private List<AdmAppraisals> admAppraisalsHistory;

              public List<AdmAppraisals> getAdmAppraisalsHistory() {
                      return admAppraisalsHistory;
              }

              public void setAdmAppraisalsHistory(List<AdmAppraisals> admAppraisalsHistory) {
                      this.admAppraisalsHistory = admAppraisalsHistory;
              }

              public List<AdmAppraisals> retrieveAppraisals() {
                      return entityManager.createQuery(
                                      "from AdmAppraisals  aa where aa.history= 0 ").getResultList();
              }

              public List<AdmEmployees> retrieveEmployees() {
                      return entityManager.createQuery(
                                      "from AdmEmployees ab where ab.active = 1 ").getResultList();
              }

              @Begin(join = true)
              public String editAdmAppraisals(AdmAppraisals admAppraisals) {
                      this.admAppraisal = admAppraisals;
                      this.admAppraisal = admAppraisal.createClone();
                      return "add_appraisal";
              }

              public String cancel() {
                      return "appraisals";
              }

              @Begin(join = true, flushMode = FlushModeType.MANUAL)
              public String addAppraisals(AdmEmployees empl) {
                      this.employee = empl;
                      attendance.setEmployees(empl);
                      this.admAppraisal = new AdmAppraisals();
                      return "add_appraisal";
              }
              @Begin(join=true)
              public String employeeSalaryEdit(AdmEmployeeSalary sal){
                      this.admSal=sal.createClone();
                      return "edit-salary-details";
                     
              }
       
        

      please help me out from this problem !!!!!!!!!!
        • 1. Re: getting Could not instantiate Seam component
          Tim Evers Master

          You should not put a constructor on a Seam bean.


          Remove this constructor from the bean.


          public AdmAppraisalsAction(EntityManager entityManager){
              this.entityManager=entityManager;
          }
          



          Seam beans should NEVER be instantiated with the new operator.


          eg. NEVER DO THIS


          AdmAppraisalsAction action = new AdmAppraisalsAction(entityManager);
          



          If you want to create a Seam bean there are a number of ways of doing this.


          @In(create=true, value="admAppraisalsAction", required="true")
          AdmAppraisalsAction action;
          



          OR


          Component.getInstance("admAppraisalsAction", true);
          



          There are other ways but this is a start. The key here is that you MUST let Seam create the instance. And Seam needs a default (no parameters) constructor on the Seam Bean. Then rely on your @In to get your entity manager.