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

Erro ao criar lib

Olá, boa tarde!

Segui exatamente as instruções do exercício e do vídeo, mas está apresentando erro ao iniciar o Tomcat. Inclusive fiz o download do projeto e importei para o Eclipse, porém o erro persiste.

Seguem as mensagens apresentadas no console:

dez 03, 2016 4:11:12 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:livraria' did not find a matching property.
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server version:        Apache Tomcat/8.0.33
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server built:          Mar 18 2016 20:31:49 UTC
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server number:         8.0.33.0
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Name:               Windows 10
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Version:            10.0
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Architecture:          amd64
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Java Home:             C:\Program Files\Java\jre1.8.0_101
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Version:           1.8.0_101-b13
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Vendor:            Oracle Corporation
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_BASE:         C:\Users\User\Desktop\Alura\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_HOME:         C:\Users\User\Documents\CURSOS\Alura\BACK-END\Java e JPA\apache-tomcat-8.0.33
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.base=C:\Users\User\Desktop\Alura\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.home=C:\Users\User\Documents\CURSOS\Alura\BACK-END\Java e JPA\apache-tomcat-8.0.33
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dwtp.deploy=C:\Users\User\Desktop\Alura\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=C:\Users\User\Documents\CURSOS\Alura\BACK-END\Java e JPA\apache-tomcat-8.0.33\endorsed
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dfile.encoding=Cp1252
dez 03, 2016 4:11:12 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_101\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk1.8.0_65/bin/../jre/bin/server;C:/Program Files/Java/jdk1.8.0_65/bin/../jre/bin;C:/Program Files/Java/jdk1.8.0_65/bin/../jre/lib/amd64;;%JAVA_HOME%\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\nodejs\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;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\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 (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Skype\Phone\;C:\Ruby22-x64\bin;C:\Program Files\Java\jdk1.8.0_65\bin;C:\Users\User\AppData\Roaming\npm;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\User\AppData\Local\Microsoft\WindowsApps;;C:\Users\User\Downloads\eclipse;;.
dez 03, 2016 4:11:12 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["http-nio-8080"]
dez 03, 2016 4:11:12 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
dez 03, 2016 4:11:12 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-nio-8009"]
dez 03, 2016 4:11:12 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
dez 03, 2016 4:11:12 PM org.apache.catalina.startup.Catalina load
INFORMAÇÕES: Initialization processed in 1129 ms
dez 03, 2016 4:11:12 PM org.apache.catalina.core.StandardService startInternal
INFORMAÇÕES: Starting service Catalina
dez 03, 2016 4:11:12 PM org.apache.catalina.core.StandardEngine startInternal
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/8.0.33
dez 03, 2016 4:11:13 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.
dez 03, 2016 4:11:16 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.
dez 03, 2016 4:11:16 PM org.jboss.weld.environment.servlet.EnhancedListener onStartup
INFO: WELD-ENV-001008: Initialize Weld using ServletContainerInitializer
dez 03, 2016 4:11:16 PM org.jboss.weld.bootstrap.WeldStartup <clinit>
INFO: WELD-000900: 2.3.5 (Final)
dez 03, 2016 4:11:17 PM org.jboss.weld.bootstrap.WeldStartup startContainer
INFO: WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
dez 03, 2016 4:11:18 PM org.jboss.weld.environment.tomcat.TomcatContainer initialize
INFO: WELD-ENV-001100: Tomcat 7+ detected, CDI injection will be available in Servlets, Filters and Listeners.
dez 03, 2016 4:11:18 PM org.jboss.weld.bootstrap.BeanDeployer createClassBean
WARN: WELD-000167: Class br.com.alura.livraria.bean.VendasBean is annotated with @ViewScoped but it does not declare an appropriate constructor therefore is not registered as a bean!
dez 03, 2016 4:11:18 PM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/livraria]]
    at java.util.concurrent.FutureTask.report(Unknown Source)
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    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.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/livraria]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
    ... 6 more
