You can download the sample code for this project from here
But you will have to make some additional changes to your portlet if you want to pass these object between portlets installed on different severs using WSRP. In case when objects are hosted on different server then portal server will serialize the complex object using JAXB and then send it to consumer. I changed my existing Contact object like this to make it work in WSRP
package com.webspherenotes.portlet.events;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Contact implements Serializable{
private static final long serialVersionUID = -1637774642655976822L;
private String firstName;
private String lastName;
private String email;
public Contact(){
}
public Contact(String firstName, String lastName, String email) {
super();
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
I had to annotate the Contact object by adding
@XmlRootElement
this. You will have to copy the contact.jar in shared library of both producer and consumer. Also make sure that Contact class has no-arg constructor.When my Contact.java class did not had constructor i was getting error like this.
[5/19/10 9:48:13:456 PDT] 00000071 PropertyDispa E com.ibm.wps.propertybroker.dispatch.PropertyDispatcherImpl dispatchSourceEvents EJPKB1002E: The propertybroker encountered an error while dispatching the source event {http://wpcertification.blogspot.com}hello from portlet window Control@1598316356 (SourcePortlet, [ObjectIDImpl '7_VVILMKG1009800I2DO701500G7', NAVIGATION_NODE, VP: 0, [Domain: rel], DB: 0000-FFCB6A290C00240480140D1F100A00F0], [ObjectIDImpl '6_VVILMKG10G4K30I2A4E1UM2007', CONTENT_NODE, VP: 0, [Domain: rel], DB: 0000-FFCB6A290C00123A80148AB8E0AD00E0], 100 with value com.webspherenotes.portlet.events.Contact@212c212c.
com.ibm.portal.propertybroker.exceptions.CommunicationTargetDispatchException: EJPKB1001E: An Error occurred while dispatching to the communication target
process.{http://wpcertification.blogspot.com}hello
11_VVILMKG1009800I2DO701500O3
{http://wpcertification.blogspot.com}hello
com.ibm.wps.pe.pc.util.JAXBEventPayloadWrapper
{http://wpcertification.blogspot.com}hello
for window Control@1605918648 (TargetPortlet, [ObjectIDImpl '7_VVILMKG1009800I2DO70150040', NAVIGATION_NODE, VP: 0, [Domain: rel], DB: 0000-FFCB6A290C00240480140D1F100A0004], [ObjectIDImpl '6_VVILMKG10G4K30I2A4E1UM2007', CONTENT_NODE, VP: 0, [Domain: rel], DB: 0000-FFCB6A290C00123A80148AB8E0AD00E0], 200.
at com.ibm.wps.propertybroker.standard.filter.JsrEventActionDispatcherPluginImpl.buildTargetJsrEventInformation(JsrEventActionDispatcherPluginImpl.java:263)
at com.ibm.wps.propertybroker.standard.filter.JsrEventActionDispatcherPluginImpl.dispatchCommunicationTarget(JsrEventActionDispatcherPluginImpl.java:106)
at com.ibm.wps.propertybroker.dispatch.PropertyDispatcherImpl.dispatchCommunicationTarget(PropertyDispatcherImpl.java:658)
at com.ibm.wps.propertybroker.dispatch.PropertyDispatcherImpl.dispatchCommunicationTargets(PropertyDispatcherImpl.java:611)
at com.ibm.wps.propertybroker.dispatch.PropertyDispatcherImpl.dispatchPropertyValues(PropertyDispatcherImpl.java:256)
at com.ibm.wps.propertybroker.dispatch.PropertyDispatcherImpl.dispatchSourceEvent(PropertyDispatcherImpl.java:138)
at com.ibm.wps.pe.pc.waspc.services.information.WaspcInformationProviderImpl$PortletEventProviderImpl.add(WaspcInformationProviderImpl.java:373)
at com.ibm.ws.portletcontainer.PortletContainerImpl.publishEventsToEventProvider(PortletContainerImpl.java:431)
at com.ibm.ws.portletcontainer.PortletContainerImpl.doAction(PortletContainerImpl.java:215)
at com.ibm.ws.portletcontainer.PortletContainerInvokerCollaboratorChainImpl.doCollaborator(PortletContainerInvokerCollaboratorChainImpl.java:78)
at com.ibm.ws.portletcontainer.ext.ExtCollaborator.doAction(ExtCollaborator.java:55)
at com.ibm.ws.portletcontainer.PortletContainerInvokerCollaboratorChainImpl.doCollaborator(PortletContainerInvokerCollaboratorChainImpl.java:65)
at com.ibm.ws.portletcontainer.cache.CacheInvokerCollaborator.doAction(CacheInvokerCollaborator.java:76)
at com.ibm.ws.portletcontainer.PortletContainerInvokerCollaboratorChainImpl.doCollaborator(PortletContainerInvokerCollaboratorChainImpl.java:65)
at com.ibm.ws.portletcontainer.PortletContainerImpl.processPortletAction(PortletContainerImpl.java:152)
at com.ibm.ws.portletcontainer.pcinvoker.PortletInvokerImpl$1.run(PortletInvokerImpl.java:59)
at java.security.AccessController.doPrivileged(AccessController.java:246)
at com.ibm.ws.portletcontainer.pcinvoker.PortletInvokerImpl.invokeProcessAction(PortletInvokerImpl.java:55)
at com.ibm.wps.pe.pc.waspc.core.impl.PortletInvokerImpl$3.invoke(PortletInvokerImpl.java:115)
at com.ibm.wps.pe.pc.waspc.core.impl.PortletInvokerImpl.invoke(PortletInvokerImpl.java:175)
at com.ibm.wps.pe.pc.waspc.core.impl.PortletInvokerImpl.invokeProcessAction(PortletInvokerImpl.java:113)
at com.ibm.wps.pe.pc.waspc.event.ActionEvent.execute(ActionEvent.java:78)
at com.ibm.wps.pe.pc.waspc.event.EventQueueManager.processEventLoop(EventQueueManager.java:112)
at com.ibm.wps.pe.pc.waspc.PortletContainerImpl.performEvents(PortletContainerImpl.java:206)
at com.ibm.wps.pe.pc.PortletContainerImpl.performEvents(PortletContainerImpl.java:298)
at com.ibm.wps.engine.phases.WPActionPhase.processPortlets(WPActionPhase.java:2644)
at com.ibm.wps.engine.phases.WPActionPhase.execute(WPActionPhase.java:668)
at com.ibm.wps.state.phases.AbstractActionPhase.next(AbstractActionPhase.java:130)
at com.ibm.wps.engine.Servlet.callPortal(Servlet.java:855)
at com.ibm.wps.engine.Servlet.doGet(Servlet.java:617)
at com.ibm.wps.engine.Servlet.doPost(Servlet.java:888)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at com.ibm.wps.engine.Servlet.doFilter(Servlet.java:1257)
at com.ibm.wps.resolver.servlet.ContentHandlerCleanup.doFilter(ContentHandlerCleanup.java:648)
at com.ibm.wps.resolver.servlet.AbstractFilter.doFilter(AbstractFilter.java:93)
at com.ibm.wps.engine.Servlet.service(Servlet.java:1248)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1087)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
at com.ibm.wps.engine.ExtendedLocaleFilter.doFilter(ExtendedLocaleFilter.java:113)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.wps.resolver.friendly.servlet.FriendlySelectionFilter.doFilter(FriendlySelectionFilter.java:191)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.wps.mappingurl.impl.URLAnalyzer.doFilter(URLAnalyzer.java:352)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.wps.engine.VirtualPortalFilter.doFilter(VirtualPortalFilter.java:88)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.wps.state.filter.StateCleanup.doFilter(StateCleanup.java:94)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:837)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:680)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:588)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:524)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3517)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:269)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:818)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1478)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:125)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
com.webspherenotes.portlet.events.Contact does not have a no-arg default constructor.
this problem is related to the following location:
at com.webspherenotes.portlet.events.Contact
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:66)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:389)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:236)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:381)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at com.ibm.wsspi.portletcontainer.util.EventFactory.serializeJAXB(EventFactory.java:285)
at com.ibm.wsspi.portletcontainer.util.EventFactory.serializeJAXB(EventFactory.java:166)
at com.ibm.wps.propertybroker.standard.filter.JsrEventActionDispatcherPluginImpl.buildTargetJsrEventInformation(JsrEventActionDispatcherPluginImpl.java:226)
... 72 more
Thanks for info....
ReplyDeleteSEO Company in Bangalore