几乎可以正常工作了,但有时它会抛出异常(请参阅stacktrace),谁能告诉我为什么!我的工作流定义有一些常规代码,此代码用于连接到数据库并根据分类属性确定网络内容的下一步。这是 Liferay 6.1 ga 1,kaleo 工作流定义代码(条件节点):
<script> <![CDATA[
import groovy.sql.Sql;
import java.util.List;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.kernel.workflow.WorkflowHandler;
import com.liferay.portal.kernel.workflow.WorkflowHandlerRegistryUtil;
import com.liferay.portlet.asset.model.AssetCategory;
import com.liferay.portlet.asset.model.AssetEntry;
import com.liferay.portlet.asset.model.AssetRenderer;
import com.liferay.portlet.asset.model.AssetRendererFactory;
import com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil;
import com.liferay.portal.model.WorkflowInstanceLink;
import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil;
try{
String className = (String)workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME);
WorkflowHandler workflowHandler = WorkflowHandlerRegistryUtil.getWorkflowHandler(className);
AssetRendererFactory assetRendererFactory = workflowHandler.getAssetRendererFactory();
long classPK = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
long companyId = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
long groupId = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_GROUP_ID));
AssetRenderer assetRenderer = workflowHandler.getAssetRenderer(classPK);
AssetEntry assetEntry = assetRendererFactory.getAssetEntry(assetRendererFactory.getClassName(), assetRenderer.getClassPK());
List<AssetCategory> assetCategories = assetEntry.getCategories();
WorkflowInstanceLink workflowInstanceLink = WorkflowInstanceLinkLocalServiceUtil.getWorkflowInstanceLink(companyId, groupId, className, classPK);
long instanceId = workflowInstanceLink.getWorkflowInstanceId();
sql = Sql.newInstance('jdbc:postgresql://localhost:5432/CGATE1.1_TNMT_KG', 'postgres', '1234567', 'org.postgresql.Driver');
long cateId;
String[] nextTransitionName;
HashMap<String, Object> context = new HashMap<String, Object>();
for (AssetCategory assetCategory : assetCategories) {
cateId = assetCategory.getCategoryId();
row = sql.firstRow("SELECT cchc_fun_cmsworkflow_nexttask(?,?) as nexttask", [cateId, instanceId]);
if(row.nexttask != null){
String nextTaskStr = row.nexttask;
if(nextTaskStr.equalsIgnoreCase("Done")){
returnValue = "Duyệt"; return;
}
context.put("roleprefix", nextTaskStr);
serviceContext.setAttribute("context", context);
nextTransitionName = nextTaskStr.split('_');
if(nextTransitionName[0].equalsIgnoreCase("BT")){
returnValue = "Biên tập"; return;
}else if(nextTransitionName[0].equalsIgnoreCase("LD")){
returnValue = "Lãnh đạo"; return;
}else if(nextTransitionName[0].equalsIgnoreCase("XB")){
returnValue = "Xuất bản";
System.out.println("Xuất bản");
return;
}
}
}
}catch(Exception ex){
returnValue ="Duyệt"; return;
}
returnValue = "Hủy";
]]> </script>
<script-language>groovy</script-language>
堆栈跟踪:
07:58:39,150 ERROR [ParallelDestination:109] Unable to process message {destinationName=liferay/kaleo_graph_walker, response=null, responseDestinationName=null, responseId=null, payload=com.liferay.portal.workflow.kaleo.runtime.graph.PathElement@161a2f1, values={principalPassword=null, principalName=11322, companyId=1}}
com.liferay.portal.kernel.messaging.MessageListenerException: java.lang.reflect.UndeclaredThrowableException
at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:31)
at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:65)
at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:106)
at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:669)
at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:580)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.reflect.UndeclaredThrowableException
at $Proxy293.eval(Unknown Source)
at com.liferay.portal.kernel.scripting.ScriptingUtil.eval(ScriptingUtil.java:40)
at com.liferay.portal.workflow.kaleo.runtime.condition.ScriptingConditionEvaluator.evaluate(ScriptingConditionEvaluator.java:40)
at com.liferay.portal.workflow.kaleo.runtime.condition.MultiLanguageConditionEvaluator.evaluate(MultiLanguageConditionEvaluator.java:47)
at com.liferay.portal.workflow.kaleo.runtime.node.ConditionNodeExecutor.doExecute(ConditionNodeExecutor.java:65)
at com.liferay.portal.workflow.kaleo.runtime.node.BaseNodeExecutor.execute(BaseNodeExecutor.java:78)
at com.liferay.portal.workflow.kaleo.runtime.graph.DefaultGraphWalker.follow(DefaultGraphWalker.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:320)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
at com.liferay.portal.dao.jdbc.aop.DynamicDataSourceTransactionInterceptor.invoke(DynamicDataSourceTransactionInterceptor.java:44)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy462.follow(Unknown Source)
at com.liferay.portal.workflow.kaleo.runtime.graph.messaging.PathElementMessageListener.doReceive(PathElementMessageListener.java:54)
at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:25)
... 5 more
Caused by: java.lang.Exception: java.lang.VerifyError: (class: org/codehaus/groovy/runtime/ArrayUtil, method: createArray signature: ()[Ljava/lang/Object;) Illegal type in constant pool
at com.liferay.portal.kernel.messaging.proxy.ProxyRequest.execute(ProxyRequest.java:66)
at com.liferay.portal.kernel.messaging.proxy.ProxyMessageListener.receive(ProxyMessageListener.java:50)
at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:65)
at com.liferay.portal.kernel.messaging.SynchronousDestination.send(SynchronousDestination.java:39)
at com.liferay.portal.kernel.messaging.sender.DirectSynchronousMessageSender.send(DirectSynchronousMessageSender.java:60)
at com.liferay.portal.kernel.messaging.sender.DefaultSingleDestinationSynchronousMessageSender.send(DefaultSingleDestinationSynchronousMessageSender.java:41)
at com.liferay.portal.messaging.proxy.MessagingProxyAdvice.doInvokeSynchronous(MessagingProxyAdvice.java:106)
at com.liferay.portal.messaging.proxy.MessagingProxyAdvice.invoke(MessagingProxyAdvice.java:60)
at sun.reflect.GeneratedMethodAccessor1870.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
... 28 more
Caused by: java.lang.VerifyError: (class: org/codehaus/groovy/runtime/ArrayUtil, method: createArray signature: ()[Ljava/lang/Object;) Illegal type in constant pool
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:210)
at org.codehaus.groovy.ast.builder.AstBuilderTransformation.visit(AstBuilderTransformation.groovy:62)
at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:302)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:814)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:511)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:487)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:727)
at groovy.lang.GroovyShell.parse(GroovyShell.java:739)
at groovy.lang.GroovyShell.parse(GroovyShell.java:766)
at groovy.lang.GroovyShell.parse(GroovyShell.java:757)
at com.liferay.portal.scripting.groovy.GroovyExecutor.getCompiledScript(GroovyExecutor.java:90)
at com.liferay.portal.scripting.groovy.GroovyExecutor.eval(GroovyExecutor.java:51)
at com.liferay.portal.scripting.ScriptingImpl.eval(ScriptingImpl.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.liferay.portal.kernel.util.MethodHandler.invoke(MethodHandler.java:83)
at com.liferay.portal.kernel.messaging.proxy.ProxyRequest.execute(ProxyRequest.java:57)
... 45 more