Groovy / Grails Hibernate无法创建bean事务

时间:2018-06-15 18:35:20

标签: html hibernate tomcat grails groovy

这是我使用webapp启动tomcat时出现的错误。我确定它与hibernate插件有关。

我在12.04版LTS ubuntu上运行了Web应用程序,现在升级到18.04 LTS。我将grails web-app编译为.war并且没有重新编译战争。我认为它将继续从一个版本的ubuntu工作到另一个版本。

15-Jun-2018 12:22:32.580 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
15-Jun-2018 12:22:33.287 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
15-Jun-2018 12:22:38.637 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener]
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    ... 5 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    ... 5 more
Caused by: org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    ... 5 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    ... 5 more
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
    at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
    ... 7 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
    ... 8 more

15-Jun-2018 12:22:38.647 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext
15-Jun-2018 12:22:38.955 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
15-Jun-2018 12:22:38.955 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
15-Jun-2018 12:22:38.956 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: attributeAdded('StockTicker', 'async.Stockticker@306acdc')

感谢您提供任何帮助或提示!!

1 个答案:

答案 0 :(得分:1)

关键是这一个Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException

您在新版本的Ubuntu上运行此Java运行时似乎不同。是不是偶然的Java 9?如果是这样,您可能会遇到此处描述的问题How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9

您可以按照该答案中的说明修复问题,或安装以前版本的Java并使用它来运行Grails应用程序