Olá amigos, estou com um problema, e não sei o que pode estar acontecendo. Pois bem, comecei a criar meu projeto do zero usando JSF /PRIMEFACES /JPA e Hibernate. Até agora criei apenas uma entidade e consegui fazer um crud. até aqui tudo bem....
*Depois criei uma entidade que se relaciona com minha entidade anterior que havia criado, mais na hora de subir meu projeto, ele apresenta vários erros e não tenho ideia do que se trata. o problema fica quando começo a aumentar o sistema. Ou seja, quando crio uma nova entidade que será persistida junto com a entidade antererior "Só repentindo para concluir rsrs"
Segue meu codigo
Minha Entidade
@Entity
public class ModeloCarro {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long codigo;
private String descricao;
@ManyToOne
@JoinColumn(name = "codigo_fabricante")
private Fabricante fabricante;
public Long getCodigo() {
return codigo;
}
public void setCodigo(Long codigo) {
this.codigo = codigo;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public Fabricante getFabricante() {
return fabricante;
}
public void setFabricante(Fabricante fabricante) {
this.fabricante = fabricante;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((codigo == null) ? 0 : codigo.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ModeloCarro other = (ModeloCarro) obj;
if (codigo == null) {
if (other.codigo != null)
return false;
} else if (!codigo.equals(other.codigo))
return false;
return true;
}
}
Meu DAO
public class ModeloCarroDAO implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private EntityManager manager;
public ModeloCarro buscarPeloCodigo(Long codigo) {
return manager.find(ModeloCarro.class, codigo);
}
@Transactional
public void salvar(ModeloCarro modeloCarro) {
manager.merge(modeloCarro);
}
public List<ModeloCarro> buscarTodos() {
return manager.createQuery("from ModeloCarro", ModeloCarro.class).getResultList();
}
@Transactional
public void excluir(ModeloCarro modeloCarro) throws NegocioException {
modeloCarro = buscarPeloCodigo(modeloCarro.getCodigo());
try {
manager.remove(modeloCarro);
manager.flush();
} catch (PersistenceException e) {
throw new NegocioException("Modelo de carro não pode ser excluído.");
}
}
}
Classe Service
public class ModeloCarroService implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private ModeloCarroDAO modeloCarroDAO;
public void salvar(ModeloCarro modeloCarro) throws NegocioException {
this.modeloCarroDAO.salvar(modeloCarro);
}
Classe BEAN
package com.irmaosuspension.controleservico.controller;
import java.io.Serializable;
import java.util.List;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.omnifaces.util.Messages;
import com.irmaosuspension.controleservico.dao.FabricanteDAO;
import com.irmaosuspension.controleservico.modelo.Fabricante;
import com.irmaosuspension.controleservico.modelo.ModeloCarro;
import com.irmaosuspension.controleservico.service.ModeloCarroService;
import com.irmaosuspension.controleservico.util.NegocioException;
@Named
@ViewScoped
public class CadastroModeloCarroBean implements Serializable {
private static final long serialVersionUID = 1L;
private ModeloCarro modeloCarro;
private List<Fabricante> fabricantes;
@Inject
private ModeloCarroService modeloCarroService;
@Inject
private FabricanteDAO fabricanteDAO;
public void inicializar() {
if (this.modeloCarro == null) {
this.limpar();
}
this.fabricantes = fabricanteDAO.buscarTodos();
}
public void salvar() {
try {
this.modeloCarroService.salvar(modeloCarro);
Messages.addGlobalInfo("Modelo carro salvo com sucesso!");
this.limpar();
} catch (NegocioException e) {
Messages.addGlobalError(e.getMessage());
}
}
public ModeloCarro getModeloCarro() {
return modeloCarro;
}
public void setModeloCarro(ModeloCarro modeloCarro) {
this.modeloCarro = modeloCarro;
}
public List<Fabricante> getFabricantes() {
return fabricantes;
}
public boolean isEditando() {
return this.modeloCarro.getCodigo() != null;
}
private void limpar() {
this.modeloCarro = new ModeloCarro();
}
}
Meu Erro:
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/suspension]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:939)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/suspension]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
... 6 more
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-000123: Error loading com.irmaosuspension.controleservico.jpa.TransactionInterceptor defined in <class>com.irmaosuspension.controleservico.jpa.TransactionInterceptor</class> in file:/D:/Projetos/projetos%20java/workspaceAlura/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/irmaoSuspension/WEB-INF/beans.xml@6
at org.jboss.weld.bootstrap.enablement.GlobalEnablementBuilder$ClassLoader.apply(GlobalEnablementBuilder.java:315)
at org.jboss.weld.bootstrap.enablement.GlobalEnablementBuilder$ClassLoader.apply(GlobalEnablementBuilder.java:302)
at com.google.common.collect.Lists$TransformingRandomAccessList$1.transform(Lists.java:617)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
at org.jboss.weld.bootstrap.enablement.GlobalEnablementBuilder.filter(GlobalEnablementBuilder.java:293)
at org.jboss.weld.bootstrap.enablement.GlobalEnablementBuilder.createModuleEnablement(GlobalEnablementBuilder.java:239)
at org.jboss.weld.bootstrap.BeanDeployment.createEnablement(BeanDeployment.java:213)
at org.jboss.weld.bootstrap.WeldStartup.startInitialization(WeldStartup.java:389)
at org.jboss.weld.bootstrap.WeldBootstrap.startInitialization(WeldBootstrap.java:76)
at org.jboss.weld.environment.servlet.WeldServletLifecycle.initialize(WeldServletLifecycle.java:187)
at org.jboss.weld.environment.servlet.EnhancedListener.onStartup(EnhancedListener.java:61)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5168)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 6 more
Caused by: java.lang.ClassNotFoundException: com.irmaosuspension.controleservico.jpa.TransactionInterceptor
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109)
at org.jboss.weld.environment.deployment.WeldResourceLoader.classForName(WeldResourceLoader.java:40)
at org.jboss.weld.bootstrap.enablement.GlobalEnablementBuilder$ClassLoader.apply(GlobalEnablementBuilder.java:313)
... 18 more
mar 11, 2017 10:41:24 AM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:939)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:655)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:948)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
mar 11, 2017 10:41:24 AM org.apache.catalina.startup.Catalina start
GRAVE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:655)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
mar 11, 2017 10:41:24 AM org.apache.coyote.AbstractProtocol pause
INFORMAÇÕES: Pausing ProtocolHandler ["http-nio-8080"]
mar 11, 2017 10:41:24 AM org.apache.coyote.AbstractProtocol pause
INFORMAÇÕES: Pausing ProtocolHandler ["ajp-nio-8009"]
mar 11, 2017 10:41:24 AM org.apache.catalina.core.StandardService stopInternal
INFORMAÇÕES: Stopping service Catalina
mar 11, 2017 10:41:24 AM org.apache.coyote.AbstractProtocol destroy
INFORMAÇÕES: Destroying ProtocolHandler ["http-nio-8080"]
mar 11, 2017 10:41:24 AM org.apache.coyote.AbstractProtocol destroy
INFORMAÇÕES: Destroying ProtocolHandler ["ajp-nio-8009"]
mar 11, 2017 10:41:24 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [suspension] appears to have started a thread named [weld-worker-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
mar 11, 2017 10:41:24 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [suspension] appears to have started a thread named [weld-worker-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
mar 11, 2017 10:41:24 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [suspension] appears to have started a thread named [weld-worker-3] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
mar 11, 2017 10:41:24 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [suspension] appears to have started a thread named [weld-worker-4] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)