0

起動時に Java コードを介してワークフローを削除する必要があります。私のコードは実行時に正しく動作しますが、起動時に実行すると例外がスローされます。Java コードを介して起動時のワークフローを削除するにはどうすればよいですか?

例えば:

私の例-context.xml:

<bean id="my-example" class="MyExamle" init-method="init">
        <property name="workflowService">
            <ref bean="WorkflowService"/>
        </property>
</bean>

MyExamle.java:

public class MyExamle {
    ...
    private WorkflowService workflowService;

    public void init() {
        PropertyCheck.mandatory(this, "workflowService", workflowService);

        AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Integer>() {
            @Override
            public Integer doWork() throws Exception {
                 Integer count = 0;
                 WorkflowDefinition reviewDef = workflowService.getDefinitionByName(
                            "activiti$activitiReview"
                 );
                 List<WorkflowInstance> workflowInstanceList = workflowService.getActiveWorkflows(
                            reviewDef.getId()
                 );
                 count = workflowInstanceList.size();
                 for (WorkflowInstance workflowInstance : workflowInstanceList) {
                          workflowService.deleteWorkflow(
                                workflowInstance.getId()
                          );
                 }
                 return count;
            }
        }, AuthenticationUtil.getSystemUserName());
    }
    ...
}

このコードは例外をスローします: org.alfresco.service.namespace.NamespaceException: Namespace prefix wf is not mapping to a namespace URI

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mrem-extention-bootstartup' defined in URL [jar:file:/C:/Alfresco/tomcat/webapps/alfresco/WEB-INF/lib/moldavia-rem.jar!/alfresco/extension/mrem-bootstartup-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.namespace.NamespaceException: Namespace prefix wf is not mapped to a namespace URI
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:63)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
    at org.apache.catalina.core.StandardService.start(StandardService.java:519)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
    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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.alfresco.service.namespace.NamespaceException: Namespace prefix wf is not mapped to a namespace URI
    at org.alfresco.service.namespace.QName.createQName(QName.java:99)
    at org.alfresco.service.namespace.QName.createQName(QName.java:121)
    at org.alfresco.repo.workflow.WorkflowQNameConverter.convertNameToQName(WorkflowQNameConverter.java:103)
    at org.alfresco.repo.workflow.WorkflowQNameConverter.convertNameToQName(WorkflowQNameConverter.java:85)
    at org.alfresco.repo.workflow.WorkflowQNameConverter.mapNameToQName(WorkflowQNameConverter.java:71)
    at org.alfresco.repo.workflow.WorkflowObjectFactory.getTaskTypeDefinition(WorkflowObjectFactory.java:409)
    at org.alfresco.repo.workflow.WorkflowObjectFactory.createTaskDefinition(WorkflowObjectFactory.java:209)
    at org.alfresco.repo.workflow.activiti.ActivitiTypeConverter.getTaskDefinition(ActivitiTypeConverter.java:155)
    at org.alfresco.repo.workflow.activiti.ActivitiTypeConverter.convert(ActivitiTypeConverter.java:144)
    at org.alfresco.repo.workflow.activiti.ActivitiWorkflowEngine.getDefinitionByName(ActivitiWorkflowEngine.java:487)
    at org.alfresco.repo.workflow.WorkflowServiceImpl.getDefinitionByName(WorkflowServiceImpl.java:342)
    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:309)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:147)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy71.getDefinitionByName(Unknown Source)
    at ru.moldavia.alfresco.workflow.WorkflowFactory.removeAllActivitiReviewWorkflow(Unknown Source)
    at ru.moldavia.alfresco.workflow.WAO.removeAllNotificationWorkflows(Unknown Source)
    at ru.moldavia.alfresco.workflow.bootstartup.WorkflowBootstartupExtention.extend(Unknown Source)
    at ru.moldavia.alfresco.bootstartup.ExtentionBootstartup.runExtentions(Unknown Source)
    at ru.moldavia.alfresco.bootstartup.ExtentionBootstartup.init(Unknown Source)
    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.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 37 more
4

1 に答える 1

1

あなたが提供した例外はあなたの質問とは関係がないと思います。データ モデルの定義を確認してください。

すべての場合で、質問に戻りますが、init() の代わりに onBootstrap() を使用してみてください。AbstractLifecycleBean クラスを拡張し、onBootstrap (ApplicationEvent イベント) と onShutdown(ApplicationEvent イベント) をオーバーライドするだけです。init() の呼び出し中に、Alfresco システムの初期化されていない部分が存在する可能性があります。

于 2012-07-16T12:44:32.403 に答える