ANY advice would be apprecated. I'm stumped...
Problem
On my laptop, anytime our application tries to load the application-config.xml, I get a java.lang.reflect.MalformedParameterizedTypeException.
The EXACT same code works on my desktop and my coworker's desktop/laptop. But on my laptop it throws this error. Since my laptop and desktop are the exact same development environment (Java 1.6 Maven project in Eclipse on Mac OS X Leopard), I've narrowed down the causes by doing the following:
What could possibly be causing this error in one place but not the other? Below is a snippet of the related beans and error...
<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
...
<bean id="dataServiceRepository" class="com.saic.gnosis.dao.DataServiceDao">
<constructor-arg ref="sessionFactory" />
</bean>
...
<bean id="implementationRepository" class="com.saic.gnosis.dao.ImplementationDao">
<property name="dataServiceRepository" ref="dataServiceRepository" />
<property name="implementationDetailRepository" ref="implementationDetailRepository" />
<property name="implementationStrategyFactory" ref="implementationStrategyFactory" />
</bean>
...
<bean id="implementationStrategyFactory" class="com.saic.gnosis.plant.ImplementationStrategyPlant" />
...
<bean id="implementationDetailRepository" class="com.saic.gnosis.dao.ImplementationDetailDao">
<constructor-arg ref="sessionFactory" />
</bean>
...
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="mysqlDataSource" />
<property name="packagesToScan">
<list>
<value>com.saic.gnosis.model</value>
<value>com.saic.gnosis.model.observable</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.c3p0.min_size">2</prop> <!-- Minimum number of Connections a pool will maintain at any given time. -->
<prop key="hibernate.c3p0.max_size">9</prop> <!-- Maximum number of Connections a pool will maintain at any given time. -->
<prop key="hibernate.c3p0.timeout">10</prop> <!-- Seconds a Connection can remain pooled but unused before being discarded.
Zero means idle connections never expire. -->
<prop key="hibernate.c3p0.max_statements">0</prop> <!-- The size of c3p0's global PreparedStatement cache. If both maxStatements
and maxStatementsPerConnection are zero, statement caching will not be enabled.
If maxStatements is zero but maxStatementsPerConnection is a non-zero value,
statement caching will be enabled, but no global limit will be enforced,
only the per-connection maximum. maxStatements controls the total number
of Statements cached, for all Connections. If set, it should be a fairly
large number, as each pooled Connection requires its own, distinct flock
of cached statements. As a guide, consider how many distinct PreparedStatements
are used frequently in your application, and multiply that number by maxPoolSize
to arrive at an appropriate value. Though maxStatements is the JDBC standard
parameter for controlling statement caching, users may find c3p0's alternative
maxStatementsPerConnection more intuitive to use. -->
</props>
</property>
</bean>
<bean id="mysqlDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://database.com/ourProject" />
<property name="user" value="ourUser" />
<property name="password" value="ourPass" />
<property name="initialPoolSize" value="4" />
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
java.lang.ExceptionInInitializerError
at com.saic.gnosis.updater.task.ConnectionCommandFileWriterTask.<init>(ConnectionCommandFileWriterTask.java:16)
at com.saic.gnosis.updater.CiscoDeviceConfiguratorTest.initializeSpyObjects(CiscoDeviceConfiguratorTest.java:120)
at com.saic.gnosis.updater.CiscoDeviceConfiguratorTest.initializeTestObjects(CiscoDeviceConfiguratorTest.java:110)
at com.saic.gnosis.updater.CiscoDeviceConfiguratorTest.setUp(CiscoDeviceConfiguratorTest.java:105)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'implementationRepository' defined in class path resource [beans/application-config.xml]: Cannot resolve reference to bean 'dataServiceRepository' while setting bean property 'dataServiceRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataServiceRepository' defined in class path resource [beans/application-config.xml]: Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [beans/application-config.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.saic.gnosis.dao.BeanDao.<clinit>(BeanDao.java:35)
... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataServiceRepository' defined in class path resource [beans/application-config.xml]: Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [beans/application-config.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:495)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:162)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:835)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
... 46 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [beans/application-config.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
... 61 more
Caused by: java.lang.reflect.MalformedParameterizedTypeException
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:42)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:35)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:77)
at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:86)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:122)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:82)
at java.lang.Class.getGenericInterfaces(Class.java:794)
at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:161)
at org.springframework.core.GenericTypeResolver.resolveReturnType(GenericTypeResolver.java:99)
at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:88)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
... 70 more
Update - I just found another clue, none of our database-related JUnit tests work. On my desktop they all pass. On my laptop, they all fail with the following exception:
java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.<init>(Ljava/lang/Class;Ljava/util/Collection;)V
Any and all suggestions welcome! Thanks!
I would assume you have wrong spring jars - perhaps one for spring 2.5 and one for 3.0. The classloader loads, say, spring-core for version 3.0, and the rest for 2.5. This would result in such errors.
I'd suggest going through your maven dependency graph and remove all redundant ones. If necessary, use <exclusions>
in your pom.
Before that clean your project on all machines.
I had similiar error when trying to run Mule service on Mule ESB embedded in Tomcat. The solution was to change JDK from default:
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.1) (6b18-1.8.1-0ubuntu1)
OpenJDK 64-Bit Server VM (build 16.0-b13, mixed mode)
to good old Sun JDK:
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)
of course, it might have been version/patch issue. If only I had the time to investigate...
I had the same problems and another measure helped: delete the whole .metadata folder. Later import projects from their place or checkout them from the svn(if you use some). The problem is that we don't really know, what metadata are broken, so the natural next step is to delete all of them. I think, it is the deepest possible cleaning apart from reinstallation of Eclipse + plugins.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With