Thursday, July 22, 2010

HTTP 404 error -"A WebGroup/Virtual Host to handle <@contextroot@> has not been defined" in WebSphere AppServer

Have you come across the error "HTTP 404" in your Web Browser when you try to access your web application deployed in WebSphere?
But even though you may see this as the error in web browser this is a generic error code.The root cause to produce this error can be found by observing WebSphere server log files under WebSphere home directory. One root cause is " A WebGroup/Virtual Host to handle /AppName has not been defined" which i came across recently (In my case i used WebSphere 6.x).

In order to fix this particular error the Virtual Host of the deployed application has to be found in the first place.
Steps:
1. In Console Navigation Tree -> Applications -> Enterprise Applications
2. Click on the deployed application name
3. Web Module Properties -> Virtual Hosts

In my case it was "default_host" and this is the default host provided by the WebSphere application. If new virtual hosts are required other than the default host those can be added too.

Now we need to verify that the virtual host of deployed application has a host alias which is similar to our application urls' host and port.
Steps:
1. In Console Navigation Tree -> Environment-> Virtual Hosts
2. Click on the host defined for the application (In my case it is default_host)
3. Additional Properties -> Host Alias

In my case this was the issue. The host and the port in my application access url was not defined under host alias in default_host.
So a new alias has to be added to the particular virtual host which matches with the applications' host and port.Now WebSphere server need to be restarted to apply changes.
Then the web application should be able to access by using its access url (With the correct contextroot) without getting this error.

No comments: