running php and java on the same server - java

I have web services written using java which interacts with the android application only now we need to implement a front end web portal using php frame work codeigniter. We have common database mysql 5.1 which interacts with both the web services and also web portal, is it possible to configure the LAMP stack in a server which is already running tomcat6 servlet container but with out apache web server. How do I processed further and when Iwas search for same issuse I found something called php java bridge is that what I have to use??
Let me be more precise on this, I have ec2 ubuntu instance already running, domain is parked in godaddy, i have configured the A records with the ip of my ec2 instance, so when the requests comes in it will be directed to the application which is running in the tomcat6/webapps/ROOT but now I need to redirect it to the php application how do I do it and also requests from android should be directed to web services which are java based, how do I manage this?
Kindly help out

You can proxy requests to the tomcat server from Apache ... have two virtual hosts, one for the tomcat and one for the php ... all co-ordinated by apache.
http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
It is recommended that you also read the Workers HowTo document to learn how to setup the working entities between your web server and Tomcat Engines. For more detailed configuration information consult the Reference Guide for workers.properties, uriworkermap and Apache.

Related

Configuring Java Client for Hazelcast

I am trying to configure a JAVA client for Hazelcast. I have a web application deployed on tomcat servers. The example that I am following is this
Basic Clients Hazelcast. I have copied the code into my local machine and when I simply run it without running anything else and without the addAddress() step I get a java.net.ConnectionException. My doubts are:
1) What is the client in this case (I am assuming it is the web application that probably means I have to get the Hazelcast server up and running then what is to be done)?
2) How do I establish a link between the web app, the tomcat server and hazelcast cluster? The web app uses MongoDB as the backend. I was able to do a only MongoDB with Hazelcast integration but not the web app on tomcat server integration. What role does tomcat play here in this setup?
3) In the example what are the start.sh and stop.sh supposed to do? Where should I run them? If I simply open the git bash and run it. It doesn't seem to work.
I have looked at the documentation provided in the Hazelcast manual but I wasn't able to understand it as my current level of knowledge is woefully inadequate. If somebody could explain it to me or paste the links to some of the obvious stuff that I should know it would be great.
The answers are inline:
What is the client in this case(I am assuming it is the web
application that probably means I have to get the Hazelcast server up
and running then what is to be done)
The web application can be a Hazelcast client if you would like to use Hazelcast in client-server topology.
How do I establish a link between the web app, the tomcat server and
hazelcast cluster. The web app uses MongoDB as the backend. I was able
to do a only MongoDB with Hazelcast integration but not the web app on
tomcat server integration. What role does tomcat play here in this
setup.
Your web app runs in Tomcat server (web container) and the Hazelcast client you use in your web app can directly connect to the Hazelcast cluster members (server). You will just need to configure your client properly such as adding cluster member address by using clientConfig.getNetworkConfig().addAddress() API. Please see for more details about configuring client in this link: http://docs.hazelcast.org/docs/latest/manual/html-single/index.html#configuring-java-client
In the example what are the start.sh and stop.sh supposed to do.
Where should I run them. If I simply open the git bash and run it. It
doesnt seem to work.
Those are sample start scripts for the sample client and member application. You don't need to use them in your application.
Please see the following guides for using Hazelcast in client-server topology:
https://hazelcast.org/getting-started-with-hazelcast/
http://docs.hazelcast.org/docs/latest/manual/html-single/index.html#getting-started-with-java-client

what is the role of apache server in java swing application (3 tier)?

I have made a Java Swing application, in the GUI the user can select the type of element and choose a date then the element's informations will be shown on a JTable.i used easyPHP to create the DB.
so what is the role of apache server in this case!
can i consider it like an application server ?
A Java swing application (AFAIK out of the box, for alternatives see below) is not available over HTTP/S (and is therefore not classified as a web application) and Apache is a web server (with features such as proxy, TLS terminator etc.). Therefore there would be no need for a web server such as Apache to front your Swing application.
Apache web server is not an application server for a Swing application per se. Although it can run applications in different programming languages such as php through loading of modules. It however does not run Java web applications.
An application server in a Java perspective would be Tomcat, Glassfish, JBoss, WebLogic etc. An application server hosts an application and could provide a set of services such as Naming, HTTP processing and so on.
Perhaps you are referring to Apache Tomcat instead of Apache Web Server. If so, you would be right on the mark as that is an application server for Java web applications.
If you would like to make your application available through HTTP and enjoy the myriad and expansive benefits of an application server, I would recommend you to rethink on using Swing and utilize a technology built over Java Servlets such as JSPs, Spring MVC and so on.
If you would still like to make the Swing application available through a web server (through HTTP/S) there are some solutions out there but I have not tried any of those. Please do a search on "Swing available on HTTP" in that case. I have also provided a link as well.
You can read up on Application Servers on this wiki link.
You can read up on an HTTP end point for a Swing application here.
This Apache is not used in your application. You installed easyPHP so Apache comes with that to provide PHP programming environment.
Moreover Apache is a web server. So any web based application can be deploy here. PHP is a web programming language sot it requires Apache or any other web server.
But your application is standalone developed with JAVA SWING. So you can stop Apache server and check everything is running fine or not.

