Jai’s Weblog – Tech, Security & Fun…

Tech, Security & Fun…

  • Jaibeer Malik

    Jaibeer Malik
  • View Jaibeer Malik's profile on LinkedIn
  • Subscribe

  • Feedburner

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 29 other followers

  • Archives

  • Categories

  • Stats

    • 379,210
  • Live Traffic

Wicket Portlet Development on WebSphere Portal – Lessons Learnt

Posted by Jai on May 4, 2009

This post will share some of the lessons learnt during JSR 286 Wicket (1.4-rc2) Portlet Development on WebSphere Portal 6.1. Some of the issues were only specific to a particular environment like it was working fine on local dev environment but it failed on testing environment. For some of the issues, I have not debugged the cause of the problem but would like to share what worked in my case.

Portlet xsd event-definition Element Declaration:

The first time when I added event-definition in the portlet deployment descriptor (portlet.xml), I got the following error:


Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'portlet'. One of '{"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":event-definition, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":public-render-parameter, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":listener, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":container-runtime-option}' is expected.
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at com.ibm.wps.pe.mgr.deployment.std.DeploymentDataParserStd.getPortletApplicationInfo(DeploymentDataParserStd.java:226)

I checked with the eclipse xml validation and it seems fine and eclipse showed no error. Then I cross checked it with the xsd schema (portlet-app_2_0.xsd), and moved the event-definition element in the end of the file and it worked well.

IWAL0072E Default namespace is empty:

As soon as I declared the event-definition element, the xml validation failed giving error:

IWAL0072E Default namespace is empty

Even if for event-definition I declared separate namespace and was using that one only, it was making the default namespace decalaration mandatory.

<default-namespace>http://www.test.com/portlets/</default-namespace&gt;

WebSphere Portlet Wiring:

Lets say we have three portlets A,B & C on the same page.

Portlet Description Publish Event Process Event
A List items item-selected
B Item details item-selected
C Add/Update item details item-selected

Update the wiring between A-B & A-C on the page in websphere portal..

If I select item on A, the event is published and potlets B & C process the event, fair enough.

If I add/update item details on C, Portlet B data is getting refreshed but portlet A list data, lets say showing some item information also, is not getting refreshed.

The problem seems like if we have wiring from A-C and no wiring between B-C, the portlet B will get refreshed but not A.

Portlet Description Publish Event Process Event
A List items item-selected item-udpated
B Item details item-selected
C Add/Update item details item-updated item-selected

If I create new event for portlet C like item-updated and wire it back to portlet A, things like to work fine. And as there is wiring between B and C, B data is refreshed all the time.

WicketFilter incompatible with javax.servlet.Filter

While deploying my wicket application on WebSphere Portal, I got the follwing error:


4/17/09 10:59:20:087 IST] 0000002a WebApp      E   [Servlet Error]-[Filter [wicket.testlist]: not a filter class]:
java.lang.ClassCastException: org.apache.wicket.protocol.http.WicketFilter incompatible with javax.servlet.Filter
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager._loadFilter(WebAppFilterManager.java:427)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.loadFilter(WebAppFilterManager.java:385)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterInstanceWrapper(WebAppFilterManager.java:244)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterChain(WebAppFilterManager.java:302)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:815)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:742)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:695)
       at com.ibm.ws.wswebcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:101)
       at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:818)
       at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:768)
       at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
       at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
       at com.ibm.ws.portletcontainer.core.impl.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:98)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.processInclude(WicketPortlet.java:803)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.processMimeResponseRequest(WicketPortlet.java:663)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.processRequest(WicketPortlet.java:614)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.doView(WicketPortlet.java:473)
       at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
       at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
       at com.ibm.ws.portletcontainer.invoker.impl.PortletFilterChainImpl.doFilter(PortletFilterChainImpl.java:128)

My wicket application lib folder contains servlet-api-2.3.jar, all wicket jars including wicket-1.4-rc2.jar,wicket-spring-1.4-rc2.jar and wicket-spring-annot-1.3.5.jar files, which is working fine on local environment using RAD 7.5 and WebSphere Portal 6.1 but failed on test environment while deploying as a war file.

I removed the servlet-api-2.3.jar file and got following error:

