Eclipse BIRT设计器中的springbean加载问题
我有一个问题,当从BIRT脚本数据源中的脚本运行时,Spring没有正确加载bean,而是自己运行OK 下面是一个最小的测试用例: 春豆:Eclipse BIRT设计器中的springbean加载问题,eclipse,spring,birt,Eclipse,Spring,Birt,我有一个问题,当从BIRT脚本数据源中的脚本运行时,Spring没有正确加载bean,而是自己运行OK 下面是一个最小的测试用例: 春豆: package test; import org.springframework.stereotype.Component; @Component public class TestComponent { } 上下文提供程序: package test; import org.springframework.context.ApplicationCont
package test;
import org.springframework.stereotype.Component;
@Component
public class TestComponent { }
上下文提供程序:
package test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringContextHolder {
private static ApplicationContext ac;
public static ApplicationContext getApplicationContext() {
if( ac == null ) {
ac = new ClassPathXmlApplicationContext("classpath:beans.xml");
}
return ac;
}
}
beans.xml:
<beans .......>
<context:component-scan base-package="test"></context:component-scan>
<context:annotation-config />
</beans>
这个程序运行良好,并提供了bean。但是,当我在BIRT designer(4.3.0)中通过在报表类路径首选项中设置相同的JAR来运行它们时,我得到了一个异常:
发生BIRT异常。有关更多信息,请参见下一个异常。
包装的org.springframework.beans.factory.BeanDefinitionStoreException:未能读取候选组件类:URL[jar:file:/C:/Users/xxx/.m2/repository/test/test/0.0.1-SNAPSHOT/test-0.0.1-SNAPSHOT.jar!/test/SpringContextHolder.class];嵌套异常为java.lang.ArrayIndexOutOfBoundsException:6
脚本源只是:
importPackage(Packages.test);
ts = SpringContextHolder.getApplicationContext().getBean("testComponent");
在org.springframework.asm.ClassReader中,readShort违反了某些数组边界,由此产生了异常。
Spring版本是3.2.3版本,Oracle Java 7u25,BIRT Designer 4.3.0
有人能解释这两种运行场景之间的区别吗?当eclipse运行时加载JAR时,可能会出现一些类装入器问题
importPackage(Packages.test);
ts = SpringContextHolder.getApplicationContext().getBean("testComponent");