java - with - Error al crear bean con el nombre ''sessionFactory'': MalformedParameterizedTypeException
osbd loggingfailureanalysisreporter (3)
Tuve los mismos problemas y otra medida ayudó: eliminar toda la carpeta .metadata. Luego, importa los proyectos desde su lugar o agrégalos desde el svn (si los usas). El problema es que no sabemos realmente qué metadatos están rotos, por lo que el siguiente paso natural es eliminarlos todos. Creo que es la limpieza más profunda posible, aparte de la reinstalación de los complementos de Eclipse +.
CUALQUIER consejo sería apreciado. Estoy perplejo...
Problema
En mi computadora portátil, cada vez que nuestra aplicación intenta cargar la aplicación-config.xml, obtengo una java.lang.reflect.MalformedParameterizedTypeException.
El mismo código EXACTO funciona en mi escritorio y en el escritorio / portátil de mi compañero de trabajo. Pero en mi computadora portátil arroja este error. Como mi computadora portátil y de escritorio son el mismo entorno de desarrollo (proyecto Java 1.6 Maven en Eclipse para Mac OS X Leopard), reduje las causas al hacer lo siguiente:
- Comprobado un nuevo proyecto de Subversion (por lo que no hay diferencias de código)
- Copié y reemplacé todo el directorio de Eclipse (por lo que no hay diferencias en la versión / complemento de Eclipse)
- Copié y reemplacé todo mi directorio .m2 (así que no hay diferencias de dependencia entre maven / project)
¿Qué podría estar causando este error en un lugar pero no en el otro? A continuación se muestra un fragmento de los beans relacionados y el error ...
Fragmento: application-config.xml<?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" />
Fragmento: JUnit Error Trace:
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
EDITAR:
Actualización: acabo de encontrar otra pista, ninguna de nuestras pruebas JUnit relacionadas con la base de datos funciona. En mi escritorio, todos pasan. En mi computadora portátil, todos fallan con la siguiente excepción:
java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.<init>(Ljava/lang/Class;Ljava/util/Collection;)V
¡Todas y cada una de las sugerencias son bienvenidas! ¡Gracias!
Supongo que tienes tarros de primavera equivocados, tal vez uno para la primavera 2.5 y uno para 3.0. El cargador de clases carga, por ejemplo, spring-core para la versión 3.0, y el resto para 2.5. Esto daría como resultado tales errores.
Sugiero que revises tu gráfico de dependencia maven y elimines todos los redundantes. Si es necesario, use <exclusions>
en su pom.
Antes de eso, limpie su proyecto en todas las máquinas.
Tuve un error similar al intentar ejecutar el servicio Mule en Mule ESB incrustado en Tomcat. La solución fue cambiar JDK de forma predeterminada:
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)
al buen viejo JDK Sun:
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)
por supuesto, podría haber sido un problema de versión / parche. Si tan solo tuviera el tiempo para investigar ...