Scala and play 2 framework hosting what are the requirements - scala

I am new to scala and play 2 framework and would like to know if they can be hosted on a webhost that has Tomcat, JSP, and Java Servlet hosting. I would obviously include the scala files.

Per the documentation, all you need on your server is JRE6 or later. Play does not use Tomcat, JSP or Java Servlets. Play will create a standalone distribution for you with the play dist command. Copy that to a server with Java installed and you're ready to go.
https://www.playframework.com/documentation/2.3.x/ProductionDist

Related

How to deploy a Scala Play framework API using the SBT native packager

I created a web API based on the Scala Play framework 2. In the past I generated war files using a SBT plugin in order to deploy in production using Tomcat. It is now possible to build native package from Play project using the SBT native packager plugin. I used it to generate a debian package from my web app.
However, I don't understand how it works. I could generate and install the debian package and start the daemon, but my API seems not listening request.
In the first case, Tomcat hosts the war file which contains the Play app and manages the HTTP connection. I have the feeling that there are missing parts in my debian package in order to work properly like the war file under Tomcat.
The question is, how can I use the native packager plugin to deploy a standalone HTTP API? What is responsible to handle HTTP connection? What is missing in my project?
Thanks in advance
Play applications run using their own light weight http server.
To build a standalone project issue
sbt dist
or if your using activator
activator dist
This makes a directory target/universal/your-app.zip
If you unzip the contents you will find a standalone application structure
/bin
/lib
/conf
/share
under which you can find shellscripts that launch the server
bin/your-app
bin/your-app.bat (windows)
The distribution to a war file appears to have been removed from play. Similar question asked here:
Deploy play as a war file into a servlet container, even if it uses JPA heavily?

framework play 2.2.1 Jboss

I can't deploy a play application framework 2.2.1 in JBoss.
I must do an application that communicates with EJBs and deploy into the same application server JBOSS.
the only way I have found is to use the start command.
You have to use the play war plugin, that will allow you to package your play app as a regular java web archive.
You can find the project here: https://github.com/dlecan/play2-war-plugin

Build tool for Scala web application development

While working with Scala frameworks such as Play! and Lift I was really amazed how these frameworks manage to create a full development stack from the source code up to the web application container (Jetty).
Right now I'm trying to configure a project on my own with the following features:
Automatic deployment on Tomcat 7 (I'm not using Jetty as I require JEE6 support)
WAR file packaging
Is it possible to do it with a build tool such as SBT or Maven?
Note: My goal is to create my own project structure, not using an existing framework (even though I'm taking some ideas from them).
There is a web plugin for SBT:
https://github.com/JamesEarlDouglas/xsbt-web-plugin
It gives you war packaging, but not automatic deployment (other than on Jetty, which it integrates, but which you don't have to use).
That said, I'd like to see a fork of that plugin that removes the Jetty dependency and adds an automatic external deployment option. Shouldn't be too hard to do.

how to run the servlet in eclipse?

I want to run a servlet in Eclipse. For this I have created a dynamic web project and I have deployed my servlet.java file under the WEB-INF folder. I have also added the servlet.jar file. How can I run the file as a java application?
Servlets run in a servletcontainer. Servlets are not "plain vanilla" java applications. See, they do not have a main() method! Servlets listens on HTTP requests and returns HTTP responses through the network. Running the sole servlet class as a plain vanilla Java application doesn't automagically make them to listen and react on HTTP requests.
Apache Tomcat is a popular servletcontainer. Just download and unzip it. Then in Eclipse (I assume that you already have downloaded the Eclipse Java EE version, else drop it all together and redownload the right version), go to Servers view and add the newly installed Tomcat instance. Then create a Dynamic Web Project wherein you pick the newly integrated server instance from the list. Eclipse will then automatically take the Servlet API libraries in the classpath/buildpath (thus, you do NOT need to download a random "servlet.jar file" separately yourself! this is only receipt for major trouble). Then create a Servlet class and register it in web.xml. Then deploy the project to the newly integrated server and start it. Then in your favourite webbrowser go to http://hostname:port/contextname which is usually http://localhost:8080/webprojectname.
To learn more about servlets (and Eclipse and Tomcat) I strongly recommend you to go through those tutorials. You can also search on youtube for video tutorials using the obvious keywords.
Servlets run in servlet/JSP engines, like Tomcat or Resin or Jetty. You normally don't run them outside a container.
You can certainly deploy your app to a servlet/JSP engine and start in from Eclipse. But it's the app server that you run, which then acts as the home for your servlet.
Servlets cannot be run directly as an Java app.
I recommend two approaches:
Refactor your servlet and put your "java" code (what ever generic code you want to call) in another jar that you call from both the servlet and the Java application.
Run the servlet in a container in Eclipse. See http://www.eclipse.org/jetty/
Communicate with the servlet through HttpRequest's and HttpResponse's

How to create stand-alone lift web application?

How to make a standalone lift application? Which tools/libraries to use? How does the performance compare to using lift application as a war in some application server?
With onejar maven plugin http://onejar-maven-plugin.googlecode.com/svn/mavensite/usage.html and maven I could package jetty and project with dependencies inside one jar.
The part of the question on performance doesn't really fit with the rest. You are primarily asking how to package the Lift application as a single JAR/WAR. This doesn't have anything to do with the runtime.
At runtime you will still be running inside a Servlet container (could be Jetty, Tomcat or a full-blown Java EE server). How you package your application won't affect the performance.
You could take a look at Hudson (a great Continuous Integration Server) to see how they deliver as a single WAR file that contains an embedded Servlet container. You can download the WAR file and run it from the command line: java -jar hudson.war
I know this is an old question, but...
If you are using sbt, I wrote a plugin to produce 'executable' wars like those mentioned above.
https://github.com/glenford/sbt-jetty-embed