0

I am new to Websphere. We have installed a simple hello world app on the websphere application server (8.5.5) and with ibm http server with the context root set as /HelloWorld. Given below is the web.xml we are using for the war:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>HelloWorld</display-name>
    <servlet>
        <servlet-name>welcome</servlet-name>
        <jsp-file>/index.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
        <servlet-name>welcome</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

When I browse to http:///HelloWorld I am expecting to see the contents of the index.jsp page of my hello world application. However I am getting the "Forbidden" page. I see the contents if I use the path http:///HelloWorld/index.jsp

Some posts/documentation online lead me to plugin-cfg.xml file on the server. I have edited the file to add the Uri "/HelloWorld/*" to the default URIGroup manually and it works.

Now my question is how do I add a Uri to the UriGroup using the Adminsitration Console? Also is there a way to have the route added via the war being deployed instead of editing the plugin-cfg file explicitly.

Update: It's working now I assumed that mapping the module to the Cluster during deployment ("Map modules to servers" step) will automatically map it to the web server, but apparently not. I have mapped the module to the cluster and the web server and it works I will just redo the whole deployment from scratch again to make sure my understanding is correct and then update the post.

Thanks @dbreaux

Update#1

I guess I should RTFI (I = Instruction). The fix for my issue was right there on the deployment page.

Map modules to servers
Specify targets such as application servers or clusters of application servers where you want to install the modules that are contained in your application. Modules can be installed on the same application server or dispersed among several application servers. Also, specify the Web servers as targets that **serve as routers for requests to this application. The plug-in **configuration file (plugin-cfg.xml) for each Web server is generated, based on the applications that are routed through.

Chandu
  • 81,493
  • 19
  • 133
  • 134

1 Answers1

1

So, first, this should be handled by web.xml for certain, not by editing plugin-cfg.xml.

I suspect if you change your <url-pattern> to '/*', it will work as you expect. But I'd have expected '/' to work as well, as that's the "default" mapping. See Difference between / and /* in servlet mapping url pattern

Depending on what you're trying to do, though, there might be more normal ways to do it. For instance, web.xml provides a <welcome-file-list> element where you define what URL you want provided when the plain context-root is requested.

You also don't need to explicitly define <servlet> elements for JSPs at all. Those are understood automatically by WebSphere.

So in your case, this should be sufficient:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <display-name>HelloWorld</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>
Community
  • 1
  • 1
dbreaux
  • 4,982
  • 1
  • 25
  • 64
  • Thanks I will try the config you mentioned. However I noticed that when I generate the plugin-cfg file it gets generated with some default Uri in uriGroup like /snoop/, /hello/ etc. Where would these be coming from? – Chandu Oct 16 '15 at 15:07
  • Sounds like you have the default application installed as well. One for testing with. – dbreaux Oct 16 '15 at 15:08
  • Yes. I would like to know what config in web.xml (if at all) of those wars is resulting in the generation of the Url /snoop etc . – Chandu Oct 16 '15 at 15:16
  • It's not in your web.xml, it's a whole separate ear/war installed into WAS. Look at the WAS console and see if there's another application installed. See https://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/rweb_defapp.html – dbreaux Oct 16 '15 at 15:17
  • Thanks I am aware of the default ear/war. Am not clear how the entries ` ` are getting added when I generate the plugin-cfg file – Chandu Oct 16 '15 at 15:42
  • They get added by that default ear/war. plugin-cfg has entries for all installed applications. Or maybe I'm misunderstanding what you're asking. – dbreaux Oct 16 '15 at 15:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92523/discussion-between-chandu-and-dbreaux). – Chandu Oct 16 '15 at 15:45
  • It's working now I assumed that mapping the module to the Cluster during deployment ("Map modules to servers" step) will automatically map it to the web server, but apparently not. I have mapped the module to the cluster and the web server and it works I will just redo the whole deployment from scratch again to make sure my understanding is correct and then update the post. – Chandu Oct 16 '15 at 16:09
  • OOPS ... I was using my phone while upvoting and looks light I hit the down arrow. It doesn't let me change my vote now, unless the answer is edited. Can you you do a dummy edit so that I can revert my vote? – Chandu Oct 20 '15 at 19:08