Caused by: org.jboss.weld.exceptions.DeploymentException: Exception List with 3 exceptions:
Exception 0 :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type EntityManager with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private br.com.alura.livraria.dao.UsuarioDao.em
  at br.com.alura.livraria.dao.UsuarioDao.em(UsuarioDao.java:0)

    at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
    at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Exception 1 :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type DAO<Autor> with qualifiers @Default
  at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public br.com.alura.livraria.bean.AutorBean(DAO<Autor>)
  at br.com.alura.livraria.bean.AutorBean.<init>(AutorBean.java:28)

    at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
    at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Exception 2 :
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type DAO<Livro> with qualifiers @Default
  at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject public br.com.alura.livraria.bean.LivroBean(DAO<Livro>, DAO<Autor>)
  at br.com.alura.livraria.bean.LivroBean.<init>(LivroBean.java:35)

    at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
    at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
    at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
    at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
    at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    at org.jboss.weld.bootstrap.ConcurrentValidator.validateBeans(ConcurrentValidator.java:76)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:479)
    at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:445)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
    at org.jboss.weld.environment.servlet.WeldServletLifecycle.initialize(WeldServletLifecycle.java:238)
    at org.jboss.weld.environment.servlet.EnhancedListener.onStartup(EnhancedListener.java:61)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5240)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 6 more

dez 03, 2016 4:11:18 PM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at java.util.concurrent.FutureTask.report(Unknown Source)
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:787)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
    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.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    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.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 6 more

dez 03, 2016 4:11:18 PM org.apache.catalina.startup.Catalina start
GRAVE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
    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.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:787)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:924)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    ... 11 more

dez 03, 2016 4:11:18 PM org.apache.coyote.AbstractProtocol pause
INFORMAÇÕES: Pausing ProtocolHandler ["http-nio-8080"]
dez 03, 2016 4:11:18 PM org.apache.coyote.AbstractProtocol pause
INFORMAÇÕES: Pausing ProtocolHandler ["ajp-nio-8009"]
dez 03, 2016 4:11:18 PM org.apache.catalina.core.StandardService stopInternal
INFORMAÇÕES: Stopping service Catalina
dez 03, 2016 4:11:18 PM org.apache.coyote.AbstractProtocol destroy
INFORMAÇÕES: Destroying ProtocolHandler ["http-nio-8080"]
dez 03, 2016 4:11:18 PM org.apache.coyote.AbstractProtocol destroy
GRAVE: Failed to destroy end point associated with ProtocolHandler ["http-nio-8080"]
java.lang.NullPointerException
    at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:305)
    at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:481)
    at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:831)
    at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:533)
    at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:297)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:589)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:297)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:877)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:297)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
    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.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

dez 03, 2016 4:11:18 PM org.apache.coyote.AbstractProtocol destroy
INFORMAÇÕES: Destroying ProtocolHandler ["ajp-nio-8009"]
dez 03, 2016 4:11:18 PM org.apache.coyote.AbstractProtocol destroy
GRAVE: Failed to destroy end point associated with ProtocolHandler ["ajp-nio-8009"]
java.lang.NullPointerException
    at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:305)
    at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:481)
    at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:831)
    at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:533)
    at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:297)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:589)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:297)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:877)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:297)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
    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.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

dez 03, 2016 4:11:18 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [livraria] 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(Unknown Source)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
 java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 java.lang.Thread.run(Unknown Source)
dez 03, 2016 4:11:18 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [livraria] 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(Unknown Source)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
 java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 java.lang.Thread.run(Unknown Source)
dez 03, 2016 4:11:18 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [livraria] 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(Unknown Source)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
 java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 java.lang.Thread.run(Unknown Source)
dez 03, 2016 4:11:18 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [livraria] 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(Unknown Source)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
 java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 java.lang.Thread.run(Unknown Source)
