Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Error reading [total]

Boa tarde, poderiam me ajudar com esse erro por favor?

ERRO:

jun 28, 2017 1:50:30 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:casadocodigo' did not find a matching property.
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server version:        Apache Tomcat/9.0.0.M21
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server built:          May 4 2017 22:42:36 UTC
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server number:         9.0.0.0
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Name:               Windows 7
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Version:            6.1
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Architecture:          amd64
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Java Home:             C:\Program Files\Java\jre1.8.0_131
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Version:           1.8.0_131-b11
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Vendor:            Oracle Corporation
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_BASE:         C:\Desenvolvimento\Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_HOME:         C:\Desenvolvimento\Server\apache-tomcat-9.0.0.M21
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.base=C:\Desenvolvimento\Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.home=C:\Desenvolvimento\Server\apache-tomcat-9.0.0.M21
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dwtp.deploy=C:\Desenvolvimento\Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=C:\Desenvolvimento\Server\apache-tomcat-9.0.0.M21\endorsed
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dfile.encoding=Cp1252
jun 28, 2017 1:50:30 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_131\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_131/bin/server;C:/Program Files/Java/jre1.8.0_131/bin;C:/Program Files/Java/jre1.8.0_131/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files\Git\cmd;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Windows\system32;;.]
jun 28, 2017 1:50:30 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["http-nio-8080"]
jun 28, 2017 1:50:30 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
jun 28, 2017 1:50:30 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-nio-8009"]
jun 28, 2017 1:50:30 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
jun 28, 2017 1:50:30 PM org.apache.catalina.startup.Catalina load
INFORMAÇÕES: Initialization processed in 1042 ms
jun 28, 2017 1:50:30 PM org.apache.catalina.core.StandardService startInternal
INFORMAÇÕES: Starting service [Catalina]
jun 28, 2017 1:50:30 PM org.apache.catalina.core.StandardEngine startInternal
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/9.0.0.M21
jun 28, 2017 1:50:33 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.
jun 28, 2017 1:50:33 PM org.apache.catalina.core.ApplicationContext log
INFORMAÇÕES: Spring WebApplicationInitializers detected on classpath: [br.com.casadocodigo.loja.conf.ServletSpringMVC@662be9f7]
log4j:WARN No appenders could be found for logger (br.com.casadocodigo.loja.conf.ServletSpringMVC).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
jun 28, 2017 1:50:33 PM org.apache.catalina.core.ApplicationContext log
INFORMAÇÕES: Initializing Spring FrameworkServlet 'dispatcher'
jun 28, 2017 1:50:39 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["http-nio-8080"]
jun 28, 2017 1:50:39 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["ajp-nio-8009"]
jun 28, 2017 1:50:39 PM org.apache.catalina.startup.Catalina start
INFORMAÇÕES: Server startup in 9048 ms
Hibernate: select produto0_.id as id1_0_, produto0_.dataLancamento as dataLanc2_0_, produto0_.descricao as descrica3_0_, produto0_.paginas as paginas4_0_, produto0_.sumarioPath as sumarioP5_0_, produto0_.titulo as titulo6_0_ from Produto produto0_
Hibernate: select distinct produto0_.id as id1_0_, produto0_.dataLancamento as dataLanc2_0_, produto0_.descricao as descrica3_0_, produto0_.paginas as paginas4_0_, produto0_.sumarioPath as sumarioP5_0_, produto0_.titulo as titulo6_0_, precos1_.Produto_id as Produto_1_0_0__, precos1_.tipo as tipo2_1_0__, precos1_.valor as valor3_1_0__ from Produto produto0_ inner join Produto_precos precos1_ on produto0_.id=precos1_.Produto_id where produto0_.id=?
Hibernate: select distinct produto0_.id as id1_0_, produto0_.dataLancamento as dataLanc2_0_, produto0_.descricao as descrica3_0_, produto0_.paginas as paginas4_0_, produto0_.sumarioPath as sumarioP5_0_, produto0_.titulo as titulo6_0_, precos1_.Produto_id as Produto_1_0_0__, precos1_.tipo as tipo2_1_0__, precos1_.valor as valor3_1_0__ from Produto produto0_ inner join Produto_precos precos1_ on produto0_.id=precos1_.Produto_id where produto0_.id=?
jun 28, 2017 2:01:15 PM org.apache.catalina.core.ApplicationDispatcher invoke
GRAVE: Servlet.service() for servlet [jsp] threw exception
java.util.NoSuchElementException: No value present
    at java.util.Optional.get(Unknown Source)
    at br.com.casadocodigo.loja.models.Produto.precoPara(Produto.java:121)
    at br.com.casadocodigo.loja.models.CarrinhoItem.getPreco(CarrinhoItem.java:17)
    at br.com.casadocodigo.loja.models.CarrinhoItem.getTotal(CarrinhoItem.java:21)
    at br.com.casadocodigo.loja.models.CarrinhoCompras.getTotal(CarrinhoCompras.java:40)
    at br.com.casadocodigo.loja.models.CarrinhoCompras.getTotal(CarrinhoCompras.java:47)
    at br.com.casadocodigo.loja.models.CarrinhoCompras$$FastClassBySpringCGLIB$$40fb54e8.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
    at br.com.casadocodigo.loja.models.CarrinhoCompras$$EnhancerBySpringCGLIB$$33410268.getTotal(<generated>)
    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 javax.el.BeanELResolver.getValue(BeanELResolver.java:94)
    at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
    at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:704)
    at org.apache.jsp.WEB_002dINF.views.carrinho.itens_jsp._jspService(itens_jsp.java:283)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:710)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:172)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1366)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    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)