HTML5 and Java server application deployment on AWS

I have created a Java restful server application which can be compiled as a JAR/WAR file and I have another front-end application built using knockoutjs and HTML5 which talks to the Restful Server side application.
I am trying to deploy both on to Amazon Linux AMI EC2 Instance. I was successfully able to deploy the JAR after setting up a glassfish server on the server. The server side application is running completely fine.
I am having problems in understanding how the HTML5 application needs to be deployed on the AWS server. So that both can be accessible from the same server.
It would be great if some best practices are also suggested.Appreciate any help
Thanks
You probably want to put your GlassFish application server behind an HTTP server like Apache HTTPd or nginx, and either of those servers could then also serve your static content -- your HTML and JS. Check out http://www.codefactorycr.com/glassfish-behind-apache.html

Creating Java Restful webservice on Windows Azure

we are working on our graduation project project that has two main block
1- A website that is written in ASP.NET
2- A webservice that access the database (mySQL DB) , do some processing on data and communicate with that website to show the results.
We are using a java library [Apache Mahout] in that webservice to help us do that processing and that's why we need to write this webservice in JAVA
How can we create and host a Restful java webservice on Windows Azure ? What are the available options ?
Also , Is it possible to start the processing and stop it depending on a request that is sent from the website or another block (another webservice for example) ?
I hope the situation is now clear.I would appreciate if you could provide us with any resources that could help us understand how Restful java Webservice in Azure works :)
Today you have two options for running Java on Windows Azure: Cloud Services and Virtual Machines. Cloud Services (Platform as a Service) enable you to package up a web deployment (WAR) along with a JDK and your java server of choice (Jetty, tomcat, Jboss, etc) and deploy it. Your other option is to use a virtual machine (Infrastructure as a Service). You have a few different options for virtual machines (including officially supported Oracle images: http://www.windowsazure.com/en-us/campaigns/oracle/).
Your easiest option will be looking at Cloud Services (though this does require packaging no a Windows computer). There is a great Windows Azure plugin for Eclipse that will help you out tremendously (http://msdn.microsoft.com/en-us/library/windowsazure/hh694271.aspx). There are also a lot of tutorials, resources, and links to references here: http://www.windowsazure.com/en-us/develop/java/.
Azure websites now supports Java web applications - check it out - http://azure.microsoft.com/en-us/documentation/articles/web-sites-java-get-started/ - you use the default JDK 7 with Tomcat 7.0.50 or Jetty 9.1.0 OR you can even upload your own web container and configure it as per your requirements. Please refer to the link above.
I have created a Java web service using Axis2 Framework/Eclipse and deployed it on Azure Websites.

Server to run java servlet

I'am developing a java servlet application, and tesing it on Eclipse + Apache Tomcat (refer: http://www.vogella.de/articles/EclipseWTP/article.html#overview_wtp).
The application is now tested on the localhost and accesed by any clients on the same LAN.
Now, I need to deploy it into the web server, where everyone from anywhere can access this servlet.
Coud you guide me the way that I've to do to archive this task.
You need to have a computer accessible to everyone - i.e. placed on the internet and not behind a firewall - with the appropriate software installed (and hardened against hacker attacks).
If you do not have such a computer, you can have a look at the Google Application Engine which allows you to deploy Java web applications (with some additional restrictions) to the Google cloud. This is free for low-volume applications.
Yes, you can do it by deploying your application in the Cloud Instance. Since we cannot able to make our server instance or computer to be run always(We may come across internet connection problems, Power Fluctuation, etc.,), We have lot of problems while making our instance public(In Security perspective too). So it is better to use cloud instances.
We have many Cloud Service Providers such as AWS by Amazon, Google Cloud, Microsoft Cloud, etc.,
Take a look on this List of Cloud Services Providers.(You have links for all top 10 providers)

Categories

Resources