JSF Erro de validação somente quando há relacionamento

10 respostas Resolvido
jsfjava
A

Bom dia.
Tenho uma tabela “Movimentacao” (representando cada movimentação de viaturas do dia como abastecimento, manutenção de demais) com vários campos, entre eles “Motorista, Encarregado, Aux1 e Aux2” esta tabela possui um relacionamento @OneToOne com “Funcionario”, em alguns casos os quatro campos citados precisarão estar preenchidos com funcionais diferentes.
A tabela “Funcionario” por sua vez está relacionada de forma @OneToOne com “usuarioLogin”.

Estou tendo o seguinte problema, quando cadastro um registro na tabela “Movimentacao” e o “Funcionario” não possui relacionamento com “UsuarioLogin” o cadastro é efetuado, porém quando há tal relacionamento recebo um erro de validação “Motorista: Erro de validação: o valor não é válido”.

Nunca passei por esta situação. Alguém poderia me ajudar a resolver isso?

Agradeço toda e qualquer ajuda.

OBS: As 3 classes possuem converter, postei as classes Model abaixo.

@Entity@Table(name = "movimentacaovtr")
public class MovimentacaoVTR implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private CodigoOcorrencia codigoOcorrencia;
private Funcionario motorista;
private Funcionario encarregado;
private Funcionario aux1;
private Funcionario aux2;

private Bairro bairro;
private Date data;
private Long bon;
private Date horaIni;
private Date horaFin;
private String complemento;
private String endereco;
private double litragem;

@Id
@GeneratedValue
public Long getId() {
	return id;
}

@ManyToOne(optional = true)
@JoinColumn(name = "codigoocorrencia_id", referencedColumnName = "id")
public CodigoOcorrencia getCodigoOcorrencia() {
	return codigoOcorrencia;
}

@ManyToOne(optional = true)
@JoinColumn(name = "bairro_id", referencedColumnName = "id")
public Bairro getBairro() {
	return bairro;
}

@ManyToOne(optional = true)
@JoinColumn(name = "motorista_id", referencedColumnName = "id")
public Funcionario getMotorista() {
	return motorista;
}

@ManyToOne(optional = true)
@JoinColumn(name = "encarregado_id", referencedColumnName = "id")
public Funcionario getEncarregado() {
	return encarregado;
}

@ManyToOne(optional = true)
@JoinColumn(name = "aux1_id", referencedColumnName = "id")
public Funcionario getAux1() {
	return aux1;
}

@ManyToOne(optional = true)
@JoinColumn(name = "aux2_id", referencedColumnName = "id")
public Funcionario getAux2() {
	return aux2;
}

@NotNull
@Temporal(TemporalType.DATE)
@Column(name = "data", nullable = false)
public Date getData() {
	return data;
}

public Long getBon() {
	return bon;
}

@NotNull
@Temporal(TemporalType.TIME)
public Date getHoraIni() {
	return horaIni;
}

@Temporal(TemporalType.TIME)
public Date getHoraFin() {
	return horaFin;
}

@Size(max = 150)
@Column(length = 80, nullable = false)
public String getComplemento() {
	return complemento;
}

@Size(max = 80)
@Column(length = 80, nullable = false)
public String getEndereco() {
	return endereco;
}


public double getLitragem() {
	return litragem;
}

// setters, hashCode e equals

}

Classe Funcionario

@Entity
@Table(name = "funcionario")
public class Funcionario implements Serializable {
private static final long serialVersionUID = 1L;


private Profissao profissao;	

private FuncionarioSituacao funcionarioSituacao;	

private NivelAutoridade nivelAutoridade;

private UsuarioLogin usuarioLogin;


private Long id;

private String nome;

private String funcao;

private String nomeGuerra;

private String cpf;


@Id
@GeneratedValue
@SequenceGenerator(name="seq8", initialValue=1, allocationSize=100)
public Long getId() {
	return id;
}

public void setId(Long id) {
	this.id = id;
}

@NotNull
@ManyToOne(optional = false)
@JoinColumn(name = "profissao_id", referencedColumnName = "id")
public Profissao getProfissao() {
	return profissao;
}

public void setProfissao(Profissao profissao) {
	this.profissao = profissao;
}

@NotNull
@ManyToOne(optional = false)
@JoinColumn(name = "FuncionarioSituacao_id", referencedColumnName = "id")
public FuncionarioSituacao getFuncionarioSituacao() {
	return funcionarioSituacao;
}

public void setFuncionarioSituacao(FuncionarioSituacao funcionarioSituacao) {
	this.funcionarioSituacao = funcionarioSituacao;
}

//@NotNull
@ManyToOne//(optional = false)
@JoinColumn(name = "NivelAutoridade_id", referencedColumnName = "id")
public NivelAutoridade getNivelAutoridade() {
	return nivelAutoridade;
}

public void setNivelAutoridade(NivelAutoridade nivelAutoridade) {
	this.nivelAutoridade = nivelAutoridade;
}

@OneToOne(cascade = CascadeType.ALL, optional=true)
@JoinColumn(name = "UsuarioLogin_id", referencedColumnName = "id")
public UsuarioLogin getUsuarioLogin() {
	return usuarioLogin;
}

public void setUsuarioLogin(UsuarioLogin usuarioLogin) {
	this.usuarioLogin = usuarioLogin;
}	

public String getNome() {
	return nome;
}

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

public String getFuncao() {
	return funcao;
}

public void setFuncao(String funcao) {
	this.funcao = funcao;
}



public String getNomeGuerra() {
	return nomeGuerra;
}

public void setNomeGuerra(String nomeGuerra) {
	this.nomeGuerra = nomeGuerra;
}

public String getCpf() {
	return cpf;
}

public void setCpf(String cpf) {
	this.cpf = cpf;
}

//HashCode e Equals

}

