google drive java in the cloud - java

I followed this tutorial on how to connect to google drive. I took some liberty with using maven instead of gradle and a few details, but it worked. I inserted the relevant code into war file and deployed it in my localhost and it worked on the server. However, when I deployed the same war into google compute engine, it didn't work. Obviously it is because of this line.
Credential credential = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("user");
I guess it invokes the authorization procedure on the machine of the tomcat, not user. I would expect there to be a way to deploy such a solution on web server, but I did not find it.
I think about moving my authorization to JS, and pass the token to backend, but that does not seem a good practise for me.
Regards

I kept digging in the Internet for a while and found class
com.google.api.client.extensions.servlet.auth.oauth2.AbstractAuthorizationCodeServlet (and AbstractAuthorizationCodeCallbackServlet from the same package).
Weird it was nowhere in the google tutorials. It is quite close to what I need, so I keep working on it.
For everyone interested in the matter:
It seems that google authorizations don't like external IP addresses, so I need to set up domain properly, but that is another story.

Related

Deploying a Java web application to Amazon

I am sure this question has been asked and answered before multiple times. But unfortunately, I am still not clear. Here is my issue.
I have a JSP, Servlet application which uses MySQL as the database. I have built the WAR file as well. Now I am in need of deploying this so it can be accessed online by anyone.
I looked into lot of areas including normal web hosting. However even though the services like DailyReazor are highly secured, they provide little for MySQL, around 250 MB for the package I selected.
Now I am looking into Amazon AWS. In AWS I am expecting to deploy my aplication and make it available online.The MySQL server should not contain limits like 250MB.
But I have never ever used this service AWS before. By reading various posts, I know that Elastic Beanstalk is the easiest way to go, but still not convinced about how to deploy it properly with database access and all. And in the other hand, will they give me a web address like "www.example.com" or will they simply provide an IP address?? I am also familiar with tomcat so I need to use it.
We will not upload files (images etc) at the moment, so I believe we can manage with around 20$ per month?
I really appreciate if someone can provide a clear guidance on deploying java web applications in Amazon, with the requirements I mentioned about MySQL, Global access and so on.
Amazon RDS for MySQL is a Database-as-a-service offerring from AWS. It is scaleable up to 3TB, and has scaleable IO as well. Of course it also depends on how much you prepared to pay. they manage the DB for you (backup etc). You get a URL to connect, credentials and you are set to go.
Amazon Elastic Beanstalk uses Tomcat. So you should be familiar with that. You upload your WAR file and specify what EC2 flavor you want (CPU/MEM etc). They launch a VM that is configured with Jva and Tomcat and deploy the WAR for you. You get an IP address.
Amazon Route 53 is the DNS service, where you can assign the IP address to your domain (assuming you have one)

How can New Relic keep my Java site up?

Is it possible to use New Relic on my Java site? I built it with JHipster Yeoman generator and deployed the WAR file to Heroku. I setup New Relic. I looked at the default policy. It appears to have a pinging service, but I am wondering if I have to do something in addition to keep my site up. Maybe create a route for the pinging service?
From looking at the Jhipster site, it says it creates a Spring boot backend: https://jhipster.github.io/
Providing the version of spring used is v3 or v4 it should work. (I was unable to verify what version boot actually uses)
https://docs.newrelic.com/docs/agents/java-agent/getting-started/new-relic-java
This looks like it should work to me, trying it is the only way to know for sure. Here is the heroku-newrelic-java install doc:
https://devcenter.heroku.com/articles/newrelic#java-installation-and-configuration
The ping service will attempt to connect to your site over http/https from external locations, to verify that it can be reached. You shouldn't need to do any additional configuration on your site.

Deploying java coded server jar on web

