无法创建请求的服务[org.hibernate.service.jta.platform.spi.JtaPlatform] [英] Unable to create requested service [org.hibernate.service.jta.platform.spi.JtaPlatform]

查看:95
本文介绍了无法创建请求的服务[org.hibernate.service.jta.platform.spi.JtaPlatform]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用spring3hibernate4和maven3,我的这段代码给了我这个错误:

I am using spring3, hibernate4, and maven3 and my this code gives me this error:

Unable to create requested service [org.hibernate.service.jta.platform.spi.JtaPlatform]

 <?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:util="http://www.springframework.org/schema/util"
            xmlns:context="http://www.springframework.org/schema/context"
            xmlns:tx="http://www.springframework.org/schema/tx"
            xmlns:jee="http://www.springframework.org/schema/jee"
            xmlns:mvc="http://www.springframework.org/schema/mvc" 
            xsi:schemaLocation="http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    http://www.springframework.org/schema/mvc 
                    http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
                    http://www.springframework.org/schema/util
                    http://www.springframework.org/schema/util/spring-util-3.0.xsd
                    http://www.springframework.org/schema/tx 
                    http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
                    http://www.springframework.org/schema/context 
                    http://www.springframework.org/schema/context/spring-context.xsd
                    http://www.springframework.org/schema/jee 
                    http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">

            <util:properties id="hibernateProperties" location="classpath:hibernate.properties" />
            <tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager"/>
            <context:component-scan base-package="com.ecom.data.access.controller" />
            <context:component-scan base-package="com.ecom.data.access.model" />
            <mvc:annotation-driven />
            <bean id="usermanagementSessionFactory"
            class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
            <property name="dataSource" ref="usermanagementDataSource" />
            <property name="configLocation" value="classpath:hibernate.cfg.xml" />
            <!-- <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" /> -->
            <property name="annotatedClasses">
                             <list> 
                                     <value>com.ecom.data.access.model.User</value>
                                     <value>com.ecom.data.access.controller.LoginController</value>
                                     <value>com.ecom.data.access.dao.MyFactory</value>
                             </list>
                     </property>
            <property name="hibernateProperties" ref="hibernateProperties" />
            </bean>

                <jee:jndi-lookup id="usermanagementDataSource" jndi-name="java:jboss/datasources/usermanagementDS" />

                <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
            init-method="init" destroy-method="close">
            <property name="forceShutdown" value="false" />
            <property name ="startupTransactionService" value="false"/>
            </bean>

            <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
            <property name="transactionTimeout" value="30" />
            </bean>

            <bean id="transactionManager"
            class="org.springframework.transaction.jta.JtaTransactionManager">
            <property name="transactionManager" ref="atomikosTransactionManager" />
            <property name="userTransaction" ref="atomikosUserTransaction" />
            </bean>

            <bean id="User" class="com.ecom.data.access.model.User"/>
            <bean id="myFactory" class="com.ecom.data.access.dao.MyFactory"/>
            </beans>

休眠属性文件

hibernate.validator.apply_to_ddl=false
hibernate.validator.autoregister_listeners=false
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=false
hibernate.format_sql=true
#hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory
hibernate.hbm2ddl.auto=validate
hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider

hibernate.max_fetch_depth=2
hibernate.default_batch_fetch_size=32

hibernate.transaction.manager_lookup_class=com.atomikos.icatch.jta.hibernate4.TransactionManagerLookup
hibernate.transaction.factory_class=org.hibernate.transaction.CMTTransactionFactory