jun 28, 2017 2:01:15 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [dispatcher] in context with path [/casadocodigo] threw exception [javax.el.ELException: Error reading [total] on type [br.com.casadocodigo.loja.models.CarrinhoCompras$$EnhancerBySpringCGLIB$$33410268]] with root cause
java.util.NoSuchElementException: No value present
    at java.util.Optional.get(Unknown Source)
    at br.com.casadocodigo.loja.models.Produto.precoPara(Produto.java:121)
    at br.com.casadocodigo.loja.models.CarrinhoItem.getPreco(CarrinhoItem.java:17)
    at br.com.casadocodigo.loja.models.CarrinhoItem.getTotal(CarrinhoItem.java:21)
    at br.com.casadocodigo.loja.models.CarrinhoCompras.getTotal(CarrinhoCompras.java:40)
    at br.com.casadocodigo.loja.models.CarrinhoCompras.getTotal(CarrinhoCompras.java:47)
    at br.com.casadocodigo.loja.models.CarrinhoCompras$$FastClassBySpringCGLIB$$40fb54e8.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
    at br.com.casadocodigo.loja.models.CarrinhoCompras$$EnhancerBySpringCGLIB$$33410268.getTotal(<generated>)
    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 javax.el.BeanELResolver.getValue(BeanELResolver.java:94)
    at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
    at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:704)
    at org.apache.jsp.WEB_002dINF.views.carrinho.itens_jsp._jspService(itens_jsp.java:283)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:710)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:172)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1366)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    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)

JSP

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>

<!DOCTYPE html>
<html>
<head>
<c:url value="/" var="contextPath" />
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport"
    content="width=device-width, initial-scale=1, maximum-scale=1" />
<link rel="icon"
    href="//cdn.shopify.com/s/files/1/0155/7645/t/177/assets/favicon.ico?11981592617154272979"
    type="image/ico" />
<link href="https://plus.googlecom/108540024862647200608"
    rel="publisher" />
<title>Livros de Java, SOA, Android, iPhone, Ruby on Rails e
    muito mais - Casa do Código</title>
<link href="${contextPath}resources/css/cssbase-min.css"
    rel="stylesheet" type="text/css" media="all" />
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700'
    rel='stylesheet' />
<link href="${contextPath}resources/css/fonts.css" rel="stylesheet"
    type="text/css" media="all" />
<link href="${contextPath}resources/css/fontello-ie7.css"
    rel="stylesheet" type="text/css" media="all" />
<link href="${contextPath}resources/css/fontello-embedded.css"
    rel="stylesheet" type="text/css" media="all" />
<link href="${contextPath}resources/css/fontello.css" rel="stylesheet"
    type="text/css" media="all" />
<link href="${contextPath}resources/css/style.css" rel="stylesheet"
    type="text/css" media="all" />
<link href="${contextPath}resources/css/layout-colors.css"
    rel="stylesheet" type="text/css" media="all" />
<link href="${contextPath}resources/css/responsive-style.css"
    rel="stylesheet" type="text/css" media="all" />
<link href="${contextPath}resources/css/guia-do-programador-style.css"
    rel="stylesheet" type="text/css" media="all" />
<link href="${contextPath}resources/css/produtos.css" rel="stylesheet"
    type="text/css" media="all" />
<link rel="canonical" href="http://www.casadocodigo.com.br/" />
</head>
<body>

    <header id="layout-header">
        <div class="clearfix container">
            <a href="/" id="logo"> </a>
            <div id="header-content">
                <nav id="main-nav">

                    <ul class="clearfix">
                        <li><a href="${s:mvcUrl('CCC#itens').build() }"
                            rel="nofollow">Seu Carrinho(${carrinhoCompras.quantidade })</a></li>

                        <li><a href="/pages/sobre-a-casa-do-codigo" rel="nofollow">Sobre
                                Nós</a></li>

                        <li><a href="/pages/perguntas-frequentes" rel="nofollow">Perguntas
                                Frequentes</a></li>
                    </ul>
                </nav>
            </div>
        </div>
    </header>
    <nav class="categories-nav">
        <ul class="container">
            <li class="category"><a href="http://www.casadocodigo.com.br">Home</a></li>
            <li class="category"><a href="/collections/livros-de-agile">
                    Agile </a></li>
            <li class="category"><a href="/collections/livros-de-front-end">
                    Front End </a></li>
            <li class="category"><a href="/collections/livros-de-games">
                    Games </a></li>
            <li class="category"><a href="/collections/livros-de-java">
                    Java </a></li>
            <li class="category"><a href="/collections/livros-de-mobile">
                    Mobile </a></li>
            <li class="category"><a
                href="/collections/livros-desenvolvimento-web"> Web </a></li>
            <li class="category"><a href="/collections/outros"> Outros </a></li>
        </ul>
    </nav>

    <section class="container middle">
        <h2 id="cart-title">Seu carrinho de compras</h2>


        <table id="cart-table">
            <colgroup>
                <col class="item-col" />
                <col class="item-price-col" />
                <col class="item-quantity-col" />
                <col class="line-price-col" />
                <col class="delete-col" />
            </colgroup>
            <thead>
                <tr>
                    <th class="cart-img-col"></th>
                    <th width="65%">Item</th>
                    <th width="10%">Preço</th>
                    <th width="10%">Quantidade</th>
                    <th width="10%">Total</th>
                    <th width="5%"></th>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${item.key.produto.titulo  }" var="item">
                    <tr>
                        <td class="cart-img-col"><img src="/excluir" width="71px"
                            height="100px" /></td>
                        <td class="item-title">${item.produto.titulo }</td>
                        <td class="numeric-cell">${item.preco }</td>
                        <td class="quantity-input-cell"><input type="number" min="0"
                            readonly="readonly" id="quantidade" name="quantidade"
                            value="${carrinhoCompras.Quantidade(item) }" /></td>
                        <td class="numeric-cell">${carrinhoCompras.Total(item) }</td>
                        <td class="remove-item">
                            <form action="" method="post">
                                <img src="${contextPath }resources/imagens/excluir.png"
                                    alt="Excluir" title="Excluir" /></a>
                            </form>
                        </td>
                    </tr>
                </c:forEach>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="3">
                        <form action="${s:mvcUrl('PC#finalizar').build()}" method="post">
                            <input type="submit" class="checkout" name="checkout"
                                value="Finalizar compra" id="checkout"/>
                        </form>
                    </td>
                    <td class="numeric-cell">${carrinhoCompras.total }</td>
                    <td></td>
                </tr>
            </tfoot>
        </table>

        <h2>Você já conhece os outros livros da Casa do Código?</h2>
        <ul id="collection" class="related-books">
            <li class="col-left"><a href="/products/livro-plsql"
                class="block clearfix book-suggest"
                data-book="PL/SQL: Domine a linguagem do banco de dados Oracle">
                    <img width="113px" height="160px"
                    src="http:////cdn.shopify.com/s/files/1/0155/7645/products/plsql-featured_compact.png?v=1434740236"
                    alt="PL/SQL: Domine a linguagem do banco de dados Oracle" />
            </a></li>
        </ul>

        <h2>
            <a href="http://www.casadocodigo.com.br">Veja todos os livros que
                publicamos!</a>
        </h2>
    </section>



    <footer id="layout-footer">
        <div class="clearfix container">




            <div id="collections-footer">
                <!-- cdc-footer -->
                <p class="footer-title">Coleções de Programação</p>
                <ul class="footer-text-links">
                    <li><a href="/collections/livros-de-java">Java</a></li>
                    <li><a href="/collections/livros-desenvolvimento-web">Desenvolvimento
                            Web</a></li>
                    <li><a href="/collections/livros-de-mobile">Mobile</a></li>
                    <li><a href="/collections/games">Games</a></li>
                    <li><a href="/collections/livros-de-front-end">Front End</a></li>
                </ul>
                <p class="footer-title">Outros Assuntos</p>
                <ul class="footer-text-links">
                    <li><a href="/collections/livros-de-agile">Agile</a></li>
                    <li><a href="/collections/outros">e outros...</a></li>
                </ul>
            </div>
            <div id="social-footer">
                <!-- books-footer -->
                <p class="footer-title">Links da Casa do Código</p>
                <ul class="footer-text-links">
                    <li><a href="http://livros.casadocodigo.com.br" rel="nofollow">Meus
                            E-books</a></li>
                    <li><a href="/pages/sobre-a-casa-do-codigo">Sobre a Casa
                            do Código</a></li>
                    <li><a href="/pages/perguntas-frequentes">Perguntas
                            Frequentes</a></li>
                    <li><a href="https://www.caelum.com.br">Caelum - Ensino e
                            Inovação</a></li>
                    <li><a href="http://www.codecrushing.com/" rel="nofollow">Code
                            Crushing</a></li>
                    <li><a
                        href="http://www.casadocodigo.com.br/pages/politica-de-privacidade"
                        rel="nofollow">Política de Privacidade</a></li>
                </ul>
                <p class="footer-title">Redes Sociais</p>
                <ul>
                    <li class="social-links"><a
                        href="http://www.twitter.com/casadocodigo" target="_blank"
                        id="twitter" rel="nofollow">Facebook</a> <a
                        href="http://www.facebook.com/casadocodigo" target="_blank"
                        id="facebook" rel="nofollow">Twitter</a></li>
                </ul>
            </div>
            <div id="newsletter-footer">
                <!-- social-footer -->
                <p class="footer-title">Receba as Novidades e Lançamentos</p>
                <div id="form-newsletter">
                    <form action="" method="POST" id="ss-form" class="form-newsletter">
                        <ul>
                            <li><input type="hidden" name="pageNumber" value="0" /><input
                                type="hidden" name="backupCache" value="" /><input type="email"
                                name="entry.0.single" value="" class="ss-q-short" id="entry_0"
                                placeholder="seu@email.com" /></li>
                            <li><input type="submit" name="submit"
                                value="Quero Receber!" id="submit-newsletter" /></li>
                        </ul>
                    </form>
                    <ul>
                        <li class="ie8"><a href="" rel="nofollow">Receba as
                                Novidades e Lançamentos</a></li>
                    </ul>
                </div>
                <ul class="footer-payments">
                    <li></li>
                    <li></li>
                </ul>
            </div>
        </div>
    </footer>
