reassign task using PCTaskHelper.updateTask NullPointerException

Hi everyone,
i’m facing a problem, I want to reassign task using PCTaskHelper.updateTask as follow:


String taskID = getOfferManageS021().getTaskID();
		String newUser = getChangeUser();
		getOfferManageS021().unacceptTask();//unaccept task first
		
		TaskInfo taskInfo = new TaskInfo();
		taskInfo.setAssignedToList(new String[]{newUser});
		
		try {
			PCTaskHelper.updateTask(null, taskID, taskInfo, null);
		} catch (Exception e) {
			e.printStackTrace();
			ContextUtils.error(e);
		}

but NullPointerException occurs, who can tell why or how? my webMethods version is 9.8

2016-10-11 08:24:48 CST (jsf:INFO) [RID:6626966] - java.lang.NullPointerException
at com.webMethods.caf.portalclient.PortalClient.getItaskPortType(PortalClient.java:277)
at com.webMethods.caf.portalclient.task.PCTaskHelper.updateTask(PCTaskHelper.java:43)
at caf.war.OfferManageS02.offermanages02view.OfferManageS02ViewDefaultviewView.changeUser(OfferManageS02ViewDefaultviewView.java:799)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.el.parser.AstValue.invoke(AstValue.java:254)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)
at com.webMethods.caf.faces.application.CAFMethodExpression.invoke(CAFMethodExpression.java:73)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at com.webMethods.caf.faces.component.ViewRoot.broadcastEvents(ViewRoot.java:238)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.webMethods.caf.faces.component.ViewRoot.processApplication(ViewRoot.java:121)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.webMethods.caf.faces.portlet.PortletLifecycle.phase(PortletLifecycle.java:286)
at com.webMethods.caf.faces.portlet.PortletLifecycle.execute(PortletLifecycle.java:179)
at com.webMethods.caf.faces.portlet.FacesPortlet.processAction(FacesPortlet.java:345)
at com.webMethods.portal.framework.portletcontainer.impl.PortletApplicationHandler.process(PortletApplicationHandler.java:536)
at com.webMethods.portal.framework.portletcontainer.servlet.PortletServlet.service(PortletServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:800)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:191)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:72)
at com.webMethods.portal.framework.portletcontainer.PortletContainer.dispatch(PortletContainer.java:222)
at com.webMethods.portal.framework.portletcontainer.PortletContainer.process(PortletContainer.java:133)
at com.webMethods.portal.framework.portletcontainer.PortletContainer.processPortletAction(PortletContainer.java:111)
at com.webMethods.portal.framework.portlet.beans.rest.RestfulPCAHandler.handle(RestfulPCAHandler.java:194)
at com.webMethods.portal.framework.dispatch.DispatchManager.handle(DispatchManager.java:513)
at com.webMethods.portal.framework.dispatch.DispatchManager.handleDispatch(DispatchManager.java:432)
at com.webMethods.portal.framework.impl.PortalServlet.service(PortalServlet.java:325)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:800)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83)
at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300)
at com.webMethods.caf.faces.servlet.GZIPFilter.doFilter(GZIPFilter.java:48)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at com.webMethods.portal.framework.impl.NTLMV1Filter.doFilter(NTLMV1Filter.java:67)
at com.webMethods.portal.framework.impl.NTLMFilter.doFilter(NTLMFilter.java:26)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at com.webMethods.portal.framework.impl.RequestFilter.doFilter(RequestFilter.java:63)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at com.webMethods.portal.framework.impl.JsfPartialAjaxRequestFilter.doFilter(JsfPartialAjaxRequestFilter.java:77)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:620)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:540)
at java.lang.Thread.run(Thread.java:745)

Hi,

You can achieve the same using the task API as below.

Not sure about the issue with PCTaskHelper, but i assume it is due to the permissions on task. You cannot run update operation without accepting. There is an option available which allows you to do that but it is not part of PCTaskHelper, you can call applyChangesNoAccept as below.

 String newUser = "sysadmin";  
        getNewTask().unacceptTask();//unaccept task first  
        getNewTask().getTaskInfo().setAssignedToList(new String[]{newUser});
          
        try {  
        	getNewTask().applyChangesNoAccept();
        } catch (Exception e) {  
            e.printStackTrace();  
            ContextUtils.error(e);  
        }  
1 Like

Hi Bari ?
thanks? I will try.