I have developed a dynamic web project using eclipse and i am having a domain name and a web hoster. all i want to do is to upload my eclipse project to my web hosting site. Currently i am using html 5 template on my website but i want to upload my own project on it. I have heard that we can do it by using war file but i am not sure how to do it as my html 5 template contains many html page like index.html and it is more in size as compare to war file which i have exported. Please tell me i am totally clueless about it
Your web host needs to support Java and some Servlet container. If they don't already have those two things installed, you'll need to install them yourself. Once that is done, in Eclipse, you will need to export your project in the form of a .war file and place it in the appropriate folder of your Servlet Container. For example, with Tomcat, you would place it in its /webapps directory. You then start your Servlet Container. Your web application will be up and running.
If your web project includes Java web technologies such as Servlets and JSP, you will need to
Build your war file first either with Ant, or Maven.
Then you can upload the war file to your web server using some type of deployment tool that is usually available on the hosting web server. For Apache Tomcat for example, you can use the Tomcat Manager tool to deploy your war file.
Related
I'm new in Java EE and Tomcat.
I worked on a REST Java application in OpenShift with JBoss EWS 2.0 and I had no problem. Recently, we got a server that I have to run my web service on.
Following How to deploy a war file in Tomcat 7, I went to my application root and used this command:
jar -cvf myapp.war *
Note that myapp is my application name for example.
I put the .war file to /base/path/of/tomcat/webapps/ and went to Tomcat GUI App Manager.
I saw that Tomcat created a folder with my .war name and put files into it, so I started my app but when I went to http://localhost:8080/myapp/ it returned 404. However, in OpenShift, when I opened it (opened root path), it displayed the index.html insomuch my webservice path is not valid and does not work.
please guide me and thank you for your time spent on my question.
I have to write an answer because I can't comment.
I suggest to give us a copy of the web.xml file.
On another hand, you have to know that Tomcat is a Servlet Container and JBoss a full stack JEE server. If you have EJB in your web-app it will not works.
AS Clément Duveau says an EJB application cannot be deployed in a Servlet container (like Tomcat). An EJB application needs to be deployed in an Application Server like JBoss, Wildfly, GlassFish, Weblogic, Websphere, TomEE, etc.
The most similar server to Tomcat (Java EE compliant) would be TomEE.
Suggestion: If you need to use Tomcat, you can change EJB for Spring Framework.
it is simple.
there is two way to deploy a war file on tomcat with custom path
the first one is to
renaming your war file to custom URL you want (for example the war file name is java-web-app-1.0.war and your path is myapp so you have to rename it to myapp.war)
and copy and put it under {tomcat-path}/webapps/, then the Tomcat/TomEE does its job. (it creates an empty directory with the same name of your war file)
after about 1 minutes you can check the path (in this example must be localhost:8080/myapp and see your war file was deployed)
the second one is to use Tomcat GUI.
go to Web Application Manager part.
it's a page like this:
in Deploy box just fill the Context field (it will be the custom path and in this case is myapp) and then choose the war file and push deploy button.(do not need to fill XML Configuration file URL field)
then it gives you a message like this:
this means your war file was deployed on the custom path.
I built my java RESTful application in Eclipse with Jersey and a couple other libraries. My question is, how do I deploy this to a Tomcat server? Do I export it as a WAR file? Do I need to deploy the libraries I used as well or are they packaged in the WAR file?
The server is running on an ubuntu machine which I can access over ssh. I got the server running with "apt-get install tomcat7". Which folder should I put it in? Is any configuration needed? What should I do with the web.xml file?
Thanks in advance.
You usually wouldn't use Apache to directly serve a Jersey web application as Apache is not a Java application server. It would be served from a Java server such as Tomcat instead. If you wish to serve your Jersey application as if it was located on your Apache server, you would still have a Tomcat server running and set up a reverse proxy to your Tomcat server. I personally use a server such as Wildfly or TomEE which implements the full JavaEE profile and means you are less likely to run into errors. Nearly all Java application servers also have the capability of serving static content so unless you specifically need Apache features, you do not need to go to the trouble of also running Apache.
With each one of these servers you would need the .WAR file and deploy it, either through the appropriate maven plugin, the web manager or placing the .WAR into the appropriate directory.
Dependencies for a .WAR specified in the 'compile' scope will be included as part of the .WAR file and those in the 'provided' scope will not be included (for when your web server has these included)
I want to deploy my Java EE project to the client desktop (Not, to a domain). How may I able to achieve that without again installing Servlet containers like Tomcat.
I want to make my war file as clickable file, to what ever system I deploy it to.
Hot to achieve it? I mean is there any way to deploy war file + servlet containers as a single file, as the web app can be opened any where without installing Tomcat or GlassFish etc., I use NetBeans IDE.
Check out Excelsior JET: it can compile your war and servlet container into a native executable for a given platform.
I guess a drawback of using such an awesome IDE like eclipse is that you miss the point for what happens behind the scenes of an application. I'm a ruby developer so not a java veteran. So I've been coding a project in java and using the spring framework for IOC and MVC. Can someone explain to me what is going on when I select run on server in eclipse? Because eventually I will be deploying this masterpiece of an application to a Linux server. Here is my setup. I am using Spring MVC 3 and the maven plugin in eclipse. In the pom.xml file, I have stuff like latest spring release version, log4j, spring mvc, spring context etc.
I have been testing my application on localhost using the handy option of run on server in the eclipse IDE. The server configuration in eclipse is pointing to the tomcat directory location for where I have installed tomcat 7. Please demystify what happens behind the scenes and what I will need to do if I want to deploy this application on a production server. The more detail the better. Thanks a ton in advance.
Deploying a web application to Tomcat is as simple as this (assuming Tomcat is installed)
Bundle your application in a .war with the correct format.
Move the generated .war file to the /webapps directory of your Tomcat installation folder.
Run the /bin/startup.[sh|bat] script in the Tomcat installation folder.
Note that there are intermediate steps you can do to configure the deployment, like changing your context path. Go through the Tomcat documentation for details.
In step 3, Tomcat will extract the .war contents to a directory in the /webapps folder with the same name as your .war file. It will use this as the context path. The script itself launches a java process by putting the WEB-INF/[class|lib|...] onto the classpath along with some Tomcat libraries.
So Eclipse basically does all the steps above for you.
Ultimately you are deploying an web application that means you are deploying a war file to the server. Regardless of using frameworks like spring, struts anything.
SO a web application request starts from web.xml file. SO for spring mvc application, you are mapping all request coming from browser to DispatcherServlet and then this guy is responsible to manage whole life cycle of your application.
For more details of how MVC works please see
http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/mvc.html
So in order to deploy your application (a war) on server first of all you have to create a war from your source code. You can go to traditional approach to use java given utility like using jar from command prompt or you can use ANT, GRADLE, MAVEN and such build tool that creates war for you in automated way.
Spring is not doing anything extra for you. I believe you to research a bit more on how these tools works.
Once a war is ready for you, you can simply go to tomcat UI and there you will find options to deploy your war.
I hope it helps you.
All the majic happens in two places.
The first is your 'Servers' directory in the root of your Eclipse Package Explorer. These are your server configuration files that Eclipse will use (mostly) when it creates a new server instance.
The second is in the ./metadata/.plugins/org.eclipse.wst.server.core/ file system directory in your Eclipse workspace. This is where the tomcat application is actually deployed by eclipse.
The Tomcat Documentation is pretty good actually and helps explain how to do deployments. FYI, I do not know many people that use the Manager, from my experience most people deploy their applications by hand.
I wrote a small servlet and jsp project on eclipse and tomcat 5.5, but I don't know with works I do for make that a real site on a real host. Should I war them or I should upload project on host? My host should have which properties? I really don't now how to start?
I would recommend packaging them in a war and deploying it out to the remote tomcat server. Its not a good idea to deploy an unpackaged project directly to the server unless your debugging or testing. Once you have a finished project ready to deploy package it to a war. I typically deploy to server using the tomcat manager page. Just browse for the war, click the upload button and it should start right up. On my local machine this is the url that I use to upload to the server http://localhost:8080/manager. The server itself should have the same properties and settings that you are using in your eclipse workspace, and I would highly recommend that it be the same version as well. The war can also be dropped into a directory on the remote host and Tomcat will load this on startup, this location will vary depending on the host.