I have three distinct heavily coded web-projects; two of them (new) is newly developed with Java/Script, the other (old) one with PHP. All of these three project has some common resources like HTML containers, Element classes etc. Moreover, one of the Java project is Main Project that call the other two projects.
The issue is that Java projects run on a Tomcat Server, PHP needs to run on Apache Server. And PHP project has some location paths for resources like "../SomeResourceFolder/somePage.php". However, when I run Main Project (Java) on Tomcat Server which has "localhost:8080" I could not reach PHP project which is run on Apache Server with "localhost:80", even if I accomplish to reach PHP project, PHP one fails to reach common resources in Tomcat.
I solve the issue a little bit unconvincing way with JavaBridge and Quercus; they help to run PHP on Tomcat Server. However, again I have some path problems.
Actually these projects runs on production with load-balancer which direct request to related server. I try to simulate this or at least run PHP on Apache, Java on Tomcat and connect them somehow. How can I construct this kind of structure without cross domain problems?
I solve the issue by using "Tomcat Connector". It connect Apache and Tomcat by defining Tomcat as worker, and send HTTP request with given path configuration.
You can follow guide given by Nanyang University. In guide Tomcat 6 and Apache 2.2 are used but I used Tomcat 7 and Apache 2.4 with the same directions.
Related
I have two questions, for those which I did not get any solution sounds good for my expectations.
1. Why both XAMPP/WAMP and Apache Tomcat?
Assume if I am now running a Windows system, with Eclipse LUNA.
Now, if I have to run a query for my localhost server, how does Eclipse help?
I won't be satisfied if you say there should be an XAMPP server running live for your query to execute in Eclipse(Like they say here Database Development Using the Eclipse IDE, MySQL with Eclipse Data Tools Platform in Java).
Then why Tomcat is there?
Sorry if there is some loop hole, or may be this is a Banana-Monkey` type question. All because I don't get it clear.
And now, my second question.
2. How can I(Is it possible to) run a Java project in Eclipse with Apache Tomcat while WAMP/XAMPP is running in background in my system?
Suppose I am on the same system working with different user privileges. Say user1 runs both the XAMPP and Eclipse As Administrator. Now (or anyhow) is it possible to run a project in Apache Tomcat while WAMP/XAMPP is running in background simultaneously in the system?
I am totally confused. Helps with your comments and answers are appreciated.
Thank you.
Yes it is possible to run two servers on same system simultaneously.
Yes you can execute a MySQL query when XAMP/WAMP is not running.
It seems you don't understand your setup and the elements involved.
XAMP/WAMP contains Apache server, so a http server that can handle static html or run php scripts. It also comes with a MySQL database.
So the only important part from the Java WebAPP is the MySQL. You can start MySQL without starting apache, you can finally install MySQL yourself (it has simple windows installer). But if your application is using MySQL it has to be running for it to work (be it a XAMP version or standalone version).
Your Java Web Application requires application container to run, and it is the Tomcat. It is Apache Tomcat as it is developed under apache groupe, but it is not the same as Apache web server.
So you need tomcat to run your web app. Again you can install one yourself or use the one that comes toghether with Eclipse.
You can have many tomcats at the same time, all running (for example different version of Tomcats or Java) as long as they listen on different ports. The ports on which tomcat is runing is configured in its server.xml file under conf directory.
I am trying to deploy a JSP/servlet onto a server. Not tomcat but on a real web domain. This is my first time doing so and so far I exported it into a war file and placed the file onto the server. Nothing happened which is why I am here. All the google searches seem to concentrate on Tomcat which I have already ran the project on. Advice?
Ok, let's get really basic. You want to see the compiled JSP in a browser, through some public URL, right?
First, find a place to host your application. You can try Digital Ocean (starts at $5/mo), EATJ (free version available), Amazon AWS (free trial available), OpenShift (free gears available), your own computer with dynamic DNS, or many other options available through Google.
Next, you packed your compiled code to a war file. That war file needs to be unpacked (deployed) using some software.
There are numerous ways to handle this (Tomcat, Jetty, Glassfish, etc.). They all have their pros and cons. Pick one and learn the very basics. Tomcat doesn't require a separate web server but you can set one up with it if you like. At this stage, I would keep it simple and not do that yet.
Lastly, set up GoDaddy (or whomever you used to get your URL) to point to the IP address of that server. If your server is running and enough time has passed for the changes to propagate, you should see your page.
There are plenty other J2EE server for example, JBoss and Glassfish. Each one has it's own way to deploy your war files. For example, Glassfish is throught a web administration console (https://docs.oracle.com/cd/E19798-01/821-1757/6nmni99aj/index.html) and in JBoss you need to deploy the war file in a specific directory (http://docs.jboss.org/jbossweb/3.0.x/deployer-howto.html).
It depends on which J2EE server you are using.
Now if you want to get your own server and configure it:
Get the server or VPS
Install JAVA
Install Apache
Install a J2EE server (I prefer glassfish)
Configure glassfish with apache (http://www.codefactorycr.com/glassfish-behind-apache.html) to use apache in front of glassfish
You may want to block the ports 4848 and 8080 used by glassfish
Deploy your webapp
Have fun!!!
PS: I'm assuming you have root access to the server
Easy Apache Tomcat 7 install after,
Run Code via SSH:
/usr/local/cpanel/scripts/addservlets2 --domain=domain.com
For Linux.
I have a Spring MVC project running locally on tomcat right now. What I need to do to be able to run it on my linux server? How can I deploy it? Before I used firezilla(running usual jars) to connect to server using ssh. Please help me by writing easy steps on how to run web application on server, thank you.
There are a lot of answers to this just have to google (i found about 10 in first couple pages that were good).
It all varies based on your environment, build setup etc.
Here is example of deploying with maven to tomcat
http://www.mkyong.com/maven/how-to-deploy-maven-based-war-file-to-tomcat/
and another
http://bitbybitblog.com/deploy-to-tomcat/
Some IDEs also have inbuilt functions that take care of this for you as well.
Is it possible to deploy my Spring/BlazeDS/Java application to elastic beanstalk? I'm using MyEclipse and built a Java Web Project with the required jar files etc. Do you need to specifically create an AWS Java Web Project - reason I ask is the options to include the BlazeDS files aren't there - so I'm wondering if Spring / BlazeDS is even supported? By default the turnkey blazeds runs through Port 8400 - so I imagine there are some additional tasks required to configure the endpoints to work through port 80?
Gracias!
Take a look at this example. Will be trying something similar over the next few weeks.
http://www.riaspace.com/tag/aws/
BlazeDS is not a standalone application, it consists from a bunch of jar files which should be added to your web application. You will also need to declare a servlet in the web.xml file. I wrote an article a couple of years ago how to add the blazeds jar files to a java web application (and what to configure), you can take a look here.
I am currently developing an application for some researchers in my university.It's a small java program that you can use by command line. The next step is to package that program and deploy it to an application server. Some clients program will submit requests to the server who will call the tool that I wrote. Lately, we will add more tools to the server and he has to dispatch the requests to the right tool.
Which application server fits my needs ? I have looked for Tomcat, Jetty and Glassfish but it seems that they are only used for web application.
Is it possible to use those servers in some context different from web context? Which package archive should i use (jar, war) ?
Any advice?
Some clients program will submit requests to the server who will call the tool that I wrote.
The big question is what server-side technology and what communication protocol can you use between the clients and the server. You basically have two major options: HTTP and web services (in that case, consider using either JAX-WS or JAX-RS) or RMI-IIOP and EJBs (in that case, you'll have to use a Java EE compliant server like GlassFish).
I have looked for Tomcat, Jetty and Glassfish but it seems that they are only used for web application.
Not really. As I said, they can also be used for web services oriented applications. And GlassFish can be used for EJBs applications.
Which package archive should i use (jar, war)
The packaging will depend on the type of application you'll write, it's not something that you choose upfront, it's just a consequence. EJBs are packaged in an EJB JAR and typically deployed inside an EAR; Servlet based web services are deployed inside a WAR.
You really need to think about what technology to use first (with the current level of detail, I can't provide more guidance).
Do you even need an application server? There's nothing stopping you from adding the necessary network bindings and deploying it on its own.
Of the servers you mention, you've got 2 different categories: servlet containers and full-stack Java EE servers
Tomcat and Jetty are servlet containers. That doesn't mean that you can only do web stuff with them and you could manually add the required libraries to get a full Java EE server.
Glassfish is a full-stack Java EE server and can be compared with JBoss (both are open source) or the commercial rivals Weblogic and Websphere.
Sometimes this question is simple as the environment you are working in mandates a particular flavour of app server. You should check this first.
If you're not forced to use an app server, I'd ask why you think you need to use an app server?
I don't see why you would want to use tomcat, glassfish or jetty for a command line program.
If it's command-line based, and you want it to run server-side, you could write a little program that allows users to, for instance, telnet to your server, which in turn starts the CLI-application in question, and relays input / output to the client.
You may also want to look into Java Webstart, which makes deployment of new versions a breeze.
Actually we can't answer with so few elements.
- What are you planning to do
- With what technologies
- Where are you planning to host your application (have you got budget?)
- In which language are written the clients (even the future ones)?
- Could clients be on mobile phones (add some technlogy constraints...)
....
It would also be great to know what kind of request the clients will do, and what kind of response the server will provide...
Actually with what you tell us, all those application servers can do what you want...
I have looked for Tomcat, Jetty and
Glassfish but it seems that they are
only used for web application
You could even make a webapplication (servlet) and on the clientside use a httpclient to call that servlet... there are so many options :)
vive Paris!