Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a war file be deployed on any server?

Please pardon me if this question is silly. Suppose I develop a J2EE web application using Spring framework and a MS SQL-Server database, using a WebSphere application server. I later create a WAR file for this application.

Can I deploy this WAR file on a Tomcat server without any change in code? Or my question is can this be hosted by web hosting which provides only Tomcat servers? If yes, is there any change in code required?

If it cannot be deployed, can you please suggest me what to do, because I havent developed any application on a tomcat server. All the applications that I have developed have been on Websphere App Server using RAD.

like image 393
Roshan Avatar asked Apr 15 '10 04:04

Roshan


People also ask

Can we deploy WAR file in Tomcat?

Perhaps the simplest way to deploy a WAR file to Tomcat is to copy the file to Tomcat's webapps directory. Copy and paste WAR files into Tomcat's webapps directory to deploy them. Tomcat monitors this webapps directory for changes, and if it finds a new file there, it will attempt to deploy it.


1 Answers

In principle, yes WAR files should be portable across Java EE servers. In practice I would not expect many portability problems, but it very much depends upon the details of your application and whether you've stuck very closely to Java EE standards. Also, just deploying your app into a different environment (your dev machine versus a hosting environment) might hit snags, not so much a WAS v Tomcat as this environment v that environment.

Possible issues, descending order of likelyhood:

1). Are you targetting the same versions of the standards.

2). Did you use any WebSphere specific extensions beyond the Java EE specs. Most vendors have some extra goodies, did you use any.

3). You've hard-coded some resource (file, directory, printer, database) that is accessed differently on your target platform.

4). Did you hit a spec ambiguity? Is there some corner case where WAS behaviour differes from Tomcat behaviour.

5). You depend upon something that WAS or your platform does really quickly and your taget platform doesn't.

My general rule for portability: always test early across your range of intended deployment platforms. There's nearly always some gotcha. If you find out early you can fix with little pain.

like image 76
djna Avatar answered Oct 08 '22 23:10

djna