</body>
</html>

classe CarrinhoCompras

package br.com.casadocodigo.loja.models;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.Map;

import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;

@Component
@Scope(value=WebApplicationContext.SCOPE_SESSION, proxyMode=ScopedProxyMode.TARGET_CLASS)
public class CarrinhoCompras implements Serializable {


    private static final long serialVersionUID = 1L;

    public static long getSerialversionuid() {
        return serialVersionUID;
    }
    private Map<CarrinhoItem, Integer> itens = new LinkedHashMap<>();

    public void add(CarrinhoItem item) {
        itens.put(item, getQuantidade(item) + 1);
    }
    public int getQuantidade(CarrinhoItem item) {
        if(!itens.containsKey(item)) {
            itens.put(item, 0);
        }
        return itens.get(item);
    }

    public int getQuantidade() {
        return itens.values().stream().reduce(0, (proximo,acumulador) -> proximo + acumulador);
    }

    public BigDecimal getTotal(CarrinhoItem item) {
        return item.getTotal(getQuantidade(item));
    }

    public BigDecimal getTotal() {
        BigDecimal total = BigDecimal.ZERO;

        for(CarrinhoItem item : itens.keySet()) {
            total = total.add(getTotal(item));
        }

        return total;
    }
    public Map<CarrinhoItem, Integer> getItens() {
        return itens;
    }
    public void setItens(Map<CarrinhoItem, Integer> itens) {
        this.itens = itens;
    }
}

classe PagamentoController

package br.com.casadocodigo.loja.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import br.com.casadocodigo.loja.models.CarrinhoCompras;

@RequestMapping("/pagamento")
@Controller
public class PagamentoController {

    @Autowired
    private CarrinhoCompras carrinho;

    @RequestMapping(value="/finalizar", method=RequestMethod.POST)
    public ModelAndView finalizar(RedirectAttributes model){
        System.out.println(carrinho.getTotal());

        model.addFlashAttribute("sucesso", "Pagamento Realizado com Sucesso");

        return new ModelAndView("redirect:/produtos");
    }
}
2 respostas
solução!

Opa, o problema está no método precoPara na classe Produto. Você está tentando dar get numa Optional, mas essa Optional está vazia. Para saber exatamente, vai ser necessário uma leve debugada para entender o que está chegando errado.

O atributo"tipoPreco" está chegando nulo ao método "precoPara". Provavelmente isso ocorre porque em seu form que envia o preço escolhido, o nome do componente "radio" não está coincidindo com o nome do atributo no método da Controller especificado na action.