So, you start a new we project in Eclipse 3.4.1 (or in Netbeans 6.5.1) and you run it, what happens is that basically the project gets copied in to the directory the application server uses to “keep” the applications it runs, then the application server starts, looks in to its directory for applications and starts your application, and you are able to see your project,if you are using Tomcat, or JBoss as lot people do, you will be able to see you web project on port 8080. Right? Wrong!
what really happens is that then the application server starts and then the project gets copied in to the directory the application server uses to “keep” the applications it runs, then the IDE opens the web browser, that connects to the port 8080 using an url that includes the context of the application, its “name” so to speak, and then, the application server then realizes there a new application with that name in on its “directory applications” and starts it.
Noticed the difference:
What one typically believes it happens:
- the project gets copied in to the directory the application server uses to “keep” the applications it runs
- the IDE starts the application server
- looks in to its directory for applications and starts your application…
- now you will be able to see you web project on port 8080
What really happens:
- the IDE starts the application server
- the project gets copied in to the directory the application server uses to “keep” the applications it runs
- then the IDE opens the web browser, that connects to the port 8080 using an url that includes the context of the application
- the application server then realizes there a new application with that name in on its “directory applications” and starts it
Now, why is it so important to understand in what order this happens?
Well, because during development this processes is repeated again and again, until the application reach a point where it can be delivered to the customer the problem is that some times, one of the iterations of this process ends with an application so dysfunctional that it is able to crash the application server (and that will not stop until we get a real virtual machine for java).
But until we do get a better virtual machine, there is a more pressing problem, if we deploy an application that crashes the application server, the order in which the process is currently done makes it impossible to deploy the fixed version, unless we delete the previous version completely. Why do I say that: well lets analyze it, lets say we start with a fresh application server, where we have never installed our application:
- then the application server starts
- the project gets copied in to the directory the application server uses to “keep” the applications it runs
- then the IDE opens the web browser, that connects to the port 8080 using an url that includes the context of the application
- the application server then realizes there a new application with that name in on its “directory applications” and starts it
This first version of our application is far from finished, but it does not have any bug capable of crashing the application server, so we add som more functionality, and we ask the IDE to run our application again, and what does the IDE do?:
- then the application server starts
- since the application server already knows it has our (failed) application installed, it does not need a visit from the browser to start it, in starts it immediately
- the project gets copied in to the directory the application server uses to “keep” the applications it runs, since the application is already there, only the changed files are copied
- if the changes are of a particular kind (alterations to web.xml for example) the applications server restarts the application so that it starts working with the new configuration
- then the IDE opens the web browser, that connects to the port 8080 using an url that includes the context of the application
This second version of our application actually has a nasty bug, so after step 4, the application server hangs, and we are forced to kill it using the services provided by the operating system to deal with misbehaving processes, then we go back to our code, fix the problem, and we ask the IDE to run our application again, and what does the IDE do?:
- the IDE starts the application server
- since the application server already knows it has our (failed) application installed, it does not need a visit from the browser to start it, in starts it immediately
- The application server hangs.
And that is it, the project files are never copied in to the directory the application server uses to “keep” the applications it runs, the critical problem here is that the IDE seems to wait for the application server to start correctly before copying the new files (it should copy them any way, that of course would not prevent it from hanging, but, after we had killed the process, the next time we ran the application server, if we had fixed the bug, it would not hang any more… but even then the behavior would be anti-intuitive, why the process is not like this is a mystery to me:
- the project gets copied in to the directory the application server uses to “keep” the applications it runs, since the application is already there, only the changed files are copied
- the IDE starts the application server
- since the application server already knows it has our (failed) application installed, it does not need a visit from the browser to start it, in starts it immediately
- Since we have fixed the bug, everything runs fine
Do you know why it does not work like this? If you do, please… would you explain it to me?
No comments:
Post a Comment