错误:

 Error creating bean with name 'usermanagementSessionFactory' defined in class path resource [applicationContext-dao.xml]: Invocation of init method failed; nested exception is
    hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jta.platform.spi.JtaPlatform]
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486) [spring-beans-3.2.1.RELEASE
    ]
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) [spring-beans-3.2.1.RELEASE.ja
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) [spring-beans-3.2.1.RELEASE.jar:
           at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.1.RELEASE.jar:]
           at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.1.RELEASE.jar:]
           at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.1.RELEASE.jar:]
           at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.1.RELEASE.jar:]
           at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608) [spring-beans-3.2.1.RELEASE.jar:]
           at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) [spring-context-3.2.1.RELEASE.jar
           at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) [spring-context-3.2.1.RELEASE.jar:]
           at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) [spring-web-3.2.2.RELEASE.jar:]
           at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-3.2.2.RELEASE.jar:]
           at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.2.RELEASE.jar:]
           at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3368) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:3821) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
           at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)
           at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_18]
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_18]
           at java.lang.Thread.run(Thread.java:619) [:1.6.0_18]
    aused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jta.platform.spi.JtaPlatform]
           at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:186) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:102) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2276) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2272) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1741) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1781) [hibernate-core-4.1.10.Final.jar:]
           at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:247) [spring-orm-3.2.2.RELEASE.jar:]
           at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:373) [spring-orm-3.2.2.RELEASE.jar:]
           at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:358) [spring-orm-3.2.2.RELEASE.jar:]
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545) [spring-beans-3.2.1.RELE
    ar:]
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483) [spring-beans-3.2.1.RELEASE
    ]
           ... 20 more
    aused by: org.hibernate.service.jta.platform.spi.JtaPlatformException: Unable to build org.hibernate.service.jta.platform.internal.TransactionManagerLookupBridge from specifie
    .hibernate.transaction.TransactionManagerLookup implementation: com.atomikos.icatch.jta.hibernate4.TransactionManagerLookup
           at org.hibernate.service.jta.platform.internal.JtaPlatformInitiator.mapLegacyClasses(JtaPlatformInitiator.java:155) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.jta.platform.internal.JtaPlatformInitiator.getConfiguredPlatform(JtaPlatformInitiator.java:78) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.jta.platform.internal.JtaPlatformInitiator.initiateService(JtaPlatformInitiator.java:60) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.jta.platform.internal.JtaPlatformInitiator.initiateService(JtaPlatformInitiator.java:47) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176) [hibernate-core-4.1.10.Final.jar:]
           ... 32 more

    4:57:12,923 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SpringMVC]] (MSC service thread 1-4) Exception sending context initialized event to list
    instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usermanagement
    onFactory' defined in class path resource [applicationContext-dao.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unabl
    create requested service [org.hibernate.service.jta.platform.spi.JtaPlatform]
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486) [spring-beans-3.2.1.RELEASE
    ]
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524) [spring-beans-3.2.1.RELEASE.ja
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) [spring-beans-3.2.1.RELEASE.jar:
           at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) [spring-beans-3.2.1.RELEASE.jar:]
           at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) [spring-beans-3.2.1.RELEASE.jar:]
           at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) [spring-beans-3.2.1.RELEASE.jar:]
           at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.1.RELEASE.jar:]
           at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608) [spring-beans-3.2.1.RELEASE.jar:]
           at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) [spring-context-3.2.1.RELEASE.jar
           at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) [spring-context-3.2.1.RELEASE.jar:]
           at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) [spring-web-3.2.2.RELEASE.jar:]
           at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-3.2.2.RELEASE.jar:]
           at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.2.RELEASE.jar:]
           at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3368) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:3821) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
           at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
           at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)
           at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_18]
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_18]
           at java.lang.Thread.run(Thread.java:619) [:1.6.0_18]
    aused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jta.platform.spi.JtaPlatform]
           at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:186) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:102) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2276) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2272) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1741) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1781) [hibernate-core-4.1.10.Final.jar:]
           at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:247) [spring-orm-3.2.2.RELEASE.jar:]
           at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:373) [spring-orm-3.2.2.RELEASE.jar:]
           at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:358) [spring-orm-3.2.2.RELEASE.jar:]
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545) [spring-beans-3.2.1.RELE
    ar:]
           at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483) [spring-beans-3.2.1.RELEASE
    ]
           ... 20 more
    aused by: org.hibernate.service.jta.platform.spi.JtaPlatformException: Unable to build org.hibernate.service.jta.platform.internal.TransactionManagerLookupBridge from specifie
    .hibernate.transaction.TransactionManagerLookup implementation: com.atomikos.icatch.jta.hibernate4.TransactionManagerLookup
           at org.hibernate.service.jta.platform.internal.JtaPlatformInitiator.mapLegacyClasses(JtaPlatformInitiator.java:155) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.jta.platform.internal.JtaPlatformInitiator.getConfiguredPlatform(JtaPlatformInitiator.java:78) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.jta.platform.internal.JtaPlatformInitiator.initiateService(JtaPlatformInitiator.java:60) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.jta.platform.internal.JtaPlatformInitiator.initiateService(JtaPlatformInitiator.java:47) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69) [hibernate-core-4.1.10.Final.jar:]
           at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176) [hibernate-core-4.1.10.Final.jar:]
           ... 32 more

    4:57:13,028 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-4) Error listenerStart
    4:57:13,028 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-4) Context [/SpringMVC] startup failed due to previous errors
    4:57:13,046 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SpringMVC]] (MSC service thread 1-4) Closing Spring root WebApplicationContext
    4:57:13,050 INFO  [org.jboss.web] (MSC service thread 1-4) registering web context: /SpringMVC
    4:57:13,055 INFO  [org.jboss.as] (MSC service thread 1-1) JBoss AS 7.0.2.Final "Arc" started in 9904ms - Started 184 of 241 services (57 services are passive or on-demand)
    4:57:13,115 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "SpringMVC.war"

推荐答案

我用hibernate.transaction.jta.platform_resolver做到了,在此.

这篇关于无法创建请求的服务[org.hibernate.service.jta.platform.spi.JtaPlatform]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