Reputation: 4231
I am trying to deploy my app on tomcat. I am getting to my index.html but my API respond
404 not found
And I can't figure out what am I doing wrong
this is my service actor
class DemoRoute extends Actor with DemoRouteService {
implicit def actorRefFactory: ActorContext = context
def receive = runRoute(route)
}
trait DemoRouteService extends HttpService{
val route = {
import com.tr.em.domain.JsonImplicits._
path("foo"/"status"){
get{
complete("I feel good, thanks for checking")
}
}
}
}
This my web.xml
<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<listener>
<listener-class>spray.servlet.Initializer</listener-class>
</listener>
<servlet>
<servlet-name>SprayConnectorServlet</servlet-name>
<servlet-class>spray.servlet.Servlet30ConnectorServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>SprayConnectorServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
this is my application.conf
akka {
loglevel = INFO
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
}
spray.servlet {
boot-class = "com.tr.em.SprayBoot"
request-timeout = 10s
}
this is my boot class
import spray.servlet.WebBoot
import akka.actor.ActorSystem
import akka.actor.Props
class SprayBoot extends WebBoot {
val system = ActorSystem("systemactor")
val serviceActor = system.actorOf(Props[DemoRoute])
system.registerOnTermination {
system.log.info("Application shut down")
}
}
Upvotes: 0
Views: 396
Reputation: 4231
Solved. it was a kind of a race condition . had to add logs to see the real error . anyway I had to add define the service actor as lazy
lazy val serviceActor = system.actorOf(Props[DemoRoute])
Upvotes: 0
Reputation: 12024
From spray-servlet documentation
# The class must have a constructor with a single #
javax.servlet.ServletContext
parameter and implement # thespray.servlet.WebBoot
trait.boot-class = ""
Looks like your class does not have appropriate constructor
Upvotes: 1