无法在Module中定义类org.joda.time.contrib.hibernate.PersistentDateTime

时间:2014-12-05 15:30:49

标签: hibernate jboss jodatime wildfly-8

我正在尝试使用joda-time-hibernate-1.0.jar添加第三方模块。当我在eclipse服务器运行时从模块添加它时它工作正常。

但是在部署代码时运行服务器时给出了这个错误。

WARN  [org.jboss.modules] (ServerService Thread Pool -- 54) Failed to define class org.joda.time.contrib.hibernate.PersistentDateTime in Module "common.thirdrdparty.lib:main" from local module loader @736e9adb (finder: local module finder @6d21714c (roots: C:\wildfly-8.1.0\modules,C:\wildfly-8.1.0\modules\system\layers\base)): java.lang.LinkageError: Failed to link org/joda/time/contrib/hibernate/PersistentDateTime (Module "common.thirdrdparty.lib:main" from local module loader @736e9adb (finder: local module finder @6d21714c (roots: C:\wildfly-8.1.0\modules,C:\wildfly-8.1.0\modules\system\layers\base)))
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:487) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:277) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:92) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.Module.loadModuleClass(Module.java:568) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:222) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at java.lang.ClassLoader.loadClass(Unknown Source) [rt.jar:1.8.0_25]
    at java.lang.ClassLoader.loadClass(Unknown Source) [rt.jar:1.8.0_25]
    at java.lang.Class.forName0(Native Method) [rt.jar:1.8.0_25]
    at java.lang.Class.forName(Unknown Source) [rt.jar:1.8.0_25]
    at org.hibernate.annotations.common.util.StandardClassLoaderDelegateImpl.classForName(StandardClassLoaderDelegateImpl.java:49) [hibernate-commons-annotations-4.0.4.Final.jar:4.0.4.Final]
    at org.hibernate.cfg.annotations.SimpleValueBinder.fillSimpleValue(SimpleValueBinder.java:491) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.cfg.SetSimpleValueTypeSecondPass.doSecondPass(SetSimpleValueTypeSecondPass.java:42) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.cfg.Configuration.processSecondPassesOfType(Configuration.java:1470) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1418) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:843) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:397) [hibernate-core-4.3.5.Final.jar:4.3.5.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:842) [hibernate-entitymanager-4.3.5.Final.jar:4.3.5.Final]
    at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) [jipijapa-hibernate4-3-1.0.1.Final.jar:]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0_25]
    at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:474) [wildfly-security-manager-1.0.0.Final.jar:1.0.0.Final]
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) [wildfly-jpa-8.1.0.Final.jar:8.1.0.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_25]
    at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_25]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final.jar:2.1.1.Final]
Caused by: java.lang.NoClassDefFoundError: org/hibernate/usertype/EnhancedUserType
    at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.8.0_25]
    at java.lang.ClassLoader.defineClass(Unknown Source) [rt.jar:1.8.0_25]
    at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:361) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482) [jboss-modules.jar:1.3.3.Final]
    ... 33 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.usertype.EnhancedUserType from [Module "common.thirdrdparty.lib:main" from local module loader @736e9adb (finder: local module finder @6d21714c (roots: C:\wildfly-8.1.0\modules,C:\wildfly-8.1.0\modules\system\layers\base))]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]

1 个答案:

答案 0 :(得分:0)

取决于hibernate-version,你可能会使用不兼容的joda-time-hibernate版本。 使用http://jadira.sourceforge.net/index.html 而是添加 <property name="jadira.usertype.autoRegisterUserTypes" value="true" /> 到你的persistence.xml