dez 03, 2016 4:11:18 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [livraria] appears to have started a thread named [weld-preloader-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(Unknown Source)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
 java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 java.lang.Thread.run(Unknown Source)
dez 03, 2016 4:11:18 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [livraria] appears to have started a thread named [weld-preloader-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(Unknown Source)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
 java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 java.lang.Thread.run(Unknown Source)
dez 03, 2016 4:11:18 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
ADVERTÊNCIA: The web application [livraria] appears to have started a thread named [weld-preloader-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(Unknown Source)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
 java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 java.lang.Thread.run(Unknown Source)
16 respostas

Opa, a exception indica que ele não está conseguindo resolver as dependências que provavelmente estão no Alura-lib. Já verificou se a dependência realmente foi instalada na Livraria? Caso tenha certeza disso, deu clean no tomcat?

Alberto, bom dia.

Sim, as dependências foram instaladas no projeto livraria. Já dei clean no Tomcat, desinstalei e instalei novamente. Mas continua apresentando erro. Não faço ideia do que pode ser. Aparentemente está tudo certo.

Fala aí Renato blz?

Pode fazer algumas verificações por favor?

No seu projeto Alura-lib, existe o arquivo beans.xml?

Se sim como está sua classe DaoFactory?

Além disso, consegue confirmar se o .jar da Alura-lib está dentro do diretório Users/seu-usuario/.m2/repository/br/com/alura...?

Fernando, tudo blz e vc?

Então, eu verifiquei e o arquvo beans.xml existe sim no projeto alura-lib. Está na pasta \src\main\resources\META-INF.

Quanto ao jar do alura-lib, também se encontra no diretório que você indicou.

Segue minha classe DAOFactory contida em alura-lib.

package br.com.alura.alura_lib.factory;

import java.lang.reflect.ParameterizedType;

import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
import javax.persistence.EntityManager;

import br.com.alura.alura_lib.dao.DAO;

@SuppressWarnings("unchecked")
public class DAOFactory {

    @Inject
    private EntityManager manger;

    @Produces
    public <T> DAO<T> factory(InjectionPoint point){

        ParameterizedType type = (ParameterizedType) point.getType();

        Class<T> classe = (Class<T>) type.getActualTypeArguments()[0];
        return new DAO<T>(classe, manger);
    }

}

Opa Renato, talvez eu esteja fazendo pergunta simples.. mas vc declarou o beans.xml no META-INF do seu projeto livraria, né?

Alberto, Estava declarado em WEB-INF. Movi para META-INF. As mensagens no console agora são essas:

dez 04, 2016 6:20:57 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:livraria' did not find a matching property.
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server version:        Apache Tomcat/8.0.33
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server built:          Mar 18 2016 20:31:49 UTC
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server number:         8.0.33.0
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Name:               Windows 10
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Version:            10.0
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Architecture:          amd64
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Java Home:             C:\Program Files\Java\jre1.8.0_101
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Version:           1.8.0_101-b13
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Vendor:            Oracle Corporation
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_BASE:         C:\Users\User\Desktop\Alura\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_HOME:         C:\Users\User\Documents\CURSOS\Alura\BACK-END\Java e JPA\apache-tomcat-8.0.33
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.base=C:\Users\User\Desktop\Alura\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.home=C:\Users\User\Documents\CURSOS\Alura\BACK-END\Java e JPA\apache-tomcat-8.0.33
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dwtp.deploy=C:\Users\User\Desktop\Alura\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=C:\Users\User\Documents\CURSOS\Alura\BACK-END\Java e JPA\apache-tomcat-8.0.33\endorsed
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dfile.encoding=Cp1252
dez 04, 2016 6:20:57 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_101\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk1.8.0_65/bin/../jre/bin/server;C:/Program Files/Java/jdk1.8.0_65/bin/../jre/bin;C:/Program Files/Java/jdk1.8.0_65/bin/../jre/lib/amd64;;%JAVA_HOME%\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\nodejs\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;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\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 (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Skype\Phone\;C:\Ruby22-x64\bin;C:\Program Files\Java\jdk1.8.0_65\bin;C:\Users\User\AppData\Roaming\npm;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\User\AppData\Local\Microsoft\WindowsApps;;C:\Users\User\Downloads\eclipse;;.
dez 04, 2016 6:20:57 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["http-nio-8080"]
dez 04, 2016 6:20:57 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
dez 04, 2016 6:20:57 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-nio-8009"]
dez 04, 2016 6:20:57 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFORMAÇÕES: Using a shared selector for servlet write/read
dez 04, 2016 6:20:57 PM org.apache.catalina.startup.Catalina load
INFORMAÇÕES: Initialization processed in 1256 ms
dez 04, 2016 6:20:57 PM org.apache.catalina.core.StandardService startInternal
INFORMAÇÕES: Starting service Catalina
dez 04, 2016 6:20:57 PM org.apache.catalina.core.StandardEngine startInternal
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/8.0.33
dez 04, 2016 6:20:58 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.
dez 04, 2016 6:21:02 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.
dez 04, 2016 6:21:03 PM org.jboss.weld.environment.servlet.EnhancedListener onStartup
INFO: WELD-ENV-001008: Initialize Weld using ServletContainerInitializer
dez 04, 2016 6:21:03 PM org.jboss.weld.bootstrap.WeldStartup <clinit>
INFO: WELD-000900: 2.3.5 (Final)
dez 04, 2016 6:21:03 PM
 org.jboss.weld.environment.servlet.WeldServletLifecycle initialize
INFO: WELD-ENV-000028: Weld initialization skipped - no bean archive found
dez 04, 2016 6:21:03 PM org.jboss.weld.environment.servlet.Listener contextInitialized
INFO: WELD-ENV-001007: Initialize Weld using ServletContextListener
dez 04, 2016 6:21:03 PM org.jboss.weld.environment.servlet.WeldServletLifecycle initialize
INFO: WELD-ENV-000028: Weld initialization skipped - no bean archive found
dez 04, 2016 6:21:03 PM org.apache.catalina.core.StandardContext listenerStart
GRAVE: Exception sending context initialized event to listener instance of class org.jboss.weld.environment.servlet.Listener
java.lang.IllegalStateException: Singleton not set for STATIC_INSTANCE => []
    at org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider$RegistrySingleton.get(RegistrySingletonProvider.java:28)
    at org.jboss.weld.Container.instance(Container.java:55)
    at org.jboss.weld.SimpleCDI.<init>(SimpleCDI.java:77)
    at org.jboss.weld.environment.WeldProvider$EnvironmentCDI.<init>(WeldProvider.java:45)
    at org.jboss.weld.environment.WeldProvider.getCDI(WeldProvider.java:61)
    at javax.enterprise.inject.spi.CDI.current(CDI.java:60)
    at org.jboss.weld.servlet.WeldInitialListener.contextInitialized(WeldInitialListener.java:94)
    at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.contextInitialized(ForwardingServletListener.java:34)
    at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:122)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

dez 04, 2016 6:21:03 PM com.sun.faces.config.ConfigureListener contextInitialized
INFORMAÇÕES: Inicializando Mojarra 2.2.13 ( 20160203-1910 unable to get svn info) para o contexto '/livraria'
dez 04, 2016 6:21:03 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFORMAÇÕES: JSF1048: Anotações PostConstruct/PreDestroy presentes.  Os métodos ManagedBeans marcados com essas anotações informarão as anotações processadas.
dez 04, 2016 6:21:04 PM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 4.3.0.Final
dez 04, 2016 6:21:05 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFORMAÇÕES: Running on PrimeFaces 5.3
dez 04, 2016 6:21:05 PM org.apache.catalina.core.StandardContext startInternal
GRAVE: One or more listeners failed to start. Full details will be found in the appropriate container log file
dez 04, 2016 6:21:05 PM org.apache.catalina.core.StandardContext startInternal
GRAVE: Context [/livraria] startup failed due to previous errors
dez 04, 2016 6:21:05 PM org.apache.catalina.core.StandardContext listenerStop
GRAVE: Exception sending context destroyed event to listener instance of class org.jboss.weld.environment.servlet.Listener
java.lang.NullPointerException
    at org.jboss.weld.servlet.WeldInitialListener.contextDestroyed(WeldInitialListener.java:119)
    at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.contextDestroyed(ForwardingServletListener.java:30)
    at org.jboss.weld.environment.servlet.Listener.contextDestroyed(Listener.java:127)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4858)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5474)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:224)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:159)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

