David Botterill's Weblog

« Previous day (Aug 4, 2006) | Main | Next day (Aug 6, 2006) »

20060805 Saturday August 05, 2006

Java Studio Creator 2 and Liferay Portal Server Update

I thought I would give some update on Java Studio Creator 2 portlets running on Liferay portal server.

Liferay 4.0

To get Java Studio Creator 2 update 1 portlets to work correctly on  Liferay 4.0 you will need to remove the "lib/portlet.jar" file and the "tld" folder from the WAR file.  I have a defect filed against Java Studio Creator to permanently remove the "portlet.jar" file from the portlet since all portal servers will most likely supply this at the container level.

Liferay 4.1

The good news is that you  don't have to worry about removing the "portlet.jar" file nor the "tld" folder from the WAR file in 4.1.  There are, however, some other issues.

 Apparently Liferay 4.1 does not support the Servlet 2.4 spec in a web.xml.

I've tried with both

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

and

<web-app version="2.4">

But both trigger the following exception.


org.dom4j.DocumentException: Error on line 3 of document  : Document is invalid: no grammar found. Nested exception: Document is invalid: no grammar found.
        at org.dom4j.io.SAXReader.read(SAXReader.java:482)
        at org.dom4j.io.SAXReader.read(SAXReader.java:365)
        at com.liferay.portal.service.impl.PortletLocalServiceImpl._readWebXML(PortletLocalServiceImpl.java:983)
        at com.liferay.portal.service.impl.PortletLocalServiceImpl.initWAR(PortletLocalServiceImpl.java:259)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)



I've done some debugging in the liferay code and the exception is thrown in this part of the code.

PortletLocalServiceImpl.java -
    private List _readWebXML(String xml) throws DocumentException, IOException {
        List servletURLPatterns = new ArrayList();

        if (xml == null) {
            return servletURLPatterns;
        }

        SAXReader reader = new SAXReader(true);

        reader.setEntityResolver(new EntityResolver());

=====>        Document doc = reader.read(new StringReader(xml));

        Element root = doc.getRootElement();

        Iterator itr = root.elements("servlet-mapping").iterator();


I'm not familiar with the 3.6 codebase so I don't know if dom4j's SAXReader was used or if it always used the "true" option to validate the schema.  In any case, apparently it has a problem resolving the schema for servlet 2.4.

Work Around:

In Java Studio Creator 2 update 1, choose the J2EE 1.3 as the target WAR type when you do the export WAR.  The dialog will look like this.

export war
Posted by david ( Aug 05 2006, 09:38:16 PM MDT ) Permalink Comments [8] del.icio.us | digg | technorati