Chandu
Chandu

Reputation: 82933

Websphere: How to add a Uri to UriGroup of plugin-cfg.xml

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.

Upvotes: 0

Views: 3099

Answers (1)

Doug Breaux
Doug Breaux

Reputation: 5115

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>

Upvotes: 1

Related Questions