dez 04, 2016 6:21:05 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["http-nio-8080"]
dez 04, 2016 6:21:05 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["ajp-nio-8009"]
dez 04, 2016 6:21:05 PM org.apache.catalina.startup.Catalina start
INFORMAÇÕES: Server startup in 8070 ms

Vamos lá Renato,

O arquivo beans.xml que você moveu para META-INF foi no projeto da biblioteca ou o projeto web?

Se for no projeto web pode deixar dentro de WEB-INF mesmo, somente no projeto da biblioteca que deve ficar em src/main/resources/META-INF.

Manda o código da sua LivroBean por favor.

Outra coisa que eu acabei esquecendo de perguntar você, desabilitou a resolução de dependência dentro do workspace ?

Fernando,

Recoloquei o arquivo beans.xml no diretório WEB-INF do projeto web. A resolução de dependências está desabilitada sim.

Segue minha classe LivroBean:

package br.com.alura.livraria.bean;

import java.io.Serializable;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;

import br.com.alura.alura_lib.dao.DAO;
import br.com.alura.livraria.modelo.Autor;
import br.com.alura.livraria.modelo.Livro;

@Named
@ViewScoped
public class LivroBean implements Serializable {

    private static final long serialVersionUID = 1L;

    private Livro livro = new Livro();

