An error occurred while performing resource injection on the state managed bean

Asked

Viewed 283 times

-1

When I try to run java, this error occurs.

I’ll send the code.

MODEL:

package com.pi.drogaria.model;

import javax.persistence.Column;
import javax.persistence.Entity;

@SuppressWarnings("serial")
@Entity
public class Estado extends Codigo{

    @Column(length = 2, nullable = false)
    private String sigla;

    @Column(length = 50, nullable = false)
    private String nome;

    public String getSigla() {
        return sigla;
    }

    public void setSigla(String sigla) {
        this.sigla = sigla;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }
}

CONTROLLER:

package com.pi.drogaria.controller;

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;

import org.omnifaces.util.Messages;

import com.pi.drogaria.DAO.EstadoDAO;
import com.pi.drogaria.model.Estado;

@SuppressWarnings("serial")
@ManagedBean
@ViewScoped
public class EstadoController implements Serializable {
    private Estado estado;
    private List<Estado> estados;

    public Estado getEstado() {
        return estado;
    }

    public void setEstado(Estado estado) {
        this.estado = estado;
    }

    public List<Estado> getEstados() {
        return estados;
    }

    public void setEstados(List<Estado> estados) {
        this.estados = estados;
    }

    @PostConstruct
    public void listar() {
        try {
            EstadoDAO estadoDAO = new EstadoDAO();
            estados = estadoDAO.listar();
        } catch (RuntimeException erro) {
            Messages.addGlobalError("Erro ao listar estados.");
            erro.printStackTrace();
        }
    }

    public void novo() {
        estado = new Estado();
            estados = new ArrayList<>();
    }

    public void salvar() {
        try {
            EstadoDAO estadoDAO = new EstadoDAO();
            estadoDAO.merge(estado);
            novo();
            estados = estadoDAO.listar();
            Messages.addGlobalInfo("Estado salvo com sucesso.");
        } catch (RuntimeException erro) {
            Messages.addGlobalError("Erro ao salvar estado.");
            erro.printStackTrace();
        }
    }

    public void excluir(ActionEvent evento) {
        try {
            estado = (Estado) evento.getComponent().getAttributes().get("estadoSelecionado");
            EstadoDAO estadoDAO = new EstadoDAO();
            estadoDAO.excluir(estado);
            estados = estadoDAO.listar();
            Messages.addGlobalInfo("Estado removido com sucesso");
        } catch (RuntimeException erro) {
            Messages.addGlobalError("Ocorreu erro ao tentar remover");
            erro.printStackTrace();
        }
    }

    public void editar(ActionEvent evento){
        estado = (Estado) evento.getComponent().getAttributes().get("estadoSelecionado");
    }
}

VIEW:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:p="http://primefaces.org/ui">

<h:head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>Estados</title>
</h:head>

<h:body>

  <p:growl id="mensagem" />

  <h:form id="formListagem">

    <p:panel header="Estados - Listagem">
      <p:dataTable id="tabela" emptyMessage="Nenhum registro encontrado." paginator="true" value="#{EstadoController.estados}" var="estado" rows="5">
        <f:facet name="header">
          <p:commandButton value="Novo" oncomplete="PF('dialogo').show();" actionListener="#{EstadoController.novo}" update=":formCadastro:painel" />
        </f:facet>

        <p:column headerText="Nome" filterBy="#{estado.nome}">
          <h:outputText value="#{estado.nome}" />
        </p:column>

        <p:column headerText="Sigla" filterBy="#{estado.sigla}">
          <h:outputText value="#{estado.sigla}" />
        </p:column>

        <p:column headerText="Opções">
          <p:commandButton icon="ui-icon-trash" actionListener="#{EstadoController.excluir}" update=":mensagem :formListagem:tabela">
            <p:confirm header="Confirmação" message="Deseja excluir o estado?" icon="ui-icon-alert" />
            <f:attribute name="estadoSelecionado" value="#{estado}" />
          </p:commandButton>

          <p:commandButton icon="ui-icon-pencil" actionListener="#{EstadoController.editar}" update=":formCadastro:painel" oncomplete="PF('dialogo').show();">
            <f:attribute name="estadoSelecionado" value="#{estado}" />
          </p:commandButton>

        </p:column>

      </p:dataTable>

      <p:confirmDialog global="true">
        <p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
        <p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
      </p:confirmDialog>

    </p:panel>
  </h:form>

  <p:dialog header="Estados - Cadastro" widgetVar="dialogo" draggable="false" resizable="false" modal="true" closable="false">
    <h:form id="formCadastro">

      <h:panelGrid id="painel" columns="2">
        <p:outputLabel value="Nome:" />
        <p:inputText maxlength="50" size="30" value="#{EstadoController.estado.nome}" />

        <p:outputLabel value="Sigla:" />
        <p:inputText maxlength="2" size="10" value="#{EstadoController.estado.sigla}" />
      </h:panelGrid>

      <h:panelGrid columns="2">

        <p:commandButton value="Salvar" actionListener="#{EstadoController.salvar}" update=":mensagem :formCadastro:painel :formListagem:tabela" />
        <p:commandButton value="Fechar" oncomplete="PF('dialogo').hide();" />

      </h:panelGrid>
    </h:form>
  </p:dialog>
</h:body>

</html>

ERROR:

  com.sun.faces.mgbean.ManagedBeanCreationException: Um erro ocorreu ao realizar a injeção de recurso no bean gerenciado estadoController
    at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:227)
    at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:103)
    at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
    at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
    at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:257)
    at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:117)
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
    at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:94)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:137)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190)
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
    at javax.faces.component.UIData.getValue(UIData.java:732)
    at org.primefaces.component.api.UIData.getDataModel(UIData.java:764)
    at javax.faces.component.UIData.getRowCount(UIData.java:356)
    at org.primefaces.component.api.UIData.calculateFirst(UIData.java:215)
    at org.primefaces.component.datatable.DataTableRenderer.preRender(DataTableRenderer.java:186)
    at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:90)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:89)
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:72)
    at org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:206)
    at org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:123)
    at org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:58)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:890)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1152)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: com.sun.faces.spi.InjectionProviderException
    at com.sun.faces.vendor.WebContainerInjectionProvider.invokeAnnotatedMethod(WebContainerInjectionProvider.java:115)
    at com.sun.faces.vendor.WebContainerInjectionProvider.invokePostConstruct(WebContainerInjectionProvider.java:95)
    at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:221)
    ... 60 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.faces.vendor.WebContainerInjectionProvider.invokeAnnotatedMethod(WebContainerInjectionProvider.java:113)
    ... 62 more
Caused by: java.lang.ExceptionInInitializerError
    at com.pi.drogaria.util.HibernateUtil.criarFabricaDeSessoes(HibernateUtil.java:24)
    at com.pi.drogaria.util.HibernateUtil.<clinit>(HibernateUtil.java:9)
    at com.pi.drogaria.DAO.DAOGenerico.listar(DAOGenerico.java:41)
    at com.pi.drogaria.controller.estadoController.listar(estadoController.java:43)
    ... 67 more
Caused by: org.hibernate.HibernateException: Error accessing stax stream
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:107)
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65)
    at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57)
    at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:163)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:258)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:244)
    at com.pi.drogaria.util.HibernateUtil.criarFabricaDeSessoes(HibernateUtil.java:17)
    ... 70 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[29,36]
Message: Fim prematuro do arquivo.
    at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source)
    at com.sun.xml.internal.stream.XMLEventReaderImpl.peek(Unknown Source)
    at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:103)
    ... 76 more

CODE CLASS:

package com.pi.drogaria.model;

import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

    @SuppressWarnings("serial")
    @MappedSuperclass
    public class Codigo implements Serializable {

        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long codigo;

        public Long getCodigo() {
            return codigo;
        }

        public void setCodigo(Long codigo) {
            this.codigo = codigo;
        }

        public String ToString() {
            return String.format("%s[codigo=%d]", getClass().getSimpleName(), getCodigo());
        }

    }

HIBERNATE UTIL:

