nested exception is java.lang.IllegalArgumentException: a beanFactoryReference already exists for key jbpmConfig
|
yushanyuan
2007-07-25
请问有人遇到过这种问题吗?听说是因为重载或更新引起的。有人知道怎么解决吗?
|
|
|
cun2001
2007-09-03
我碰见过这个问题,大概的原因是因为重复加载spring的配置文件引起的,解决办法是写一个加载spring配置文件的static方法,在里面判断ApplicationContext为空的时候才加载配置文件即可:
package com.cun.jbpm.common.util; import org.springframework.context.ApplicationContext; import org.springframework.context.support.*; public class ServiceLocator { private static ApplicationContext ctx = null; public static Object getBean(String name) { if (ctx == null) { ctx = new ClassPathXmlApplicationContext( new String[] { "classpath*:/applicationContext-*.xml" }); } return ctx.getBean(name); } } |
|
|
cun2001
2007-09-03
在Action中加载service时这么写:
TestManager testManager = (TestManager) ServiceLocator .getBean("testManager"); 不要这么写: ApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] { "classpath*:/applicationContext-*.xml" }); 这样写的话相当与重复加载Spring配置文件,就会出现所谓的“a beanFactoryReference already exists for key jbpmConfig ”问题,因为你的jbpmConfig肯定是配置在Spring配置文件中的。 |