    private Integer autorId;

    private List<Livro> livros;

    private DAO<Autor> autorDao;

    private DAO<Livro> livroDao;

    @Inject
    public LivroBean(DAO<Livro> livroDao, DAO<Autor> autorDao){
        this.livroDao = livroDao;
        this.autorDao = autorDao;
    }

    public void setAutorId(Integer autorId) {
        this.autorId = autorId;
    }

    public Integer getAutorId() {
        return autorId;
    }

    public Livro getLivro() {
        return livro;
    }

    public List<Livro> getLivros() {

        if(this.livros == null) {
            this.livros = livroDao.listaTodos();
        }
        return livros;
    }

    public List<Autor> getAutores() {
        return autorDao.listaTodos();
    }

    public List<Autor> getAutoresDoLivro() {
        return this.livro.getAutores();
    }

    public void carregarLivroPelaId() {
        this.livro = livroDao.buscaPorId(this.livro.getId()); 
    }

    public void gravarAutor() {
        Autor autor = autorDao.buscaPorId(this.autorId);
        this.livro.adicionaAutor(autor);
        System.out.println("Escrito por: " + autor.getNome());
    }

    public void gravar() {
        System.out.println("Gravando livro " + this.livro.getTitulo());

        if (livro.getAutores().isEmpty()) {
            FacesContext.getCurrentInstance().addMessage("autor",
                    new FacesMessage("Livro deve ter pelo menos um Autor."));
            return;
        }


        if(this.livro.getId() == null) {
            livroDao.adiciona(this.livro);
            this.livros = livroDao.listaTodos();
        } else {
            livroDao.atualiza(this.livro);
        }

        this.livro = new Livro();
    }

    public void remover(Livro livro) {
        System.out.println("Removendo livro");
        livroDao.remove(livro);
        this.livros = livroDao.listaTodos();
    }

    public void removerAutorDoLivro(Autor autor) {
        this.livro.removeAutor(autor);
    }

    public void carregar(Livro livro) {
        System.out.println("Carregando livro");
        this.livro = livro;
    }

    public String formAutor() {
        System.out.println("Chamanda do formulário do Autor.");
        return "autor?faces-redirect=true";
    }

    public void comecaComDigitoUm(FacesContext fc, UIComponent component,
            Object value) throws ValidatorException {

        String valor = value.toString();
        if (!valor.startsWith("1")) {
            throw new ValidatorException(new FacesMessage(
                    "ISBN deveria começar com 1"));
        }

    }
}

Cara tem como mandar o beans.xml por favor?

Fernando,

Segue:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       version="1.2" bean-discovery-mode="all">

    <!-- some content -->
</beans>`

Fala aí Renato,

As suas configurações aparentemente estão todas corretas.

Esse beans.xml que você me enviou é do projeto alura_lib ou do projeto livraria?

Renato tem como postar seu projeto no Github? Assim fica mais fácil de eu conseguir verificar o problema.

Valeu!

Fala Fernando. Tudo certo?

Obrigado pelo retorno.

Seguem os projetos:

https://github.com/RenatoFrancisco/alura-lib.git

https://github.com/RenatoFrancisco/livraria.git

Abraços!

solução!

Fala aí Renato blz?

Cara dei uma olhada no seu projeto e vi que tem algumas coisas conflitantes,

No seu projeto alura-lib você tem as Classes DAO e JPAFactory para produzir EntityManager.

E no seu projeto livraria você tem a mesma classe DAO e a classe JPAUtil que também produz EntityManger.

Tente excluir as classes que eu mencionei do projeto livraria e veja se corrige o erro .

Fernando, blz?

Cara, olhei o meu projeto no Eclipse e no meu Workspace, as classes DAO e JPAUtil NÃO estão no projeto livraria. Mas por algum motivo que desconheço elas subiram para o github como se fizessem parte do projeto livraria. Bom, vou seguir o curso sem usar o alura-lib por enquanto, ou seja, vou mover todos as classes necessárias para livraria. Mas muito obrigado pela disposição em ajudar. Abraços.