[4/17/09 11:25:40:916 IST] 00000026 WebApp        E   [Servlet Error]-[Filter [wicket.portlet.test]: could not be initialized]: java.lang.NoClassDefFoundError:org.apache.wicket.spring.injection.annot.SpringComponentInjector
(initialization failure)
       at java.lang.J9VMInternals.initialize(J9VMInternals.java:132)
       at com.test.TestApplication.init(TestApplication.java:17)
       at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:695)
       at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.init(FilterInstanceWrapper.java:142)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager._loadFilter(WebAppFilterManager.java:471)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.loadFilter(WebAppFilterManager.java:385)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterInstanceWrapper(WebAppFilterManager.java:244)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterChain(WebAppFilterManager.java:302)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:815)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:742)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:695)
       at com.ibm.ws.wswebcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:101)
       at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:818)
       at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:768)
       at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
       at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
       at com.ibm.ws.portletcontainer.core.impl.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:98)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.processInclude(WicketPortlet.java:803)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.processMimeResponseRequest(WicketPortlet.java:663)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.processRequest(WicketPortlet.java:614)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.doView(WicketPortlet.java:473)
       at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
       at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
       at com.ibm.ws.portletcontainer.invoker.impl.PortletFilterChainImpl.doFilter(PortletFilterChainImpl.java:128)
       at com.ibm.wps.propertybroker.standard.filter.C2APortletFilter.doFilter(C2APortletFilter.java:183)
       at com.ibm.ws.portletcontainer.invoker.impl.PortletFilterChainImpl.doFilter(PortletFilterChainImpl.java:120)
       at com.ibm.ws.portletcontainer.invoker.impl.PortletServlet.doDispatch(PortletServlet.java:573)
       at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:114)

Then I removed wicket-spring-1.4-rc2.jar from lib folder, keeping wicket-spring-annot-1.3.5.jar inside lib folder as both contain the
SpringComponentInjector class file, which caused the following error:


[4/17/09 11:31:23:079 IST] 0
0000026 WebApp        E   [Servlet Error]-[Filter [wicket.portlet.test]: could not be initialized]:
java.lang.NoClassDefFoundError:org.apache.wicket.spring.ISpringContextLocator
       at java.lang.J9VMInternals.verifyImpl(Native Method)
       at java.lang.J9VMInternals.verify(J9VMInternals.java:68)
       at java.lang.J9VMInternals.initialize(J9VMInternals.java:129)
       at com.test.TestApplication.init(TestApplication.java:17)
       at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:695)
       at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.init(FilterInstanceWrapper.java:142)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager._loadFilter(WebAppFilterManager.java:471)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.loadFilter(WebAppFilterManager.java:385)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterInstanceWrapper(WebAppFilterManager.java:244)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.getFilterChain(WebAppFilterManager.java:302)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:815)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:742)
       at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:695)
       at com.ibm.ws.wswebcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:101)
       at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:818)
       at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:768)
       at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
       at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
       at com.ibm.ws.portletcontainer.core.impl.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:98)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.processInclude(WicketPortlet.java:803)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.processMimeResponseRequest(WicketPortlet.java:663)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.processRequest(WicketPortlet.java:614)
       at org.apache.wicket.protocol.http.portlet.WicketPortlet.doView(WicketPortlet.java:473)
       at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
       at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
       at com.ibm.ws.portletcontainer.invoker.impl.PortletFilterChainImpl.doFilter(PortletFilterChainImpl.java:128)
       at com.ibm.wps.propertybroker.standard.filter.C2APortletFilter.doFilter(C2APortletFilter.java:183)
       at com.ibm.ws.portletcontainer.invoker.impl.PortletFilterChainImpl.doFilter(PortletFilterChainImpl.java:120)
       at com.ibm.ws.portletcontainer.invoker.impl.PortletServlet.doDispatch(PortletServlet.java:573)
       at com.ibm.ws.portletcontainer.invoker.impl.PortletServletCollaboratorChainImpl.doCollaborator(PortletServletCollaboratorChainImpl.java:114)

And then I removed wicket-spring-annot-1.3.5.jar file and did put back the wicket-spring-1.4-rc2.jar file.

It all worked!!!

I am not sure why it was working fine on local but not on test environment. No idea if it is related to the WebSphere Portal class loading strategy or something else, but I didn’t look further for details.

Hope these small things help you also to debug it further or at least to move forward.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: