web-dev-qa-db-fra.com

compatibilité du printemps 4.0.0 avec la mise en veille prolongée 4.30

J'utilise Spring 4.0. RELEASE jars, hibernate-coe 4.3. jar dans mon spring + hibernate projet. Je fais face à une erreur avec org.hibernate.engine.FilterDefinition n'est pas trouvé. En fait, dans les anciens pots principaux en veille prolongée, nous avons cette classe, mais pas dans la version 4.3.0. En fait, nous avons org.hibernate.engine.spi.FilterDefinition dans 4.3. version. Mais je ne sais pas comment cette classe dépend en cours d'exécution. Pendant que j'utilise glassfish server pour mon application.

Veuillez me faire savoir la compatibilité des versions spring 4.0. et hibernate 4.3. et me suggérer les dernières versions compatibles de ces deux.


Mon code est: dispatcher-servlet a

<bean id="hibernateTransactionManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="annotatedClasses">
        <list>
            <value>com.venkat.homeapp.entity.CustomerEntity</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
        </props>
    </property>
</bean>
<bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${database.driver}" />
    <property name="url" value="${database.url}" />
    <property name="username" value="${database.user}" />
    <property name="password" value="${database.password}" />
</bean>

Ma classe de contrôleur est:

@Controller
@RequestMapping("/")
@ComponentScan("com.venkat.homeapp.service")
public class HomeAppController {

@Autowired
private CustomerService customerService;
:
:
}

Le journal que je peux voir est:

INFO:   WebModule[null] ServletContext.log():No Spring WebApplicationInitializer types detected on classpath
INFO:   WebModule[null] ServletContext.log():Initializing Spring FrameworkServlet 'HomeApp'
INFO:   FrameworkServlet 'HomeApp': initialization started
INFO:   Refreshing WebApplicationContext for namespace 'HomeApp-servlet': startup date [Mon Jan 20 23:42:45 IST 2014]; root of context hierarchy
INFO:   Loading XML bean definitions from ServletContext resource [/WEB-INF/HomeApp-servlet.xml]
INFO:   Loading properties file from class path resource [jdbc.properties]
INFO:   JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
SEVERE:   Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeAppController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.venkat.homeapp.service.CustomerService com.venkat.homeapp.controller.HomeAppController.customerService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.venkat.homeapp.dao.CustomerDAO com.venkat.homeapp.service.impl.CustomerServiceImpl.customerDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.venkat.homeapp.dao.impl.CustomerDAOImpl.sessionFactory; nested exception is Java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.Java:292)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.Java:1185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.Java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.Java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.Java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.Java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.Java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.Java:700)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.Java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.Java:482)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.Java:643)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.Java:606)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.Java:657)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.Java:525)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.Java:466)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.Java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.Java:244)
    at org.Apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.Java:1583)
    at org.Apache.catalina.core.StandardWrapper.load(StandardWrapper.Java:1382)
    at org.Apache.catalina.core.StandardContext.loadOnStartup(StandardContext.Java:5670)
    at org.Apache.catalina.core.StandardContext.start(StandardContext.Java:5912)
    at com.Sun.enterprise.web.WebModule.start(WebModule.Java:691)
    at org.Apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.Java:1041)
    at org.Apache.catalina.core.ContainerBase.addChild(ContainerBase.Java:1024)
    at org.Apache.catalina.core.StandardHost.addChild(StandardHost.Java:747)
    at com.Sun.enterprise.web.WebContainer.loadWebModule(WebContainer.Java:2278)
    at com.Sun.enterprise.web.WebContainer.loadWebModule(WebContainer.Java:1924)
    at com.Sun.enterprise.web.WebApplication.start(WebApplication.Java:139)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.Java:122)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.Java:291)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.Java:352)
    at com.Sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.Java:497)
    at com.Sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.Java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.Java:491)
    at com.Sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.Java:527)
    at com.Sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.Java:523)
    at Java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.Java:356)
    at com.Sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.Java:522)
    at com.Sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.Java:546)
    at com.Sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.Java:1423)
    at com.Sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.Java:108)
    at com.Sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.Java:1762)
    at com.Sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.Java:1674)
    at com.Sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.Java:534)
    at com.Sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.Java:224)
    at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.Java:297)
    at com.Sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.Java:246)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.Java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.Java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.Java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.Java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.Java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.Java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.Java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.Java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.Java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.Java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.Java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.Java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.Java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.Java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.Java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.Java:544)
    at Java.lang.Thread.run(Thread.Java:744)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.venkat.homeapp.service.CustomerService com.venkat.homeapp.controller.HomeAppController.customerService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.venkat.homeapp.dao.CustomerDAO com.venkat.homeapp.service.impl.CustomerServiceImpl.customerDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.venkat.homeapp.dao.impl.CustomerDAOImpl.sessionFactory; nested exception is Java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.Java:508)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.Java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.Java:289)
    ... 65 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.venkat.homeapp.dao.CustomerDAO com.venkat.homeapp.service.impl.CustomerServiceImpl.customerDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.venkat.homeapp.dao.impl.CustomerDAOImpl.sessionFactory; nested exception is Java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.Java:292)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.Java:1185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.Java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.Java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.Java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.Java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.Java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.Java:1014)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.Java:957)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.Java:855)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.Java:480)
    ... 67 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.venkat.homeapp.dao.CustomerDAO com.venkat.homeapp.service.impl.CustomerServiceImpl.customerDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.venkat.homeapp.dao.impl.CustomerDAOImpl.sessionFactory; nested exception is Java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.Java:508)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.Java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.Java:289)
    ... 78 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.venkat.homeapp.dao.impl.CustomerDAOImpl.sessionFactory; nested exception is Java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.Java:292)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.Java:1185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.Java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.Java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.Java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.Java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.Java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.Java:1014)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.Java:957)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.Java:855)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.Java:480)
    ... 80 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.venkat.homeapp.dao.impl.CustomerDAOImpl.sessionFactory; nested exception is Java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.Java:508)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.Java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.Java:289)
    ... 91 more
Caused by: Java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;
    at Java.lang.Class.getDeclaredFields0(Native Method)
    at Java.lang.Class.privateGetDeclaredFields(Class.Java:2397)
    at Java.lang.Class.getDeclaredFields(Class.Java:1806)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.Java:392)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.Java:332)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.Java:908)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.Java:512)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.Java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.Java:304)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.Java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.Java:300)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.Java:195)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.Java:1014)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.Java:957)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.Java:855)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.Java:480)
    ... 93 more
Caused by: Java.lang.ClassNotFoundException: org.hibernate.engine.FilterDefinition
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1761)
    at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1611)
    ... 109 more
31

si vous utilisez hibernate4.x

Pour résoudre l'exception provoquée par Java.lang.NoClassDefFoundError: [Lorg/hibernate/engine/FilterDefinition;

Dans dipatcher-servlet, au lieu de

 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

utilisation

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
74
Nickhil

C'est l'erreur pertinente:

Champ de câblage automatique impossible: private org.hibernate.SessionFactory com.venkat.homeapp.dao.impl.CustomerDAOImpl.sessionFactory; l'exception imbriquée est Java.lang.NoClassDefFoundError [Lorg/hibernate/engine/FilterDefinition;

et ceci est la cause probable:

  class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

voyez que vous avez à la fois des éléments hibernate4 et hibernate3. Copié de cette réponse ,

Je pense que vous devriez utiliser org.springframework.orm.hibernate4.LocalSessionFactoryBean au lieu de org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

Depuis LocalSessionFactoryBean javadoc:

REMARQUE: cette variante de LocalSessionFactoryBean nécessite Hibernate 4.0 ou supérieur. Son rôle est similaire à celui de la classe portant le même nom dans le package orm.hibernate3. Cependant, en pratique, il est plus proche de AnnotationSessionFactoryBean car son objectif principal est de bootstrap un SessionFactory à partir de l'analyse des annotations.

10
eis

Utilisez org.springframework.orm.hibernate4.LocalSessionFactoryBean à la place de org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

alors ça marchera

7
ysramkumar