Gente boa noite, ao tentar acessar a pagina de detalhes, consta esse erro
HTTP Status 500 - An exception occurred processing JSP page /WEB-INF/views/produtos/detalhe.jsp at line 102
type Exception report
message An exception occurred processing JSP page /WEB-INF/views/produtos/detalhe.jsp at line 102
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/produtos/detalhe.jsp at line 102
99: <form action="/carrinho/add" method="post" class="container">
100: <ul id="variants" class="clearfix">
101: <input type="hidden" name="produtoId" value="${produto.id}" />
102: <c:forEach items="${produto.precos}" var="preco">
103: <li class="buy-option"><input type="radio" name="tipo"
104: class="variant-radio" id="tipo" value="${preco.tipo}"
105: checked="checked" /> <label class="variant-label">
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:580)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:172)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.casadocodigo.loja.models.Produto.precos, could not initialize proxy - no Session
org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:572)
org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:212)
org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:551)
org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:140)
org.hibernate.collection.internal.PersistentBag.iterator(PersistentBag.java:294)
org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(ForEachSupport.java:382)
org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator(ForEachSupport.java:258)
org.apache.taglibs.standard.tag.common.core.ForEachSupport.prepare(ForEachSupport.java:189)
javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(LoopTagSupport.java:287)
org.apache.jsp.WEB_002dINF.views.produtos.detalhe_jsp._jspx_meth_c_005fforEach_005f0(detalhe_jsp.java:393)
org.apache.jsp.WEB_002dINF.views.produtos.detalhe_jsp._jspService(detalhe_jsp.java:222)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:172)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.73 logs.
Apache Tomcat/7.0.73
nele informa um erro na linha 102
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/views/produtos/detalhe.jsp at line 102
como se ele não tivesse encontrando os precos do produto .
alguém pode me ajudar ?
segue codigo do meu model
package br.com.casadocodigo.loja.models;
import java.util.Calendar;
import java.util.List;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.springframework.format.annotation.DateTimeFormat;
@Entity
public class Produto {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String titulo;
private String descricao;
private int paginas;
@ElementCollection
private List<Preco> precos;
private Calendar dataLancamento;
private String sumarioPath;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSumarioPath() {
return sumarioPath;
}
public void setSumarioPath(String sumarioPath) {
this.sumarioPath = sumarioPath;
}
public Calendar getDataLancamento() {
return dataLancamento;
}
public void setDataLancamento(Calendar dataLancamento) {
this.dataLancamento = dataLancamento;
}
public List<Preco> getPrecos() {
return precos;
}
public void setPrecos(List<Preco> precos) {
this.precos = precos;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public int getPaginas() {
return paginas;
}
public void setPaginas(int paginas) {
this.paginas = paginas;
}
@Override
public String toString() {
return "Produto [titulo=" + titulo + ", descricao=" + descricao + ", paginas=" + paginas + "]";
}
}
controller
package br.com.casadocodigo.loja.controllers;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import br.com.casadocodigo.loja.daos.ProdutoDAO;
import br.com.casadocodigo.loja.infra.FileSaver;
import br.com.casadocodigo.loja.models.Produto;
import br.com.casadocodigo.loja.models.TipoPreco;
import br.com.casadocodigo.loja.validation.ProdutoValidation;
@Controller
@RequestMapping("/produtos")
public class ProdutosController {
@Autowired
private FileSaver fileSaver;
@Autowired
private ProdutoDAO produtoDao;
@InitBinder
public void InitBinder(WebDataBinder binder){
binder.addValidators(new ProdutoValidation());
}
@RequestMapping("form")
public ModelAndView form(Produto produto){
ModelAndView modelAndView = new ModelAndView("produtos/form");
modelAndView.addObject("tipos", TipoPreco.values());
return modelAndView;
}
@RequestMapping(method=RequestMethod.POST)
public ModelAndView gravar(MultipartFile sumario, @Valid Produto produto, BindingResult result, RedirectAttributes redirectAttributes){
if(result.hasErrors()){
return form(produto);
}
String path = fileSaver.write("arquivosSumario", sumario);
produto.setSumarioPath(path);
produtoDao.gravar(produto);
redirectAttributes.addFlashAttribute("message","Produto cadastrado com sucesso");
return new ModelAndView("redirect:produtos");
}
@RequestMapping(method = RequestMethod.GET )
public ModelAndView listar(){
ModelAndView modelAndView = new ModelAndView("produtos/listar");
modelAndView.addObject("produtos", produtoDao.listar());
return modelAndView;
}
@RequestMapping("/detalhe/{id}")
public ModelAndView detalhe(@PathVariable("id") Integer id){
ModelAndView modelAndView = new ModelAndView("/produtos/detalhe");
Produto produto = produtoDao.find(id);
modelAndView.addObject("produto", produto);
return modelAndView;
}
}
view
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>${produto.titulo}-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="/carrinho" rel="nofollow">Carrinho</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>
<article id="${produto.id}">
<header id="product-highlight" class="clearfix">
<div id="product-overview" class="container">
<img width="280px" height="395px"
src="http://cdn.shopify.com/s/files/1/0155/7645/products/css-eficiente-featured_large.png?v=1435245145"
class="product-featured-image" />
<h1 class="product-title">${produto.titulo}</h1>
<p class="product-author">
<span class="product-author-link"> </span>
</p>
<p class="book-description">${produto.descricao}</p>
</div>
</header>
<section class="buy-options clearfix">
<form action="/carrinho/add" method="post" class="container">
<ul id="variants" class="clearfix">
<input type="hidden" name="produtoId" value="${produto.id}" />
<c:forEach items="${produto.precos}" var="preco">
<li class="buy-option"><input type="radio" name="tipo"
class="variant-radio" id="tipo" value="${preco.tipo}"
checked="checked" /> <label class="variant-label">
${preco.tipo} </label> <small class="compare-at-price">R$ 39,90</small>
<p class="variant-price">${preco.valor}</p></li>
</c:forEach>
</ul>
<button type="submit" class="submit-image icon-basket-alt"
alt="Compre Agora" title="Compre Agora${produto.titulo}"></button>
</form>
</section>
<div class="container">
<section class="summary">
<ul>
<li><h3>
E muito mais... <a href='/pages/sumario-java8'>veja o sumário</a>.
</h3></li>
</ul>
</section>
<section class="data product-detail">
<h2 class="section-title">Dados do livro:</h2>
<p>
Número de páginas: <span>AQUI O NÚMERO DE PÁGINAS</span>
</p>
<p></p>
<p>Data de publicação: AQUI A DATA DE PUBLICAÇÃO</p>
<p>
Encontrou um erro? <a href='/submissao-errata' target='_blank'>Submeta
uma errata</a>
</p>
</section>
</div>
</article>
<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>