• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to migrate web application from one Server to another server

 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I have created a web application in TOMCAT 7.0.x using JDBC+Servlet+HTML+JSP
and I tested it on my localhost on MySQL database.

Now I want to transfer its war file to some another host or server.

My Question is how to do this like I can copy its war file to another sever web-apps that is ok.It works but question is since it is a database driven application So how to make it running on another host.?


Any link that will guide me How to migrate a web application from one Host to another will be nice

Thanking you
 
Rancher
Posts: 43016
76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The usual approach is to make the web app pick up such configuration information from something like a properties file, maybe located in WEB-INF. Then you can prepare different properties files for the various environments, and include the correct config file one at build time before creating the war file. A build tool like Ant would make this relatively easy.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you have any video link or tutioral that will help me understand it very well..

or at least from basic?

Thanking you
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're not familiar with Ant, I would start with Ant tutorials, of which there are plenty out there. Once you get to the point of where you're using its <war> task to built your war file, you can start thinking of how to copy the different properties files before building the war - assuming that you have different properties files for the different environments. If not, start by moving all environment-specific config data into into property files.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got some information and knowledge about Apache Ant...

But My Question is still there how to make my database driven web-application transfer from my localhost to some other host?
Can you give some step by step any link or tutioral that will guide me to make step by step transfer

thanks for help
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said, start by moving all configuration information that differs between the two environments into a properties file that resides in WEB-INF, and which is read at application startup. Prepare one such file for each environment in which the app is supposed to run. Once you have that, and you can create war files that are runnable in each the respective environments merely by swapping out the property file, you can think about how to automate it using a build tool. Since you mention DBs specifically, that file would for example contain the connection information for the DB (URL, account, password).

I think this answers your question as I understand it, but if it does not, tell us specifically in which way it doesn't address the exact problem you're trying to solve (and which problem that is).
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I am addressing full problem here

1)I have a Database driven Web application names "LoginApplication".

2)This application takes some argument from a web-page and Insert them in database that is configued with it.And it also query back to servlet(Everything is fine working)

3)I used Eclipse+MySQL+Apache+Servlet to create that web application.

4)Application run successfully on my localhost server.

5)I have created a WAR file using export in Eclipse.

6)Now I pasted that WAR file on some another machine which is using Apache Tomcat server and I paste on its Web-Apps folder and it is successfully deploy.

7)But when i try to insert any value from another machine it doesn't insert (Obviously there is not any database that I configured).

8)My Questions are

->How to make or Configure that LoginApplication to run with its database on another machine?

->How to import a database that i created on first machine for my "LoginApplication" with that WAR file?


Any more clarifications..


I am using MySQL database embedded inside WAMP server and My Apache Server is a different Instance other than of WAMP server(this is OK everything running well)


Thanking you

 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

How to make or Configure that LoginApplication to run with its database on another machine?


By keeping the DB config information outside of the code. Did the properties file approach I mentioned make sense to you?

How to import a database that i created on first machine for my "LoginApplication" with that WAR file?


I don't understand what you're asking here. Do you want to take all the data from your development DB and move it to the production DB? If so, the best approach is probably to use the MySQL tools to create a data dump on one DB, and then import it on the other. Much easier than to try and do this from within the app.
 
Saloon Keeper
Posts: 22483
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The J2EE standards support 2 "deployment descriptor" files. One of them contains application information that's independent of the brand and version (more or less) of server being used. It's called the "server-independent deployment descriptor", but you'll recognize it as the WAR's WEB-INF/web.xml file.

The other deployment descriptor varies with the server. For the case of the Tomcat server, this is the Tomcat Context, which may be defined in a META-INF/context.xml file in the WAR or as a file in the TOMCAT_HOME/conf/Catalina/localhost directory or one of its relatives.

A lot of people simply dump a WAR - either an actual WAR file or its unzipped contents (known as a "exploded WAR") into the TOMCAT_HOME/webapps directory. In that case, a Context will be synthesized, but it won't contain advanced Context features such as a database Connection Pool or security Realm definition.

So to migrate a webapp from one Tomcat to another, you'd copy the WAR and the Context and customize the Context, if needed. The WAR would remain unchanged.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks tom I will do it and soon get back to you
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there

I am following these articles

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

https://tomcat.apache.org/tomcat-4.1-doc/appdev/build.xml.txt

http://tomcat.apache.org/tomcat-5.5-doc/config/globalresources.html


https://tomcat.apache.org/connectors-doc-archive/jk2/jk2/configweb.html

so using these file I don't find any artciles that will guide where and what should be name of .properties files?


and second question is

No one of this article solve my problem that how to configure my database properties in these .properties?


and I also read about ant so before following these Do I need to learn about Ant?


thanks
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to learn about Tomcat, you should read up on the version you will likely be using - at this point, that should not be anything older than Tomcat 7.

so using these file I don't find any artciles that will guide where and what should be name of .properties files?


This has nothing to do with Tomcat - it's something you would implement, so you can freely choose the name and location of the file. Inside WEB-INF would be an obvious location.

No one of this article solve my problem that how to configure my database properties in these .properties?


See above. If the only difference between the environments are the DB properties, then the file may not contain anything more than the few properties you would need to make a DB connection. In fact, if that's the only difference (unlikely but not inconceivable) then you can get away with using a datasource in tour Tomcat config, and wouldn't have to do anything else.

and I also read about ant so before following these Do I need to learn about Ant?


Learning about Ant is useful if you want to automate the process of creating war files, and particularly if you want to do so for several environments. You can of course do this by hand, but that's a tedious and error-prone process.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
many many thanks to all moderate for help.

I think I am close to what I want to do

ok i got some information about Apache-ant and I have created a project in my computer its just a simple Java Application and i have build it using
this
http://ant.apache.org/manual/index.html

according to my choice that i specified in build.xml file..


but as i experience that this build tool can only create and change structure of application and i can create a web application structure what i want using this.I can change war file structure using this.

Now I want to know what parameter about database and other specification i need to configure in this .properties file to run it on another server


thanking you.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic