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? I开发者_如何学编程f 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.
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.
精彩评论