Setup Weblets 1.0 for JSF on Weblogic 8.1

This week I’ve tried to upgrade from Weblets 0.4 to 1.0 while using the following technologies: JSF1.1, JDK1.4 and Weblogic 8.1.

Here are some of my experiences:

As noted in the documentation on https://weblets.dev.java.net/doc/longdoc/setup.html, the web.xml needs the following additions:

       <servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

This URL pattern will be used only by Weblets. The generated URLs whenever you call weblet:url / weblet:resource via EL, Javascript, CSS or Java will begin with /faces.
This in fact makes sure that the WebletsPhaseListener knows when to process a resource or not by looking at the url

For Weblogic 8.1 it also necessary to add the following listener to your web.xml:

 

 <listener>
<listener-class>net.java.dev.weblets.WebletsContextListener</listener-class>
</listener>

I couldn’t get Weblets to work without it.

Last but not least you should add mime-mappings to your web.xml for all the different types of static resources you want Weblets to serve:

<mime-mapping>
<extension>css</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>application/x-javascript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gif</extension>
<mime-type>image/gif</mime-type>
</mime-mapping>

<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>

<mime-mapping>
<extension>jpg</extension>
<mime-type>image/jpg</mime-type>
</mime-mapping>

If you don’t do this, then a NullPointerException is thrown internally by Weblets and gives problems serving the static resources.
I don’t know about other servers, but on Weblogic doing a servletContext.getMimeType will return null when it was not defined in the web.xml

In fact, Weblets 1.0 also supports defining a <mime-mapping> in the weblets-config.xml. But adding the mime types only there didn’t work as in the Weblets source code there are few places where servletContext.getMimeType is called directly thus ignores any configuration done in the weblets-config.xml. For the next version of Weblets it would be interesting to fix this behaviour and document eg. that mime-mappings in weblets-config.xml take precedence. And if not defined there, Weblets will try to look for mime-mappings in the web.xml via the servlet context.


Warning: count(): Parameter must be an array or an object that implements Countable in /home/javablog/web/wp-includes/class-wp-comment-query.php on line 405

3 thoughts on “Setup Weblets 1.0 for JSF on Weblogic 8.1”

  1. Great. It was exactly what I required. I had the problem with integration of weblogic 9.2 and weblets. The mime-mapping helped to resolve it. Thank you a lot.

  2. Hi Wim.
    Article is helpful indeed, but I couldn’t make weblets work properly on Webpshere 6.1, I’ve followed same steps you described but for some reason I’m getting empty js file (investigated it using firebugs)

    Thanks,
    Dave

Leave a Reply

Your email address will not be published. Required fields are marked *