Classe UsuarioLogin

@Entity

@Table(name = USUARIOLOGIN)

public class UsuarioLogin implements Serializable {

private static final long serialVersionUID = 1L;
private Long id;

private String username;

private String password;

private boolean enable;

private List<NivelAutoridade> niveisAutoridade;

// getters e setters    
@Id
@GeneratedValue
@SequenceGenerator(name="seq7", initialValue=1, allocationSize=100)
public Long getId() {
	return id;
}

public void setId(Long id) {
	this.id = id;
}

public String getUsername() {
	return username;
}

public void setUsername(String username) {
	this.username = username;
}

public String getPassword() {
	return password;
}

public void setPassword(String password) {
	this.password = password;
}

public boolean isEnable() {
	return enable;
}

public void setEnable(boolean enable) {
	this.enable = enable;
}

@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "USULOG_NIVAUT", joinColumns = @JoinColumn(name = "USU_id"), inverseJoinColumns = @JoinColumn(name = "NIVAUT_id"))
public List<NivelAutoridade> getNiveisAutoridade() {
	return niveisAutoridade;
}

public void setNiveisAutoridade(List<NivelAutoridade> niveisAutoridade) {
	this.niveisAutoridade = niveisAutoridade;
}

//Equals e HashCode

}

10 Respostas

M

Posta a página de cadastro também.
Se tiver um validator, posta o validator também
Eu diria que o campo espera receber um Motorista, mas esta sendo passado outro valor…

A

Boa tarde Mike, obrigado por responder.

Só reforçando que a eu consigo cadastrar normalmente uma movimentacao, o problema ocorre quando um registro da classe funcionario (motorista, encarregado, aux1 ou aux2) está relacionado com algum registro da classe “UsuarioLogin.java”.

Estou postando abaixo a classe “CadastroMovimentacaoBean.java”:

@Named
@javax.faces.view.ViewScoped
public class CadastroMovimentacaoBean implements Serializable {
private static final long serialVersionUID = 1L;

@Inject
private CadastroMovimentacaoVTR cadastro;

@Inject
private CodigosOcorrencia codigosOcorrencia;
private List<CodigoOcorrencia> todosCodigosOcorrencia;

@Inject
private Bairros bairros;
private List<Bairro> todosBairros;

@Inject
private Funcionarios funcionarios;
private List<Funcionario> todosFuncionarios;

private MovimentacaoVTR movimentacaoVTR = new MovimentacaoVTR();

private String tab;

public void descricaoModificada(ValueChangeEvent event) {
	System.out.println("Valor antigo: " + event.getOldValue());
	System.out.println("Novo valor: " + event.getNewValue());
	FacesContext.getCurrentInstance().renderResponse();
}

public void prepararCadastro() {
	this.todosCodigosOcorrencia = this.codigosOcorrencia.todos();
	this.todosBairros = this.bairros.todos();
	this.todosFuncionarios = this.funcionarios.ativos();
	
	if (this.movimentacaoVTR == null) {
		this.movimentacaoVTR = new MovimentacaoVTR();
	}
}

public String salvar() {
	FacesContext context = FacesContext.getCurrentInstance();
	try {
		this.cadastro.salvar(this.movimentacaoVTR);
		this.movimentacaoVTR = new MovimentacaoVTR();
		context.addMessage(null, new FacesMessage("Contato salvo com sucesso!"));
	} catch (NegocioException e) {
		FacesMessage mensagem = new FacesMessage(e.getMessage());
		mensagem.setSeverity(FacesMessage.SEVERITY_ERROR);
		context.addMessage(null, mensagem);
	}
	return "/CadastroMovimentacao?faces-redirect=true";
}

public String getTab(){
	return tab;
}

public void setTab(String tab) {
	this.tab = tab;
}

public MovimentacaoVTR getMovimentacaoVTR() {
	return movimentacaoVTR;
}

public void setMovimentacaoVTR(MovimentacaoVTR movimentacaoVTR) {
	this.movimentacaoVTR = movimentacaoVTR;
}

public List<CodigoOcorrencia> getTodosCodigosOcorrencia() {
	return todosCodigosOcorrencia;
}

public void setTodosCodigosOcorrencia(List<CodigoOcorrencia> todosCodigosOcorrencia) {
	this.todosCodigosOcorrencia = todosCodigosOcorrencia;
}

public CodigosOcorrencia getCodigosOcorrencia() {
	return codigosOcorrencia;
}

public void setCodigosOcorrencia(CodigosOcorrencia codigosOcorrencia) {
	this.codigosOcorrencia = codigosOcorrencia;
}

public Bairros getBairros() {
	return bairros;
}

public void setBairros(Bairros bairros) {
	this.bairros = bairros;
}

public List<Bairro> getTodosBairros() {
	return todosBairros;
}

public void setTodosBairros(List<Bairro> todosBairros) {
	this.todosBairros = todosBairros;
}

public List<Funcionario> getTodosFuncionarios() {
	return todosFuncionarios;
}

public void setTodosFuncionarios(List<Funcionario> todosFuncionarios) {
	this.todosFuncionarios = todosFuncionarios;
}

}

D

Posta o stack completo.

A

Obrigado darlan_machado por ajudar.

Segue a saída:

jul 31, 2018 1:57:56 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property source to org.eclipse.jst.jee.server:Sigcm did not find a matching property.

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: Server version:        Apache Tomcat/9.0.10

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: Server built:          Jun 20 2018 17:32:21 UTC

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: Server number:         9.0.10.0

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: OS Name:               Windows 7

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: OS Version:            6.1

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: Architecture:          x86

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: Java Home:             C:\Program Files\Java\jre1.8.0_91

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: JVM Version:           1.8.0_91-b14

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: JVM Vendor:            Oracle Corporation

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: CATALINA_BASE:         C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: CATALINA_HOME:         C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: Command line argument: -Dcatalina.base=C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: Command line argument: -Dcatalina.home=C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: Command line argument: -Dwtp.deploy=C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\wtpwebapps

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\endorsed

jul 31, 2018 1:57:56 PM org.apache.catalina.startup.VersionLoggerListener log

INFORMAÇÕES: Command line argument: -Dfile.encoding=Cp1252

jul 31, 2018 1:57:56 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent

INFORMAÇÕES: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_91\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_91/bin/client;C:/Program Files/Java/jre1.8.0_91/bin;C:/Program Files/Java/jre1.8.0_91/lib/i386;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5;C:\Program Files\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP;C:\Users\user\Desktop\Desenvolvimento\eclipse;;.]

jul 31, 2018 1:57:58 PM org.apache.coyote.AbstractProtocol init

INFORMAÇÕES: Initializing ProtocolHandler [http-nio-8080]

jul 31, 2018 1:57:58 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

INFORMAÇÕES: Using a shared selector for servlet write/read

jul 31, 2018 1:57:58 PM org.apache.coyote.AbstractProtocol init

INFORMAÇÕES: Initializing ProtocolHandler [ajp-nio-8009]

jul 31, 2018 1:57:58 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

INFORMAÇÕES: Using a shared selector for servlet write/read

jul 31, 2018 1:57:58 PM org.apache.catalina.startup.Catalina load

INFORMAÇÕES: Initialization processed in 6624 ms

jul 31, 2018 1:57:59 PM org.apache.catalina.core.StandardService startInternal

INFORMAÇÕES: Starting service [Catalina]

jul 31, 2018 1:57:59 PM org.apache.catalina.core.StandardEngine startInternal

INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/9.0.10

jul 31, 2018 1:58:26 PM org.apache.jasper.servlet.TldScanner scanJars

INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

jul 31, 2018 1:58:26 PM org.apache.catalina.core.ApplicationContext log

INFORMAÇÕES: No Spring WebApplicationInitializer types detected on classpath

jul 31, 2018 1:58:26 PM org.jboss.weld.environment.servlet.EnhancedListener onStartup

INFO: WELD-ENV-001008: Initialize Weld using ServletContainerInitializer

jul 31, 2018 1:58:26 PM org.jboss.weld.bootstrap.WeldStartup 