public class HibernateUtil {
private static SessionFactory fabricaDeSessoes = criarFabricaDeSessoes();

public static SessionFactory getFabricaDeSessoes() {
    return fabricaDeSessoes;
}

private static SessionFactory criarFabricaDeSessoes() {
    try {
        StandardServiceRegistry standardRegistry = 
                new StandardServiceRegistryBuilder().configure("hibernate.cfg.xml").build();
        Metadata metaData = 
                new MetadataSources(standardRegistry).getMetadataBuilder().build();
        fabricaDeSessoes = metaData.getSessionFactoryBuilder().build();
    } catch (Throwable th) {
        System.err.println("A fábrica de sessões não pode ser criada." + th);
        throw new ExceptionInInitializerError(th);
    }
    return fabricaDeSessoes;
}

HIBERNATE.CFG.XML:

<hibernate-configuration>

<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/postgres</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">12345</property>

<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<property name="format_sql">false</property>

<mapping class="com.pi.drogaria.model.Cidade"/>
<mapping class="com.pi.drogaria.model.Cliente"/>
<mapping class="com.pi.drogaria.model.Estado"/>
<mapping class="com.pi.drogaria.model.Fabricante"/>
<mapping class="com.pi.drogaria.model.Funcionario"/>
<mapping class="com.pi.drogaria.model.ItemVenda"/>
<mapping class="com.pi.drogaria.model.Pessoa"/>
<mapping class="com.pi.drogaria.model.Produto"/>
<mapping class="com.pi.drogaria.model.Usuario"/>
<mapping class="com.pi.drogaria.model.Venda"/>

ERROR TRYING TO SAVE A STATE:

    ago 17, 2018 9:26:16 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
ADVERTÊNCIA: /pages/estados.xhtml @75,48 value="#{EstadoController.estado.nome}": Target Unreachable, identifier 'EstadoController' resolved to null
javax.el.PropertyNotFoundException: /pages/estados.xhtml @75,48 value="#{EstadoController.estado.nome}": Target Unreachable, identifier 'EstadoController' resolved to null
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
    at org.primefaces.util.ComponentUtils.getConverter(ComponentUtils.java:146)
    at org.primefaces.renderkit.InputRenderer.getConvertedValue(InputRenderer.java:176)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1045)
    at javax.faces.component.UIInput.validate(UIInput.java:975)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1248)
    at javax.faces.component.UIInput.processValidators(UIInput.java:712)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at javax.faces.component.UIForm.processValidators(UIForm.java:253)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at org.primefaces.component.dialog.Dialog.processValidators(Dialog.java:424)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1152)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'EstadoController' resolved to null
    at org.apache.el.parser.AstValue.getTarget(AstValue.java:74)
    at org.apache.el.parser.AstValue.getType(AstValue.java:58)
    at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:174)
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
    ... 38 more

