How to have Play 2.0 Framework ignore routes - scala

Building a Play 2.0 scala app and deploying it to the ROOT context on Tomcat (from what I understand, a Play app must be deployed to ROOT context). There are other web apps running on this server at different contexts, but with the Play app at root, it is intercepting every request and failing if it is a route it does not understand.
Is there any way to have Play ignore a route in order to have Tomcat continue dispatching it to a servlet that is registered for that context?
thanks,
brian

In fact the limitation you have seams to be linked to sub-context deploiement. The play2 war plugin does not support it until Play 2.1
It could be possible to trick with tomcat conf to do what you want. I don't know tomcat enough to give you the right conf.
You can still deploy your Play app as a standalone app (not embedded in Tomcat) and use a front-end HTTP server to handle reverse-proxy to the right HTTP server. You will have to define for each HTTP server the right port to run on and then configure your reverse-proxy to route the request depending on the domain/port to the right local port. I use Nginx for that. Maybe Tomcat can handle this also.

Actually, it turns out that this was not a problem after all. I had inadvertently not had the other apps deployed in the same tomcat server I was testing with (doh!). Once I deployed them properly, then the Play Framework app got the requests that were correctly bound for it and the other apps got the requests that were bound for them in the sub-contexts. So, false alarm.

Related

GWT 2.7 with Rest

We are building a project and will be using gwt 2.7 with rest ( spring) and weblogic server.
The problem which we face is that I want to run the gwt module on superdev mode (which runs on 8888 port by default) but the rest is deployed on 7001 port on weblogic server.
I cannot call the rest services from superdev mode as it gives a cross site scripting error.
How can get my super dev mode running so that I can test and develop UI and connect to rest services on different port.
I know there has been topic on use a different server for dev mode. But i don't see any examples.
Can some please suggest wat needs to be done. Even if it requires changing the project structure to get the dev mode working with rest.
This is a common problem for web-development. It can be solved by using:
CORS (at the REST server)
Using a proxy servlet (I use this approach, but with a handwritten servlet)
Disable the browser security (I would not do this)
did you try running GWT module on external server mode?

Play framework 2.3.x where do traffic logs get written?

I built my play application using
activator clean compile dist
I then extracted it to a folder and started the application using Play's integrated HTTP server
sudo ./appname -Dhttp.port=80
I then loaded it on localhost:80 and clicked around in it. My question is, where do the traffic logs from my session get written? Not the application logs, but the actual web traffic logs (like apache HTTP server traffic logs)?
Thanks in advance

How I can deploy my GWT application on www

I created my first Java EE application (GWT + Hibernate). I want deploy my application on a Tomcat web server.
Could you give me a step by step tutorial?
You can start with Google App Engine + GWT tutorial if you are trying out deploying into Google Cloud - https://developers.google.com/web-toolkit/doc/latest/tutorial/appengine
This question is massive so I will try to bring it down to some steps that need some research to implement.
1st. You created an application using GWT and Hibernate. That means that you need some kind of a web server that understands java and can re-write the logic from java to javascript (for the clientside), and also connect to the database on the serverside and retrieve the data for the client.
This web server is tomcat so what you need is:
A computer that will work as a server. This could be your own machine or some server you can buy as a hosting solution. Buying something like this requires research and effort on your part and cannot be explained here.
A version of Tomcat or Resin or any other web server that understands java
A domain name. These can be bought from sites like this one, but there are some free ones around the web. They require static ips that is you cannot use them from a home line that changes ips. Even without a domain name you can host your site on the server but you need to access it by writing the machine's ip instead. - optional - A temporary solution would be to use some kind of dynamic dns service on your router.
After having set up tomcat (you might want to give port 80 to tomcat) and the server you can host your application by uploading the war file. You can make a war file from gwt by following the instructions here
To upload the war file you can use the tomcat manager interface, or you can connect to the server and place it manually in the folder used for the web applications.
I know that each step propably needs as much if not more explanation by I hope I cleared the area a little bit here.

Best approach to integrate netty with openshift

In fact, I'm trying to see which would be the best approach to achieve play framework native support on openshift.
Play has it's own http server developed with netty. Right now you can deploy a play application to openshift, but you have to deploy it as a war, in which case play uses Servlet Container wrapper.
Being able to deploy it as a netty application would allow us to use some advanced features, like asynchronuos request.
Openshift uses jboss, so this question would also involve which would be the recommended approach to deploy a netty application on a jboss server, using netty instead of the servlet container provided by jboss.
Here is request for providing play framework native support on openshift There's more info there, and if you like it you can also add your vote ;-)
Start with creating 'raw-0.1' application.
SSH into the server and
cd $OPENSHIFT_DATA_DIR
download and install play into a directory here. $OPENSHIFT_DATA_DIR is supposed to survive redeploys of your application.
Now you can disconnect from SSH.
Clone the application repository. In the repository, there is a file .openshift/actions_hooks/start. It's task is to start the application using a framework of your choice. The file will need to contain at least (from what I know about Play)
cd $OPENSHIFT_REPO_DIR
$OPENSHIFT_DATA_DIR/play-directroy/play run --http.port=$OPENSHIFT_INTERNAL_PORT --some-other-parameters
Important
You have to bind to $OPENSHIFT_INTERNAL_IP:$OPENSHIFT_INTERNAL_PORT. Trying to bind to different interface is not allowed, also most of the ports are blocked.
To create some sort of template, save the installation steps into .openshift/action_hooks/build file. Check if play is installed, if it is do nothing, if it's not, execute the installation process.

Debugging a GWT app which needs access to an external resource (Same Origin Policy)

We have a GWT application which draws some resources from a separate servlet via async javascript. In production this poses no problems as both the producer servlet and the consumer GWT app will reside on the same server, however for development I can't find a way to make this happen as we are head to head with the Same Origin Policy.
As a temporary solution I have the servlet running on Tomcat, and I compile and deploy the GWT app to that same Tomcat instance - this of course works, and it does allow me to attach Eclipse for debugging. However there is the slight problem of the 40 second or so build time for each modification.
We would like to be able to debug via GWT's hosted mode w/ OOPHM - can anybody see a way for us to do this?
Thanks all!
you could use the -noserver option of gwt dev mode, which lets you run your server code with any servlet container.
Maybe you can deploy the producer servlet to Jetty.
http://www.enavigo.com/2008/08/29/deploying-a-web-application-to-jetty/
I think the Jetty home most reside somewhere in the Eclipse directories. A simple file search might help.
Good luck!
If you need just a servlet, why not define it in web.xml and start dev mode as usual?