INFO: WELD-000900: 2.4.6 (Final)

jul 31, 2018 1:58:27 PM org.jboss.weld.environment.deployment.discovery.DiscoveryStrategyFactory create

INFO: WELD-ENV-000020: Using jandex for bean discovery

jul 31, 2018 1:58:28 PM org.jboss.weld.bootstrap.WeldStartup startContainer

INFO: WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.

jul 31, 2018 1:58:29 PM org.jboss.weld.bootstrap.MissingDependenciesRegistry handleResourceLoadingException

INFO: WELD-000119: Not generating any bean definitions from org.omnifaces.cdi.param.ParamProducer because of underlying class loading error: Type javax.validation.ConstraintViolation not found.  If this is unexpected, enable DEBUG logging to see the full error.

jul 31, 2018 1:58:29 PM org.jboss.weld.environment.tomcat.TomcatContainer initialize

INFO: WELD-ENV-001100: Tomcat 7+ detected, CDI injection will be available in Servlets, Filters and Listeners.

jul 31, 2018 1:58:31 PM org.omnifaces.ApplicationInitializer logOmniFacesVersion

INFORMAÇÕES: Using OmniFaces version 2.6.8

jul 31, 2018 1:58:31 PM com.sun.faces.config.ConfigureListener contextInitialized

INFORMAÇÕES: Inicializando Mojarra 2.2.13 ( 20160203-1910 unable to get svn info) para o contexto '/Sigcm

jul 31, 2018 1:58:31 PM com.sun.faces.spi.InjectionProviderFactory createInstance

INFORMAÇÕES: JSF1048: Anotações PostConstruct/PreDestroy presentes.  Os métodos ManagedBeans marcados com essas anotações informarão as anotações processadas.

jul 31, 2018 1:58:34 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent

INFORMAÇÕES: Running on PrimeFaces 6.2

jul 31, 2018 1:58:34 PM org.primefaces.extensions.application.PostConstructApplicationEventListener processEvent

INFORMAÇÕES: Running on PrimeFaces Extensions 6.2

jul 31, 2018 1:58:34 PM org.jboss.weld.environment.servlet.Listener contextInitialized

INFO: WELD-ENV-001006: org.jboss.weld.environment.servlet.EnhancedListener used to initialize Weld

jul 31, 2018 1:58:34 PM org.apache.catalina.core.ApplicationContext log

INFORMAÇÕES: Initializing Spring root WebApplicationContext

jul 31, 2018 1:58:34 PM org.springframework.web.context.ContextLoader initWebApplicationContext

INFORMAÇÕES: Root WebApplicationContext: initialization started

jul 31, 2018 1:58:34 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh

INFORMAÇÕES: Refreshing Root WebApplicationContext: startup date [Tue Jul 31 13:58:34 BRT 2018]; root of context hierarchy

jul 31, 2018 1:58:34 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions

INFORMAÇÕES: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]

jul 31, 2018 1:58:35 PM org.springframework.security.core.SpringSecurityCoreVersion performVersionChecks

INFORMAÇÕES: You are running with Spring Security Core 3.2.3.RELEASE

jul 31, 2018 1:58:35 PM org.springframework.security.core.SpringSecurityCoreVersion performVersionChecks

ADVERTÊNCIA: **** You are advised to use Spring 3.2.8.RELEASE or later with this version. You are running: 3.2.1.RELEASE

jul 31, 2018 1:58:35 PM org.springframework.security.config.SecurityNamespaceHandler 

INFORMAÇÕES: Spring Security config module version is 3.2.3.RELEASE

jul 31, 2018 1:58:35 PM org.springframework.security.config.http.HttpSecurityBeanDefinitionParser checkFilterChainOrder

