play2war / play2-war-plugin

WAR Plugin for Play framework 2.x
Apache License 2.0
443 stars 71 forks source link

play2 tomcat war not deploying #307

Open mateobadillo opened 8 years ago

mateobadillo commented 8 years ago

Hi i'm having an issue trying to deploy a war file with the war plugin on tomcat 8

parameters:

java play 2.5.x tomcat 8 java 8

plugins.sbt:

// The Play plugin addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.4-beta1")

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.0")

// Web plugins addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0") addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0") addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3") addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7") addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0") addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0") addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.2") addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.0")

// Play enhancer - this automatically generates getters/setters for public fields // and rewrites accessors of these fields to use the getters/setters. Remove this // plugin if you prefer not to have this feature, or disable on a per project // basis using disablePlugins(PlayEnhancer) in your build.sbt addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using // enablePlugins(PlayEbean). // addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")

build.sbt:

import com.github.play2war.plugin._

name := """AuditoriaCip"""

version := "1.0-SNAPSHOT"

Play2WarPlugin.play2WarSettings Play2WarKeys.servletVersion := "3.1"

lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)

scalaVersion := "2.11.7"

libraryDependencies ++= Seq( javaJdbc, cache, "mysql" % "mysql-connector-java" % "5.1.38", "org.avaje.ebeanorm" % "avaje-ebeanorm" % "6.8.1", javaWs )

fork in run := true

this is the localhost.log file when i try to start de application:

16-Mar-2016 13:35:49.768 INFO [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationContext.log PlayServletWrapper > contextDestroyed
16-Mar-2016 13:35:49.769 SEVERE [http-nio-8080-exec-1] org.apache.catalina.core.StandardContext.listenerStop Exception sending context destroyed event to listener instance of class play.core.server.servlet30.Play2Servlet
 java.lang.NoClassDefFoundError: Could not initialize class play.core.server.servlet.Play2WarServer$
    at play.core.server.servlet.GenericPlay2Servlet.contextDestroyed(GenericPlay2Servlet.scala:51)
    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:224)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:159)
    at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1293)
    at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:666)
    at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:217)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
dlecan commented 8 years ago

Play 2.5 is not supported yet. Can you try with Play 2.4.x ?

mateobadillo commented 8 years ago

Thx very much for your quickly response!

so i changed plugins.sbt to versio 2.4.4:

// The Play plugin addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.4-beta1")

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.4")

// Web plugins addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0") addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0") addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3") addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7") addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0") addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0") addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.2") addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.0")

// Play enhancer - this automatically generates getters/setters for public fields // and rewrites accessors of these fields to use the getters/setters. Remove this // plugin if you prefer not to have this feature, or disable on a per project // basis using disablePlugins(PlayEnhancer) in your build.sbt addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using // enablePlugins(PlayEbean). // addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")

The error continues localhost.log:

16-Mar-2016 15:51:36.116 INFO [http-nio-8080-exec-5] org.apache.catalina.core.ApplicationContext.log PlayServletWrapper > contextDestroyed
16-Mar-2016 15:51:36.116 SEVERE [http-nio-8080-exec-5] org.apache.catalina.core.StandardContext.listenerStop Exception sending context destroyed event to listener instance of class play.core.server.servlet31.Play2Servlet
 java.lang.NoClassDefFoundError: Could not initialize class play.core.server.servlet.Play2WarServer$
    at play.core.server.servlet.GenericPlay2Servlet.contextDestroyed(GenericPlay2Servlet.scala:51)
    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:224)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:159)
    at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1293)
    at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:666)
    at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:217)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
dlecan commented 8 years ago

When do you have this stacktrace ? When Tomcat shutdowns ?

mateobadillo commented 8 years ago

when i start the Tomcat, the .war is inside the webapps directory

mateobadillo commented 8 years ago

so i tried with tomcat 7, but the error persist, y changed the servletVersion to 3.0.

This is the error that appears in the Catalina.out when i try to deploy

