1
Not to escape the scope of the previous question: Product displayed is the smallest within the group (Criteria)
The problem apparently of the issue has been solved, although it was not possible to verify if it really is correct due to the occurrence of an exception error in the conversion class
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import br.com.modelo.Lote;
import br.com.repository.Lotes;
import br.com.util.cdi.CDIServiceLocator;
@FacesConverter(forClass = Lote.class)
public class LoteConverter implements Converter {
//@Inject
private Lotes lotes;
public LoteConverter() {
lotes = CDIServiceLocator.getBean(Lotes.class);
}
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
Lote retorno = null;
if (value != null) {
String id = new String(value);
retorno = lotes.porId(id);
}
return retorno;
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (value != null) {
Lote lote = (Lote) value;
return lote.getLote() == null ? null : lote.getLote();
}
return "";
}
}
War error:
java.lang.ClassCastException: java.sql.Timestamp cannot be cast to br.com.modelo.Lote
at br.com.converter.LoteConverter.getAsString(LoteConverter.java:38)
at org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeSuggestionsAsList(AutoCompleteRenderer.java:498)
at org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeSuggestions(AutoCompleteRenderer.java:393)
at org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeResults(AutoCompleteRenderer.java:123)
at org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeEnd(AutoCompleteRenderer.java:105)
at javax.faces.component.UIComponentBase.encodeEnd(Unknown Source)
at javax.faces.component.UIComponent.encodeAll(Unknown Source)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(Unknown Source)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(Unknown Source)
at javax.faces.component.UIComponent.visitTree(Unknown Source)
at org.primefaces.component.api.UIData.visitColumnContent(UIData.java:879)
at org.primefaces.component.api.UIData.visitRows(UIData.java:853)
at org.primefaces.component.api.UIData.visitTree(UIData.java:707)
at javax.faces.component.UIComponent.visitTree(Unknown Source)
at javax.faces.component.UIComponent.visitTree(Unknown Source)
at org.primefaces.component.api.UITabPanel.visitTree(UITabPanel.java:920)
at javax.faces.component.UIComponent.visitTree(Unknown Source)
at javax.faces.component.UIForm.visitTree(Unknown Source)
at javax.faces.component.UIComponent.visitTree(Unknown Source)
at javax.faces.component.UIComponent.visitTree(Unknown Source)
at com.sun.faces.context.PartialViewContextImpl.processComponents(Unknown Source)
at com.sun.faces.context.PartialViewContextImpl.processPartial(Unknown Source)
at javax.faces.context.PartialViewContextWrapper.processPartial(Unknown Source)
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)
at javax.faces.component.UIViewRoot.encodeChildren(Unknown Source)
at javax.faces.component.UIComponent.encodeAll(Unknown Source)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(Unknown Source)
at com.sun.faces.application.view.MultiViewHandler.renderView(Unknown Source)
at javax.faces.application.ViewHandlerWrapper.renderView(Unknown Source)
at javax.faces.application.ViewHandlerWrapper.renderView(Unknown Source)
at javax.faces.application.ViewHandlerWrapper.renderView(Unknown Source)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(Unknown Source)
at com.sun.faces.lifecycle.Phase.doPhase(Unknown Source)
at com.sun.faces.lifecycle.LifecycleImpl.render(Unknown Source)
at javax.faces.webapp.FacesServlet.service(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
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)
The error line is as follows:
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (value != null) {
Lote lote = (Lote) value; << Linha 38
return lote.getLote() == null ? null : lote.getLote();
}
return "";
}
Any suggestions on how to solve?
Continued with the same error of Exception: java.lang.Classcastexception: java.sql.Timestamp cannot be cast to br.com.modelo.Batch I think has something to do with the expiration date of the lot. Or it may be that the solution to the question at the beginning of this question is not doing what it is to do.
– Fábio Luciano