Alex Suo
Alex Suo

Reputation: 3119

spring JTable creation throwing exception

I have a spring configuration which reliably throw exception with the following configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
	default-init-method="init">

	<!-- GUI tables -->	

	<bean id="basket.summary.table.model" class="javax.swing.table.DefaultTableModel" />
	
	<bean id="basket.summary.table" class="javax.swing.JTable">
		<constructor-arg ref="basket.summary.table.model" />
	</bean>

</beans>

And the exception I got is as following:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2890
	at org.springframework.asm.ClassReader.readClass(Unknown Source)
	at org.springframework.asm.ClassReader.accept(Unknown Source)
	at org.springframework.asm.ClassReader.accept(Unknown Source)
	at org.springframework.core.LocalVariableTableParameterNameDiscoverer.inspectClass(LocalVariableTableParameterNameDiscoverer.java:114)
	at org.springframework.core.LocalVariableTableParameterNameDiscoverer.getParameterNames(LocalVariableTableParameterNameDiscoverer.java:86)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:94)
	at org.aso.algo.gui.system.GuiMain.main(GuiMain.java:39)

I think the example is simple enough but I still couldn't figure out what caused the problem. It basically failed to construct the JTable object. I tried to specify the parameter class for the constructor-arg but no luck.

Anyone could help me please? Must missing some simple thing.

Upvotes: 0

Views: 567

Answers (1)

M. Deinum
M. Deinum

Reputation: 124441

Older Spring versions aren't compatible with JDK 1.8, especially due to the internally packaged ASM library which isn't compatible.

JDK 1.8 support was added in Spring 4, so you would need to upgrade to one of those.

Upvotes: 4

Related Questions