Mar 17, 2016 8:56:12 AM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile INFO: validateJarFile(/Users/mateobadillo/Desktop/IBM/apache-tomcat-7.0.68/webapps/consultarApp/WEB-INF/lib/javax.el.javax.el-api-3.0.0.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class Mar 17, 2016 8:56:12 AM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile INFO: validateJarFile(/Users/mateobadillo/Desktop/IBM/apache-tomcat-7.0.68/webapps/consultarApp/WEB-INF/lib/org.apache.tomcat.tomcat-servlet-api-8.0.32.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class Mar 17, 2016 8:56:15 AM org.apache.catalina.startup.TldConfig execute INFO: 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. Mar 17, 2016 8:56:15 AM org.apache.catalina.core.StandardContext startInternal SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file Mar 17, 2016 8:56:15 AM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/consultarApp] startup failed due to previous errors Mar 17, 2016 8:56:15 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads SEVERE: The web application [/consultarApp] appears to have started a thread named [AsyncAppender-Worker-ASYNCFILE] but has failed to stop it. This is very likely to create a memory leak. Mar 17, 2016 8:56:15 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads SEVERE: The web application [/consultarApp] appears to have started a thread named [AsyncAppender-Worker-ASYNCSTDOUT] but has failed to stop it. This is very likely to create a memory leak.

pawitk commented 8 years ago

I have also found the same error, doing the exact same process (initially started with 2.5.x, then downgrading to 2.4.6). Below are the config files and stacktrace:

Current stack:

plugins.sbt

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.6")

// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
addSbtPlugin("org.irundaia.sbt" % "sbt-sassify" % "1.4.2")
addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.4-beta1")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.0")

// Play enhancer - this automatically generates getters/setters for public fields
// and rewrites accessors of these fields to use the getters/setters. Remove this
// plugin if you prefer not to have this feature, or disable on a per project
// basis using disablePlugins(PlayEnhancer) in your build.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
// enablePlugins(PlayEbean).
// addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")

build.sbt

import com.github.play2war.plugin._

name := """TestPlayApplication"""

version := "1.0.0-SNAPSHOT"

Play2WarPlugin.play2WarSettings

Play2WarKeys.servletVersion := "3.0"

lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)

scalaVersion := "2.11.7"

libraryDependencies ++= Seq(
  javaJdbc,
  jdbc,
  "org.postgresql" % "postgresql" % "9.4-1206-jdbc42",
  "org.mindrot" % "jbcrypt" % "0.3m",
  cache,
  javaWs
)

fork in run := true

application log

Apr 16, 2016 7:32:44 AM org.apache.catalina.core.StandardContext filterStop
FINE: Stopping filters
Apr 16, 2016 7:32:44 AM org.apache.catalina.core.ApplicationContext log
INFO: PlayServletWrapper > contextDestroyed
Apr 16, 2016 7:32:44 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class play.core.server.servlet30.Play2Servlet
java.lang.NoClassDefFoundError: Could not initialize class play.core.server.servlet.Play2WarServer$
    at play.core.server.servlet.GenericPlay2Servlet.contextDestroyed(GenericPlay2Servlet.scala:51)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5115)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5779)
    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.addChildInternal(ContainerBase.java:899)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    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)

Any help or hint will be greatly appreciated :)

pevers commented 8 years ago

Any news on this issue? I'm facing the same problem as @pawitk

pawitk commented 8 years ago

@pevers

Sorry, it's been a while, and my memory's fuzzy, but here's a gist of what I did to get it to work.

I remember creating a new play 2.4.6 project and moving my code over. From this, i discovered that some classes were using ebean syntax compatible with only 2.5. After another thorough code cleanup, and more debugging, it finally worked.

Wish I could be more specific, but due to time constraints, I didn't document my method. Hope you don't have to go through what I did.

pevers commented 8 years ago

@pawitk thanks! I'll give it a try!

pevers commented 8 years ago

I figured it out, I was still polluting the project with Play 2.5 specific code. There is a small issue with newly introduced logging in Play 2.5 that is not yet in play2war. See:

https://www.playframework.com/documentation/2.5.x/Migration25

My code was also referencing to cached Play 2.5 code that caused more problems.