I have coded a Jersey based java server which is all wrapped in one excecutable jar.
I am looking for a web host service in which i can deploy the jar and run it.
I saw some dedicated servers which can do this but this is overshooting the need, any suggestions?
As per your comment I understand that you created a web application with a Jetty embedded server.
I think the best solution for you in this case is to get a virtual machine host, install JRE, upload your *.jar and run it from there. Given firewall permissions and correct configuration you should be able to receive requests on the 80 port. Cons? It costs. A lot.
Most of the Java hosts have already a servlet container running (almost always Tomcat) and you can only deploy your web application in it. Having an embedded Jetty server messes up everything for you.
I strongly suggest you to detach your web application (or as you called it REST server) from Jetty and deploy the *.war in any of the multiple free Java hosts to test it online.
EDIT
Thanks to you I made a deeper research on the topic and found an interesting guide to deploy a web application with embedded Jetty server in Heroku. I've never tried it nor I know if its free, but maybe you can give a try.
Digital Ocean work pretty well for me. Their basic packages are really cheap and you get root control over your own machine, meaning you can host whatever you want without restrictions. The only downside is that they are pretty old school - you have to set up EVERYTHING yourself, including firewalls etc. There are a lot of guides available on their website though, which makes life a lot easier!
http://www.digitalocean.com
I know this is a touch redundant but I don't have voting or comment rights yet so this is the only method for me to communicate.
Digital Ocean is a solid choice. I am paying 5$ a month for a VM with 512 Mb Ram and 20 gigs of storage (which for my use is just fine.) I am still working on my first proper deploy but as stated above there are tons of tutorials to guide you through it. I have no prior command line experience but I've managed to get the server running, Created an SSH key, uploaded my landing page and have gotten a test project using Spark as the embedded server up and functional in a matter of a few hours. The Droplets are easily scalable from what I've seen. I'm still having trouble deploying an Rest based app with Postgres as the DB but it seems more to do with the ports in play than anything else. Keep getting 404s.

Taking local Jersey REST service to openshift

I have a REST service, that uses Jersey, deployed on my local machine. The service does not use an ORM. Instead, it uses the JDBC driver to populate models from my MYSQL database. Everything is working as expected and now, I would like to deploy my service onto Openshift. I have read up on how Openshift works and I'm a little confused. I do not have any experience with GIT, so I found myself getting lost when the Openshift website told me to push my application to their servers via GIT.
I am looking to have my REST service, as well as MYSQL database moved to the Openshift server without making changes to my existing code. This is my first time deploying a web service on something other than localhost so any leads, regarding what to do research on to get what I want would be very much appreciated.
I've been using OpenShift to host some personal projects, and I can feel your pain when you get a little lost with how to do it. I had been using Git for awhile though so that helped.
This page. is what helped me get the tools set up for git correctly. They require ruby, and node, so you'll have to install those as well. Once you get everything set up though, you'll basically "Clone" the repository that open shift gives you which will create a local instance of the repositories contents in your computer. You can then use the commands "git add", "git commit" and "git push" which will push your changes back up to their server.
Good instructions exist on this page describing what I just told you. From what you said it looks like you've completed steps 1 + 2, but steps 3 and 4 are still left. You have to have your command line tools set up first however. Let me know if it helps!

Google App Engine tutorial questions

I am interested in importing Google contacts into my web-application.
I have gone through some of the Google App Engine tutorials on youtube and I have the following questions.
http://www.youtube.com/watch?v=tVIIgcIqoPw
(the above tutorial, my question are applicable to any google api)
In the tutorial they are using "Google plugin for eclipse" to build and deploy the application on to the App Engine.
I know I can deploy it on the local machine (for development purpose), but can I use Tomcat for deploying this.
When I use my local machine for development, how to configure OAuth2 redirect URL. The reason I am confused with this is because the application will deployed on the local machine. Will it mean I cannot use OAuth2 redirect URL will developing?
Your help will be greatly appreciated...
You are mixing things up and reading unrelated tutorials. Gae tutorials are about gae not a random deployment to something else like tomcat.
Look at the contacts api directly. There are also many tutorials on how to do oauth for a client app.

Categories