INFORMAÇÕES: Checking sorted filter chain: [Root bean: class [org.springframework.security.web.context.SecurityContextPersistenceFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 200, Root bean: class [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 400, Root bean: class [org.springframework.security.web.authentication.logout.LogoutFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 700, <org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0>, order = 1100, Root bean: class [org.springframework.security.web.authentication.www.BasicAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1500, Root bean: class [org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1600, Root bean: class [org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1700, Root bean: class [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2000, Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2100, Root bean: class [org.springframework.security.web.access.ExceptionTranslationFilter]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2200, <org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0>, order = 2300]

jul 31, 2018 1:58:35 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons

INFORMAÇÕES: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@cd0c3e: defining beans [org.springframework.security.filterChains,org.springframework.security.filterChainProxy,org.springframework.security.web.PortMapperImpl#0,org.springframework.security.web.PortResolverImpl#0,org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0,org.springframework.security.authentication.ProviderManager#0,org.springframework.security.web.context.HttpSessionSecurityContextRepository#0,org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy#0,org.springframework.security.web.savedrequest.HttpSessionRequestCache#0,org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler#0,org.springframework.security.access.vote.AffirmativeBased#0,org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0,org.springframework.security.web.access.DefaultWebInvocationPrivilegeEvaluator#0,org.springframework.security.authentication.AnonymousAuthenticationProvider#0,org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint#0,org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0,org.springframework.security.userDetailsServiceFactory,org.springframework.security.web.DefaultSecurityFilterChain#0,org.springframework.security.provisioning.JdbcUserDetailsManager#0,org.springframework.security.authentication.dao.DaoAuthenticationProvider#0,org.springframework.security.authentication.DefaultAuthenticationEventPublisher#0,org.springframework.security.authenticationManager,dataSource]; root of factory hierarchy

jul 31, 2018 1:58:35 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName

INFORMAÇÕES: Loaded JDBC driver: org.postgresql.Driver

jul 31, 2018 1:58:35 PM org.springframework.security.provisioning.JdbcUserDetailsManager initDao

INFORMAÇÕES: No authentication manager set. Reauthentication of users when changing passwords will not be performed.

jul 31, 2018 1:58:36 PM org.springframework.security.web.DefaultSecurityFilterChain 

INFORMAÇÕES: Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.SecurityContextPersistenceFilter@4de249, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@73a08e, org.springframework.security.web.authentication.logout.LogoutFilter@1f0ffba, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@18365b2, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@df89a1, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@1093764, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@19a1850, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@1e05d64, org.springframework.security.web.session.SessionManagementFilter@1424ab8, org.springframework.security.web.access.ExceptionTranslationFilter@1d4ed23, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@af2b91]

jul 31, 2018 1:58:36 PM org.springframework.security.config.http.DefaultFilterChainValidator checkLoginPageIsntProtected

INFORMAÇÕES: Checking whether login URL /login.xhtml is accessible with your configuration

jul 31, 2018 1:58:36 PM org.springframework.web.context.ContextLoader initWebApplicationContext

INFORMAÇÕES: Root WebApplicationContext: initialization completed in 1640 ms

jul 31, 2018 1:58:36 PM com.sun.faces.config.ConfigureListener contextInitialized

INFORMAÇÕES: Inicializando Mojarra 2.2.13 ( 20160203-1910 unable to get svn info) para o contexto '/Sigcm

jul 31, 2018 1:58:36 PM com.sun.faces.spi.InjectionProviderFactory createInstance

INFORMAÇÕES: JSF1048: Anotações PostConstruct/PreDestroy presentes.  Os métodos ManagedBeans marcados com essas anotações informarão as anotações processadas.

jul 31, 2018 1:58:36 PM com.sun.faces.mgbean.BeanManager addBean

ADVERTÊNCIA: JSF1074: O bean gerenciado denominado startup  foi registrado.  Substituindo o tipo de classe do bean gerenciado java.util.Date por java.util.Date.

jul 31, 2018 1:58:36 PM com.sun.faces.mgbean.BeanManager addBean

ADVERTÊNCIA: JSF1074: O bean gerenciado denominado now  foi registrado.  Substituindo o tipo de classe do bean gerenciado java.util.Date por java.util.Date.

jul 31, 2018 1:58:37 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent

INFORMAÇÕES: Running on PrimeFaces 6.2

jul 31, 2018 1:58:37 PM org.primefaces.extensions.application.PostConstructApplicationEventListener processEvent

INFORMAÇÕES: Running on PrimeFaces Extensions 6.2

jul 31, 2018 1:58:37 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent

INFORMAÇÕES: Running on PrimeFaces 6.2

jul 31, 2018 1:58:37 PM org.primefaces.extensions.application.PostConstructApplicationEventListener processEvent

INFORMAÇÕES: Running on PrimeFaces Extensions 6.2

jul 31, 2018 1:58:37 PM org.jboss.weld.environment.servlet.EnhancedListener contextInitialized

INFO: WELD-ENV-001009: org.jboss.weld.environment.servlet.Listener used for ServletRequest and HttpSession notifications

jul 31, 2018 1:58:37 PM org.apache.catalina.startup.HostConfig deployDirectory

INFORMAÇÕES: Deploying web application directory [C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\webapps\docs]

jul 31, 2018 1:58:40 PM org.apache.jasper.servlet.TldScanner scanJars

INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

jul 31, 2018 1:58:40 PM org.apache.catalina.startup.HostConfig deployDirectory

INFORMAÇÕES: Deployment of web application directory [C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\webapps\docs] has finished in [3,246] ms

jul 31, 2018 1:58:40 PM org.apache.catalina.startup.HostConfig deployDirectory

INFORMAÇÕES: Deploying web application directory [C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\webapps\examples]

jul 31, 2018 1:58:44 PM org.apache.jasper.servlet.TldScanner scanJars

INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

jul 31, 2018 1:58:45 PM org.apache.catalina.core.ApplicationContext log

INFORMAÇÕES: ContextListener: contextInitialized()

jul 31, 2018 1:58:45 PM org.apache.catalina.core.ApplicationContext log

INFORMAÇÕES: SessionListener: contextInitialized()

jul 31, 2018 1:58:45 PM org.apache.catalina.core.ApplicationContext log

INFORMAÇÕES: ContextListener: attributeAdded(StockTicker, async.Stockticker@1de4120)

jul 31, 2018 1:58:45 PM org.apache.catalina.startup.HostConfig deployDirectory

INFORMAÇÕES: Deployment of web application directory [C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\webapps\examples] has finished in [4,687] ms

jul 31, 2018 1:58:45 PM org.apache.catalina.startup.HostConfig deployDirectory

INFORMAÇÕES: Deploying web application directory [C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\webapps\host-manager]

jul 31, 2018 1:58:49 PM org.apache.jasper.servlet.TldScanner scanJars

INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

jul 31, 2018 1:58:49 PM org.apache.catalina.startup.HostConfig deployDirectory

INFORMAÇÕES: Deployment of web application directory [C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\webapps\host-manager] has finished in [4,309] ms

jul 31, 2018 1:58:49 PM org.apache.catalina.startup.HostConfig deployDirectory

INFORMAÇÕES: Deploying web application directory [C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\webapps\manager]

jul 31, 2018 1:58:52 PM org.apache.jasper.servlet.TldScanner scanJars

INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

jul 31, 2018 1:58:52 PM org.apache.catalina.startup.HostConfig deployDirectory

INFORMAÇÕES: Deployment of web application directory [C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\webapps\manager] has finished in [3,461] ms

jul 31, 2018 1:58:52 PM org.apache.catalina.startup.HostConfig deployDirectory

INFORMAÇÕES: Deploying web application directory [C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\webapps\ROOT]

jul 31, 2018 1:58:56 PM org.apache.jasper.servlet.TldScanner scanJars

INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

jul 31, 2018 1:58:56 PM org.apache.catalina.startup.HostConfig deployDirectory

INFORMAÇÕES: Deployment of web application directory [C:\Users\user\Desktop\Desenvolvimento\apache-tomcat-9.0.10\webapps\ROOT] has finished in [3,468] ms

jul 31, 2018 1:58:56 PM org.apache.coyote.AbstractProtocol start

INFORMAÇÕES: Starting ProtocolHandler [http-nio-8080]

jul 31, 2018 1:58:56 PM org.apache.coyote.AbstractProtocol start

INFORMAÇÕES: Starting ProtocolHandler [ajp-nio-8009]

jul 31, 2018 1:58:56 PM org.apache.catalina.startup.Catalina start

INFORMAÇÕES: Server startup in 57544 ms

jul 31, 2018 3:06:52 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation

INFO: HHH000204: Processing PersistenceUnitInfo [

name: AgendaPU

]

jul 31, 2018 3:06:53 PM org.hibernate.Version logVersion

INFO: HHH000412: Hibernate Core {5.2.2.Final}

jul 31, 2018 3:06:53 PM org.hibernate.cfg.Environment 

INFO: HHH000206: hibernate.properties not found

jul 31, 2018 3:06:53 PM org.hibernate.cfg.Environment buildBytecodeProvider

INFO: HHH000021: Bytecode provider name : javassist

jul 31, 2018 3:06:53 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager 

INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}

jul 31, 2018 3:06:55 PM org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator instantiateC3p0Provider

WARN: HHH000022: c3p0 properties were encountered, but the c3p0 provider class was not found on the classpath; these properties are going to be ignored.

jul 31, 2018 3:06:55 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)

jul 31, 2018 3:06:55 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH10001005: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/agenda]

jul 31, 2018 3:06:55 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH10001001: Connection properties: {user=postgres, password=****, shutdown=true}

jul 31, 2018 3:06:55 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator

INFO: HHH10001003: Autocommit mode: false

jul 31, 2018 3:06:55 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections 

INFO: HHH000115: Hibernate connection pool size: 20 (min=1)

jul 31, 2018 3:06:55 PM org.hibernate.dialect.Dialect 

INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect

jul 31, 2018 3:06:56 PM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl useContextualLobCreation

INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException

jul 31, 2018 3:06:56 PM org.hibernate.type.BasicTypeRegistry register

INFO: HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@15457f9

jul 31, 2018 3:07:00 PM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection

INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@56fa0f] for (non-JTA) DDL execution was not in auto-commit mode; the Connection local transaction will be committed and the Connection will be set into auto-commit mode.

jul 31, 2018 3:07:03 PM org.hibernate.hql.internal.QueryTranslatorFactoryInitiator initiateService

INFO: HHH000397: Using ASTQueryTranslatorFactory

jul 31, 2018 3:07:04 PM org.primefaces.component.messages.MessagesRenderer encodeEnd

INFORMAÇÕES: autoUpdate attribute is deprecated and will be removed in a future version, use p:autoUpdate component instead.

jul 31, 2018 3:07:04 PM com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent

ADVERTÊNCIA: Não foi possível encontrar o componente com a ID # na exibição.

jul 31, 2018 3:07:04 PM com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent

ADVERTÊNCIA: Não foi possível encontrar o componente com a ID # na exibição.

jul 31, 2018 3:07:10 PM org.primefaces.component.messages.MessagesRenderer encodeEnd

INFORMAÇÕES: autoUpdate attribute is deprecated and will be removed in a future version, use p:autoUpdate component instead.

jul 31, 2018 3:07:21 PM org.primefaces.component.messages.MessagesRenderer encodeEnd

INFORMAÇÕES: autoUpdate attribute is deprecated and will be removed in a future version, use p:autoUpdate component instead.

jul 31, 2018 3:07:21 PM com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent

ADVERTÊNCIA: Não foi possível encontrar o componente com a ID # na exibição.

jul 31, 2018 3:07:21 PM com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent

ADVERTÊNCIA: Não foi possível encontrar o componente com a ID # na exibição.
D

Cadê o erro no stack?

A

darlan_machado, o Stack não aponta o erro, somente tenho o erro da validação, o que me impede de persistir:

image

D

Você tem algum convertes para esse elemento? Tem como postar o xhtml?

A

Segue o .xhtml e o converter:

<!DOCTYPE html>
<ui:composition template="/WEB-INF/template/Layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">>
<f:metadata>
	<o:viewParam name="id"
		value="#{cadastroMovimentacaoBean.movimentacaoVTR}" />
	<f:viewAction action="#{cadastroMovimentacaoBean.prepararCadastro}" />
</f:metadata>

<ui:define name="titulo">Cadastro Movimentação de Viaturas</ui:define>
<ui:define name="corpo">
	<h1>Cadastro Movimentação de Viaturas</h1>

	<p:megaMenu orientation="#" style="margin-top:20px">
		<p:menuitem value="Listar Talão" url="ConsultaMovimentacao.xhtml"
			icon="ui-icon-pencil" />
		<p:menuitem value="Novo Código de Ocorrência"
			url="CadastroCodigoOcorrencia.xhtml" icon="ui-icon-pencil" />
		<p:menuitem value="Novo Bairro" url="CadastroBairro.xhtml"
			icon="ui-icon-pencil" />
		<p:menuitem value="Novo Funcionario" url="CadastroFuncionario.xhtml"
			icon="ui-icon-pencil" />
	</p:megaMenu>

	<h:form id="frm">
		<p:messages showDetail="false" showSummary="true" autoUpdate="true" />
		<p:panelGrid columns="4">

			<p:outputLabel value="Data:" for="data" />
			<p:calendar id="data" size="12" pattern="dd/MM/yyyy"
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.data}">
				<p:ajax event="dateSelect" update="@this data" process="@this data" />
				<p:ajax event="change" update="@this data" process="@this data" />
			</p:calendar>
			<h:outputLabel value="" for="#" />
			<h:outputLabel value="" for="#" />

			<h:outputLabel value="Hora Inicial: *" for="horaIni" />
			<pe:timePicker id="horaIni"
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.horaIni}"
				mode="popup" widgetVar="popupBtnTimeWidget" showOn="button"
				label="Popup time picker with button" />

			<h:outputLabel value="Hora Final:" for="horaFin" />
			<pe:timePicker id="horaFin"
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.horaFin}"
				mode="popup" widgetVar="popupBtnTimeWidget" showOn="button"
				label="Popup time picker with button" />

			<h:outputLabel value="BO nº:" for="bon"/>
			<p:inputText size="12" id="bon"
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.bon}"
				label="bon">
			</p:inputText>
			<h:outputLabel value="" />
			<h:outputLabel value="" />

			<p:outputLabel value="Motorista:" for="motorista" />
			<p:selectOneMenu
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.motorista}"
				id="motorista">
				<f:selectItem itemLabel="Selecione" itemValue="" />
				<f:selectItems
					value="#{cadastroMovimentacaoBean.todosFuncionarios}"
					var="motorista" itemValue="#{motorista}"
					itemLabel="#{motorista.nome}" />
			</p:selectOneMenu>

			<p:outputLabel value="Encarregado:" for="encarregado" />
			<p:selectOneMenu
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.encarregado}"
				id="encarregado">
				<f:selectItem itemLabel="Selecione" itemValue="" />
				<f:selectItems
					value="#{cadastroMovimentacaoBean.todosFuncionarios}"
					var="encarregado" itemValue="#{encarregado}"
					itemLabel="#{encarregado.nome}" />
			</p:selectOneMenu>

			<p:outputLabel value="Auxiliar 1:" for="auxiliar1" />
			<p:selectOneMenu
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.aux1}"
				id="auxiliar1">
				<f:selectItem itemLabel="Selecione" itemValue="" />
				<f:selectItems
					value="#{cadastroMovimentacaoBean.todosFuncionarios}"
					var="auxiliar1" itemValue="#{auxiliar1}"
					itemLabel="#{auxiliar1.nome}" />
			</p:selectOneMenu>

			<p:outputLabel value="Auxiliar 2:" for="auxiliar2" />
			<p:selectOneMenu
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.aux2}"
				id="auxiliar2">
				<f:selectItem itemLabel="Selecione" itemValue="" />
				<f:selectItems
					value="#{cadastroMovimentacaoBean.todosFuncionarios}"
					var="auxiliar2" itemValue="#{auxiliar2}"
					itemLabel="#{auxiliar2.nome}" />
			</p:selectOneMenu>

			<p:outputLabel value="Codigo de Ocorrência:" for="codigoOcorrencia" />
			<p:selectOneMenu
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.codigoOcorrencia}"
				id="codigoOcorrencia">
				<f:selectItem itemLabel="Selecione" itemValue="" />
				<f:selectItems
					value="#{cadastroMovimentacaoBean.todosCodigosOcorrencia}"
					var="codigoOcorrencia" itemValue="#{codigoOcorrencia}"
					itemLabel="#{codigoOcorrencia.descricao}" />
			</p:selectOneMenu>

			<h:outputLabel value="Complemento:" />
			<p:inputText size="12"
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.complemento}"
				label="Complemento">
			</p:inputText>

			<h:outputLabel value="Endereco:" />
			<p:inputText size="12"
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.endereco}"
				label="Endereco">
			</p:inputText>

			<p:outputLabel value="Bairro:" for="bairro" />
			<p:selectOneMenu
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.bairro}"
				id="bairro">
				<f:selectItem itemLabel="Selecione" itemValue="" />
				<f:selectItems value="#{cadastroMovimentacaoBean.todosBairros}"
					var="bairro" itemValue="#{bairro}" itemLabel="#{bairro.bairro}" />
			</p:selectOneMenu>

			<h:outputLabel for="litragem:" value="Litragem: " />
			<p:spinner id="litragem"
				value="#{cadastroMovimentacaoBean.movimentacaoVTR.litragem}"
				stepFactor="0.25" />

			<h:outputLabel value="" for="" />
			<h:outputLabel value="" for="" />
			<p:commandButton value="Salvar"
				action="#{cadastroMovimentacaoBean.salvar}" icon="ui-icon-disk"
				update="@form" />

		</p:panelGrid>
	</h:form>
</ui:define>

</ui:composition>

Converter:

@FacesConverter(forClass = Funcionario.class)
public class FuncionarioConverter implements Converter {
@Inject
private Funcionarios funcionarios;

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
	Funcionario retorno = null;
	if (value != null && !"".equals(value)) {
		retorno = this.funcionarios.porId(new Long(value));
	}
	return retorno;
}

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
	if (value != null) {
		Funcionario lancamento = ((Funcionario) value);
		return lancamento.getId() == null ? null : lancamento.getId().toString();
	}
	return null;
}

}

A
Solucao aceita

Não entendo o que pode estar ocorrendo, já que somente o “Funcionario” que possuem relação com “UsuarioLogin” dá esse erro.

Veja na imagem abaixo que o exemplo “Silva” não possui uma relação em “UsuarioLogin” e não tenho o erro, já “Oliveira” sim possui tal relacionamento aí o erro ocorre:

image

A

Pessoal, consegui resolver, coloquei o <?xml version="1.0" encoding="UTF-8"?> no início do arquivo .xhtml.

Obrigado aos amigos.

Criado 28 de julho de 2018
Ultima resposta 1 de ago. de 2018
Respostas 10
Participantes 3