Boa tarde. estou tendo um problema com minha aplicação web. tenho a classe ordemdeservico a classe itensdeservico e a classe tipodeservico qndo mando adicionar algum serviço a minha ordem de servico me da um erro…
Meu Bean
[code]package br.com.projeto.controller;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import br.com.projeto.beans.Funcionario;
import br.com.projeto.beans.ItensDeServico;
import br.com.projeto.beans.OrdemDeServico;
import br.com.projeto.beans.Pessoa;
import br.com.projeto.beans.TipoDeServico;
import br.com.projeto.dao.HibernateDao;
@ManagedBean
@SessionScoped
public class OrdemDeServicoBean implements InterfaceController {
private Funcionario funcionario = new Funcionario();
private Pessoa pessoa = new Pessoa();
private List<ItensDeServico> itensDeServico = new ArrayList<ItensDeServico>();
private ItensDeServico itenDeServico = new ItensDeServico();
private OrdemDeServico ordemDeServico = new OrdemDeServico();
private TipoDeServico tipoDeServico = new TipoDeServico();
private Integer quantidade = 0;
private float subtotal = 0;
@Override
public void salvar() {
try {
FacesContext context = FacesContext.getCurrentInstance();
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
ordemDeServico.setPessoa(pessoa);
ordemDeServico.setItensDeServico(itensDeServico);
ordemDeServico.setFuncionario(funcionario);
hibernateDao.salvar(ordemDeServico);
ordemDeServico = new OrdemDeServico();
funcionario = new Funcionario();
pessoa = new Pessoa();
itensDeServico = new ArrayList<ItensDeServico>();
itenDeServico = new ItensDeServico();
tipoDeServico = new TipoDeServico();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Sucesso!", "Ordem De Servico Adicionada"));
} catch (Exception e) {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(
FacesMessage.SEVERITY_ERROR, "Erro!", " " + e));
}
}
@Override
public void remove() {
try {
FacesContext context = FacesContext.getCurrentInstance();
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
Integer id = ordemDeServico.getIdOrdemDeServico();
ordemDeServico = hibernateDao.getBean(id);
hibernateDao.deletar(ordemDeServico);
ordemDeServico = new OrdemDeServico();
funcionario = new Funcionario();
pessoa = new Pessoa();
itensDeServico = new ArrayList<ItensDeServico>();
itenDeServico = new ItensDeServico();
tipoDeServico = new TipoDeServico();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Sucesso!", "Ordem De Servico Excluida"));
} catch (Exception e) {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Erro!", " " + e));
}
}
@Override
public String antesUpdate() {
try {
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
Integer id = ordemDeServico.getIdOrdemDeServico();
ordemDeServico = hibernateDao.getBean(id);
funcionario = ordemDeServico.getFuncionario();
pessoa = ordemDeServico.getPessoa();
itensDeServico = ordemDeServico.getItensDeServico();
return "EditarOrdemDeServico";
} catch (Exception e) {
System.out.println("Erro " + e);
return "Erro";
}
}
@Override
public void update() {
try {
FacesContext context = FacesContext.getCurrentInstance();
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
hibernateDao.atualizar(ordemDeServico);
ordemDeServico = new OrdemDeServico();
funcionario = new Funcionario();
pessoa = new Pessoa();
itensDeServico = new ArrayList<ItensDeServico>();
itenDeServico = new ItensDeServico();
tipoDeServico = new TipoDeServico();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Sucesso!", "Ordem De Servico Atualizada"));
} catch (Exception e) {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Erro!", " " + e));
}
}
public List<OrdemDeServico> getListOrdemDeServico() {
List<OrdemDeServico> ordemDeServicos = new ArrayList<OrdemDeServico>();
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
ordemDeServicos = hibernateDao.getBeans();
return ordemDeServicos;
}
public String selecionarPessoa(){
try {
HibernateDao<Pessoa> hibernateDao = new HibernateDao<Pessoa>(Pessoa.class);
Integer id = pessoa.getIdPessoa();
pessoa = hibernateDao.getBean(id);
return "CadastroOrdemDeServico";
} catch (Exception e) {
System.out.println("Erro " + e);
return "Erro.jsf";
}
}
public String selecionarFuncionario(){
try{
HibernateDao<Funcionario> hibernateDao = new HibernateDao<Funcionario>(Funcionario.class);
Integer id = funcionario.getIdFuncionario();
funcionario = hibernateDao.getBean(id);
return "CadastroOrdemDeServico";
}catch(Exception e){
System.out.println("Erro "+e);
return "Erro.jsf";
}
}
public String selecionarTiposDeServico(){
HibernateDao<TipoDeServico> hibernateDao = new HibernateDao<TipoDeServico>(TipoDeServico.class);
Integer id = tipoDeServico.getIdTipoDeServico();
tipoDeServico = hibernateDao.getBean(id);
return "EditarOrdemDeServico";
}
//AKI EU CHAMO PARA ADICIONAR O SERVICO
public void adicionarServico(){
HibernateDao<TipoDeServico> hibernateDao = new HibernateDao<TipoDeServico>(TipoDeServico.class);
Integer id = tipoDeServico.getIdTipoDeServico();
tipoDeServico = hibernateDao.getBean(id);
itenDeServico.setTipoDeServico(tipoDeServico);
itenDeServico.setPessoa(pessoa);
itenDeServico.setQuantidade(quantidade);
itensDeServico.add(itenDeServico);
}
public List<ItensDeServico> getListItensDeServico() {
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
Integer id = ordemDeServico.getIdOrdemDeServico();
ordemDeServico = hibernateDao.getBean(id);
itensDeServico = ordemDeServico.getItensDeServico();
return itensDeServico;
}
//GAN
}[/code]
CLASSE ORDEM DE SERVICO
[code]package br.com.projeto.controller;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import br.com.projeto.beans.Funcionario;
import br.com.projeto.beans.ItensDeServico;
import br.com.projeto.beans.OrdemDeServico;
import br.com.projeto.beans.Pessoa;
import br.com.projeto.beans.TipoDeServico;
import br.com.projeto.dao.HibernateDao;
@ManagedBean
@SessionScoped
public class OrdemDeServicoBean implements InterfaceController {
private Funcionario funcionario = new Funcionario();
private Pessoa pessoa = new Pessoa();
private List<ItensDeServico> itensDeServico = new ArrayList<ItensDeServico>();
private ItensDeServico itenDeServico = new ItensDeServico();
private OrdemDeServico ordemDeServico = new OrdemDeServico();
private TipoDeServico tipoDeServico = new TipoDeServico();
private Integer quantidade = 0;
private float subtotal = 0;
@Override
public void salvar() {
try {
FacesContext context = FacesContext.getCurrentInstance();
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
ordemDeServico.setPessoa(pessoa);
ordemDeServico.setItensDeServico(itensDeServico);
ordemDeServico.setFuncionario(funcionario);
hibernateDao.salvar(ordemDeServico);
ordemDeServico = new OrdemDeServico();
funcionario = new Funcionario();
pessoa = new Pessoa();
itensDeServico = new ArrayList<ItensDeServico>();
itenDeServico = new ItensDeServico();
tipoDeServico = new TipoDeServico();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Sucesso!", "Ordem De Servico Adicionada"));
} catch (Exception e) {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(
FacesMessage.SEVERITY_ERROR, "Erro!", " " + e));
}
}
@Override
public void remove() {
try {
FacesContext context = FacesContext.getCurrentInstance();
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
Integer id = ordemDeServico.getIdOrdemDeServico();
ordemDeServico = hibernateDao.getBean(id);
hibernateDao.deletar(ordemDeServico);
ordemDeServico = new OrdemDeServico();
funcionario = new Funcionario();
pessoa = new Pessoa();
itensDeServico = new ArrayList<ItensDeServico>();
itenDeServico = new ItensDeServico();
tipoDeServico = new TipoDeServico();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Sucesso!", "Ordem De Servico Excluida"));
} catch (Exception e) {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Erro!", " " + e));
}
}
@Override
public String antesUpdate() {
try {
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
Integer id = ordemDeServico.getIdOrdemDeServico();
ordemDeServico = hibernateDao.getBean(id);
funcionario = ordemDeServico.getFuncionario();
pessoa = ordemDeServico.getPessoa();
itensDeServico = ordemDeServico.getItensDeServico();
return "EditarOrdemDeServico";
} catch (Exception e) {
System.out.println("Erro " + e);
return "Erro";
}
}
@Override
public void update() {
try {
FacesContext context = FacesContext.getCurrentInstance();
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
hibernateDao.atualizar(ordemDeServico);
ordemDeServico = new OrdemDeServico();
funcionario = new Funcionario();
pessoa = new Pessoa();
itensDeServico = new ArrayList<ItensDeServico>();
itenDeServico = new ItensDeServico();
tipoDeServico = new TipoDeServico();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Sucesso!", "Ordem De Servico Atualizada"));
} catch (Exception e) {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Erro!", " " + e));
}
}
public List<OrdemDeServico> getListOrdemDeServico() {
List<OrdemDeServico> ordemDeServicos = new ArrayList<OrdemDeServico>();
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
ordemDeServicos = hibernateDao.getBeans();
return ordemDeServicos;
}
public String selecionarPessoa(){
try {
HibernateDao<Pessoa> hibernateDao = new HibernateDao<Pessoa>(Pessoa.class);
Integer id = pessoa.getIdPessoa();
pessoa = hibernateDao.getBean(id);
return "CadastroOrdemDeServico";
} catch (Exception e) {
System.out.println("Erro " + e);
return "Erro.jsf";
}
}
public String selecionarFuncionario(){
try{
HibernateDao<Funcionario> hibernateDao = new HibernateDao<Funcionario>(Funcionario.class);
Integer id = funcionario.getIdFuncionario();
funcionario = hibernateDao.getBean(id);
return "CadastroOrdemDeServico";
}catch(Exception e){
System.out.println("Erro "+e);
return "Erro.jsf";
}
}
public String selecionarTiposDeServico(){
HibernateDao<TipoDeServico> hibernateDao = new HibernateDao<TipoDeServico>(TipoDeServico.class);
Integer id = tipoDeServico.getIdTipoDeServico();
tipoDeServico = hibernateDao.getBean(id);
return "EditarOrdemDeServico";
}
public void adicionarServico(){
HibernateDao<TipoDeServico> hibernateDao = new HibernateDao<TipoDeServico>(TipoDeServico.class);
Integer id = tipoDeServico.getIdTipoDeServico();
tipoDeServico = hibernateDao.getBean(id);
itenDeServico.setTipoDeServico(tipoDeServico);
itenDeServico.setPessoa(pessoa);
itenDeServico.setQuantidade(quantidade);
itensDeServico.add(itenDeServico);
}
public List<ItensDeServico> getListItensDeServico() {
HibernateDao<OrdemDeServico> hibernateDao = new HibernateDao<OrdemDeServico>(OrdemDeServico.class);
Integer id = ordemDeServico.getIdOrdemDeServico();
ordemDeServico = hibernateDao.getBean(id);
itensDeServico = ordemDeServico.getItensDeServico();
return itensDeServico;
}
//GAS
}
[/code]
CLASSE ITEMDESERVICO
[code]package br.com.projeto.beans;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class ItensDeServico implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Integer idItensDeServico;
private Integer quantidade;
private Float subtotal;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "id_tipoDeServico")
private TipoDeServico tipoDeServico;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "id_pessoa")
private Pessoa pessoa;
//GAS
}
[/code]
O ERRO
[code]28391 [http-bio-8080-exec-10] ERROR org.hibernate.LazyInitializationException - failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:205)
at org.hibernate.collection.PersistentBag.add(PersistentBag.java:297)
at br.com.projeto.controller.OrdemDeServicoBean.adicionarServico(OrdemDeServicoBean.java:160)
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 org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Nov 16, 2011 2:45:57 PM com.sun.faces.application.ActionListenerImpl processAction
Grave: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed
javax.faces.el.EvaluationException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:205)
at org.hibernate.collection.PersistentBag.add(PersistentBag.java:297)
at br.com.projeto.controller.OrdemDeServicoBean.adicionarServico(OrdemDeServicoBean.java:160)
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 org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
… 24 more
Nov 16, 2011 2:45:57 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
Advertência: #{ordemDeServicoBean.adicionarServico}: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed
javax.faces.FacesException: #{ordemDeServicoBean.adicionarServico}: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.EvaluationException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
… 23 more
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:205)
at org.hibernate.collection.PersistentBag.add(PersistentBag.java:297)
at br.com.projeto.controller.OrdemDeServicoBean.adicionarServico(OrdemDeServicoBean.java:160)
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 org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
… 24 more
Nov 16, 2011 2:45:57 PM org.apache.catalina.core.StandardWrapperValve invoke
Grave: Servlet.service() for servlet [Faces Servlet] in context with path [/Projeto_Faculdade] threw exception [org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed] with root cause
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.projeto.beans.OrdemDeServico.itensDeServico, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:205)
at org.hibernate.collection.PersistentBag.add(PersistentBag.java:297)
at br.com.projeto.controller.OrdemDeServicoBean.adicionarServico(OrdemDeServicoBean.java:160)
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 org.apache.el.parser.AstValue.invoke(AstValue.java:262)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)[/code]
ALGUEM PDE ME AJUDA?