ago 17, 2018 9:26:16 PM com.sun.faces.context.AjaxExceptionHandlerImpl handlePartialResponseError
GRAVE: javax.el.PropertyNotFoundException: /pages/estados.xhtml @75,48 value="#{EstadoController.estado.nome}": Target Unreachable, identifier 'EstadoController' resolved to null
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
    at org.primefaces.util.ComponentUtils.getConverter(ComponentUtils.java:146)
    at org.primefaces.renderkit.InputRenderer.getConvertedValue(InputRenderer.java:176)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1045)
    at javax.faces.component.UIInput.validate(UIInput.java:975)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1248)
    at javax.faces.component.UIInput.processValidators(UIInput.java:712)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at javax.faces.component.UIForm.processValidators(UIForm.java:253)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at org.primefaces.component.dialog.Dialog.processValidators(Dialog.java:424)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1152)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'EstadoController' resolved to null
    at org.apache.el.parser.AstValue.getTarget(AstValue.java:74)
    at org.apache.el.parser.AstValue.getType(AstValue.java:58)
    at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:174)
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
    ... 38 more
  • 1

    Is that all the stacktrace you got or just a cut? The failure to create the bean is probably just a symptom of another error that occurred before the attempt to create it.

  • You have twice placed the state class Control, put the code class

  • I’m sorry, I messed up, I corrected, now you’re with the view.

  • The other error is hibernateUtil, but I think it’s a problem that my postgresql does not want to catch and I will wait for my teacher to correct this error, so I can use the eclipse with postgresql, then I removed the end of what informed the hibernateUtil error, however, if you still want to, I can send the ending to view the stacktrace in full.

  • Puts your Code class too

  • I put the Code class

  • 2

    Implements the equals and hashcode methods in the Code class. But because of this error: Caused by: javax.xml.stream.Xmlstreamexception: Parseerror at [Row,col]:[29,36] I believe one of your problems is in configuring your xml

  • @Lucas Stays as a hint: whenever you have a stacktrace of errors, never take any part of it, always inform it fully. The origin of the errors in a stacktrace goes from bottom to top, so if you take a part, you prevent the real reason for the problem from being visualized, ok?

  • Edjane, in which case would it be web.xml? I put the equals and hashcode in the Code, it’s funny this error appears now, I formatted the notebook, when I installed eclipse and put the jboss and Tomcat and put the folder of my project, it came with this error, before it picked normally, without this error, now comes with this error.

  • 1

    Statelessdev, ok, understood, excludes because he didn’t think it was necessary because he was talking about Hibernateutil and the question of doubt was just the error out of that, because he knew that my session factory or something related to postgresql would not take to save in the bank, that I was going to settle with my teacher next week... but anyway... it was put, it was wrong there!

  • Post the code of your method com.pi.drogaria.util.HibernateUtil.criarFabricaDeSessoes(...) and your Hibernate XML as well.

  • Added. I only have this BEAN injection problem with controller. However it’s all correct, I don’t know why it doesn’t show the screen.

  • Hello Lucas, first the name of your file is like this? HIBERNET.CFG.XML I don’t think so, because he’s giving the location of the error [Row,col]:[29,36], goes in your file Hibernate.cfg.xml check if the class declared in line 29 is according to the class of your project, anything comments on line 29 and see the result.

  • Hi, Edjane, I just misspelled here, but in the project itself, I was correct HIBERNATE.CFG.XML, I just misspelled, but I edited to put right name, but I’ve really looked through everything, and I can’t find any solution, I’ve already deleted 4 eclipse and put others to see if the problem is in the eclipse, but I don’t think so, it might be JSF, but if that’s where I don’t know how to fix to get this one to work, "Bean injection".

  • What’s on line 29 of your xml Hibernate.cfg.?

  • @Edjane closing the tag </Hibernate-Configuration>

  • I checked that in your stateController you do not initialize your data, so as it will get big here, I will put as a response what I think can help you. But I find it strange because you said that this project ran before formatting the computer.

Show 12 more comments

1 answer

1


Try to do it this way:

  1. in your class state start a class name always in capital letters;
  2. initialize its state and state variables, you can do this in the constructor method because it will always be executed when an object of this class is instantiated, follow an example of how you can do this:

I saw that you created a method called new() that you use to clear the data in the form, right?

public void novo() {
  estado = new Estado();
  estados = new ArrayList<>(); //adicione essa linha para limpar a lista de estados
}

Creates a constructor method in your State class

//Aqui, seguindo a padronização, já considerei a classe iniciada com letra maiuscula
public EstadoController(){
  //chama o método novo
  novo();
}

Make these changes and tell the result, because as you said you formatted the computer and that before it worked might have other problems.

  • I was able to resolve somehow, I think by changing to start with capital letter ... Only now he doesn’t want to save... from the error in a line in xhtml with the controller... I’ve redone everything and continued with this error... I’ll post the new error, if I know what might be wrong, I’m grateful. Thanks for your help so far!

  • I saw the new error, when you call your bean object on the JSF page, you are calling it so: #{Estadocontroller.estado.name} by default the class starts with uppercase letter but the bean call on the JSF page starts with lowercase letter #{stateController.estado.name}

  • I saw it, I fixed it, but unfortunately my project or my computer, I don’t know... has returned to give problem with injection of refuse Bean, it’s really discouraging me, the project pick up when you want? Ai does it all without testing to see if getting it right, when it arrives on the day of the presentation of the project it does not open... complicated arise a problem with no solution at all... really gets left without knowing what to do, picked up last night, this morning back the problem of Bean’s injection, pick up when you want.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.