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

Erro ao startar sistema (feito com VRaptor) nos moldes do Heroku com Tomcat 8 ( embedded ou webapp-runner) - causa aparente: plugin vraptor-jpa

Boa tarde.

Estou tentando startar um sistema em vraptor com tomcat 8 nos moldes do Heroku (tomcat embedded ou usando o webapp-runner). Para evitar riscos de erros, comecei a fazer testes a partir do blank-project do vraptor e para cada teste fiz as devidas alterações num pom.xml isolado (um para tomcat embedded e outro para o runner). Agora o problema: ao habilitar o plugin vraptor-jpa ocorrem erros ao startar a aplicação (a fase package (do maven) passa com sucesso).

O erro gerado nas duas formas é o mesmo. Segue a coisarada:

17:14:57,053  INFO [Tomcat7Container    ] Tomcat 7+ detected, CDI injection will be available in Servlets and Filters. Injection into Listeners is not supported
nov 11, 2016 5:14:57 PM org.apache.catalina.core.StandardContext listenerStart
GRAVE: Exception sending context initialized event to listener instance of class org.jboss.weld.environment.servlet.Listener
org.jboss.weld.exceptions.DeploymentException: javax/persistence/EntityTransaction
    at org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:66)
    at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:43)
    at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:51)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.createClassBeans(ConcurrentBeanDeployer.java:72)
    at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:260)
    at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:351)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:79)
    at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:170)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    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(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: java.lang.NoClassDefFoundError: javax/persistence/EntityTransaction
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethods(Class.java:1975)
    at java.lang.Class.getEnclosingMethod(Class.java:1045)
    at org.jboss.weld.util.reflection.Reflections.isNonStaticInnerClass(Reflections.java:388)
    at org.jboss.weld.util.Beans.isTypeManagedBeanOrDecoratorOrInterceptor(Beans.java:486)
    at org.jboss.weld.bootstrap.BeanDeployer.createClassBean(BeanDeployer.java:233)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:74)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:72)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
    ... 4 more
Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityTransaction
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
    ... 15 more

nov 11, 2016 5:14:57 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
nov 11, 2016 5:14:57 PM org.apache.catalina.core.StandardContext startInternal
GRAVE: Context [] startup failed due to previous errors
SEVERE: Context [] failed in [org.apache.catalina.core.StandardContext] lifecycle. Allowing Tomcat to shutdown.
nov 11, 2016 5:14:57 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:120)
    at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.contextDestroyed(ForwardingServletListener.java:30)
    at org.jboss.weld.environment.servlet.Listener.contextDestroyed(Listener.java:85)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4859)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
    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(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)

Com o runner:

$ java -jar target/dependency/webapp-runner.jar target/*.war

https://devcenter.heroku.com/articles/java-webapp-runner

-

Com o tomcat embedded:

$ sh target/bin/webapp

https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat

P.S:

Eu to apavorado com o tempo que já perdi pra acertar o deploy do sistema. Subestimei essa etapa e me arrependo profundamente. Dica para quem estiver começando no ambiente java web (assim como eu) – não subestime o deploy!

4 respostas

Opa, esse problema tem cara de ser versão incompatível entre o esperado pelo plugin e o que vc definiu para o projeto, tenta olhar isso :).

solução!

Oi Rodrigo

Me parece que faltou adicionar o JPA aí no seu pom, além do plugin:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.3.0.Final</version>
</dependency>

Experimenta adicionar e subir novamente?

Bahh...

E depois o culpado é o vraptor-jpa, rsrsr

Muito obrigado senhores!

Ufa, que bom que funcionou!

Rodrigo, se quiser, você também pode se basear no projeto de exemplo do VRaptor:

o vraptor-musicdot

https://github.com/caelum/vraptor4/tree/master/vraptor-musicjungle

Só depois me dei conta que ele tem um setup bastante parecido com o seu.