Hibernate 在 EntityTuplizerFactory.constructTuplizer 中失败并出现 NullPointerException?为什么?

发布于 2024-08-17 23:04:42 字数 1461 浏览 8 评论 0原文

当我尝试实例化 Hibernate 并连接 MySQL 数据库时遇到问题(请参阅下面的错误消息)。

奇怪的是,在运行 Junit 测试时,使用完全相同的 hibernate.cfg.xml 文件连接工作正常,但在从 Tomcat 运行时却无法工作......

我开始没有想法了。

有什么线索或提示去哪里寻找吗?

原因:org.hibernate.HibernateException:无法实例化默认 tuplizer [org.hibernate.tuple.entity.DynamicMapEntityTuplizer] 在org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110) 在org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135) 在 org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:69) 在 org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:323) 在 org.hibernate.persister.entity.AbstractEntityPersister。(AbstractEntityPersister.java:456) 在 org.hibernate.persister.entity.SingleTableEntityPersister。(SingleTableEntityPersister.java:131) 在 org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84) 在 org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:267) 在 org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341) 在se.fmt.atlantism.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:16) ... 38 更多 引起原因:java.lang.NullPointerException 在org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107) ... 47 更多

I have a problem when I try to instantiate Hibernate and connect with a MySQL database (see error message below).

Curiously enough the connection works fine using the exact same hibernate.cfg.xml file when running Junit tests but it refuses to work when run from Tomcat...

I am starting to run out of ideas.

Any clues or tip where to look?

Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.DynamicMapEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:69)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:456)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:131)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:267)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at se.fmt.atlantism.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:16)
... 38 more
Caused by: java.lang.NullPointerException
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
... 47 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

累赘 2024-08-24 23:04:42

我写这篇文章是为了供未来的 Google 员工参考。

我做了更多研究,但问题的根源仍然未知。然而,下面的文章让我走上了正轨。

http://www.howtogeek.com/howto/linux /installing-tomcat-6-on-ubuntu/

Ubuntu(和 Debian)中可用的 Tomcat(至少版本 6)软件包似乎无法正常工作。相反,我使用以下指南安装了 Tomcat:

http://www.ctrip.ufl .edu/tomcat6-debian-lenny-howto

虽然这可能不是最佳安装选择,但似乎有必要让 Tomcat 版本 6 在 Ubuntu 和/或 Debian Lenny 上顺利运行。

I'm writing this for future Googlers and reference.

I've done some more research and the root source of the problem is still not known. However the following article throw me on the right track.

http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/

It seems like the Tomcat (version 6 at least) packages available in Ubuntu (and Debian) are not working correctly. Instead I installed Tomcat using the following guide:

http://www.ctrip.ufl.edu/tomcat6-debian-lenny-howto

While this might not be the premium choice of installation it seems necessary to get Tomcat version 6 running without problems on Ubuntu and/or Debian Lenny.

美煞众生 2024-08-24 23:04:42

就我而言,这个错误是通过切换> 来解决的。在我的 pom.xml 中订购。当 hibernate (3.2.7.ga) 在 hibernate-annotations (3.4.0.GA) 之前出现时,会发生此错误。反过来说,它工作得很好。即使使用scope=compile 也是如此。

我猜你需要调整你的类路径,除了(假设你已经将两个 jar 放在 WEB-INF/lib 中)它应该以正确的顺序进行 alpha 排序。但这也许会给某人带来如何前进的提示。

In my case, this error was resolved by switching the <dependency/> order in my pom.xml. When hibernate (3.2.7.ga) comes before hibernate-annotations (3.4.0.GA) this error occurs. The other way around, it works fine. This is the case even with scope=compile.

I would guess that you need to tweak your classpath, except that (assuming you've dropped both jars in WEB-INF/lib) it should alpha-sort in the correct order. But maybe this will give someone a hint on how to move forward.

雪化雨蝶 2024-08-24 23:04:42

就我而言,这是一个简单的错误 - 配置文件 *.hbm.xml 有一个映射对象没有的属性!我还听说过当你拼错 get/set 函数时出现该错误的情况 - 与我的情况非常相似。

In my case it was a simple mistake - the config file *.hbm.xml had a property that the mapped object didnt have! I also heard of cases of that error apearing when you misspell a get/set function - very similar to my case.

∝单色的世界 2024-08-24 23:04:42

我面临着同样的问题。我下载“javassist.jar”并将其放入类路径后它就消失了: http://www.java2s.com/Code/Jar/JKL/Downloadjavassistjar.htm

I was facing the same problem. It went away after I downloaded "javassist.jar" and put it in the classpath: http://www.java2s.com/Code/Jar/JKL/Downloadjavassistjar.htm

此生挚爱伱 2024-08-24 23:04:42

这是 Tomcat 守护进程进程的外观:

root      2605  0.0  0.0  16584   376 ?        Ss   15:39   0:00
  /usr/bin/jsvc -user tomcat6
 -cp /usr/share/java/commons-daemon.jar:/usr/share/tomcat6/bin/bootstrap.jar
 -outfile SYSLOG -errfile SYSLOG -pidfile /var/run/tomcat6.pid
 -Djava.awt.headless=true -Xmx128M
 -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
 -Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6
 -Djava.io.tmpdir=/tmp/tomcat6-temp -Djava.security.manager
 -Djava.security.policy=/var/lib/tomcat6/work/catalina.policy
 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
 -Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties
 org.apache.catalina.startup.Bootstrap

这是使用 Sysdeo Tomcat 启动器插件从 Eclipse 中运行时 Tomcat 进程的外观:
(这个实际上有效)

jzaruba   2655 19.7  4.5 358304 46152 ?        Sl   15:43   0:01
 /usr/lib/jvm/java-6-sun-1.6.0.15/bin/java
 -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:37377
 -Dcatalina.home=/usr/share/tomcat6
 -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
 -Dcatalina.base=/var/lib/tomcat6 -Djava.io.tmpdir=/var/lib/tomcat6/temp
 -Dfile.encoding=UTF-8 -classpath
 /usr/share/tomcat6/bin/bootstrap.jar:/usr/lib/jvm/java-6-sun-1.6.0.15/lib/tools.jar 
 org.apache.catalina.startup.Bootstrap start

工作的(Eclipse启动)是使用java-6-sun-1.6.0.15运行的,我是Windows用户,所以我不知道如何判断/usr/lib/使用哪个JRE jsvc(虽然看着它),但我猜它是一些 OpenJDK...这可能是区别吗?

更新:jsvc 可能使用相同的 JRE Sysdeo Tomcat 启动器

This is how the Tomcat daemon process looks:

root      2605  0.0  0.0  16584   376 ?        Ss   15:39   0:00
  /usr/bin/jsvc -user tomcat6
 -cp /usr/share/java/commons-daemon.jar:/usr/share/tomcat6/bin/bootstrap.jar
 -outfile SYSLOG -errfile SYSLOG -pidfile /var/run/tomcat6.pid
 -Djava.awt.headless=true -Xmx128M
 -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
 -Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6
 -Djava.io.tmpdir=/tmp/tomcat6-temp -Djava.security.manager
 -Djava.security.policy=/var/lib/tomcat6/work/catalina.policy
 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
 -Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties
 org.apache.catalina.startup.Bootstrap

This is how the Tomcat process looks when run from within Eclipse using the Sysdeo Tomcat launcher plugin:
(this one actually works)

jzaruba   2655 19.7  4.5 358304 46152 ?        Sl   15:43   0:01
 /usr/lib/jvm/java-6-sun-1.6.0.15/bin/java
 -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:37377
 -Dcatalina.home=/usr/share/tomcat6
 -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
 -Dcatalina.base=/var/lib/tomcat6 -Djava.io.tmpdir=/var/lib/tomcat6/temp
 -Dfile.encoding=UTF-8 -classpath
 /usr/share/tomcat6/bin/bootstrap.jar:/usr/lib/jvm/java-6-sun-1.6.0.15/lib/tools.jar 
 org.apache.catalina.startup.Bootstrap start

The working one (Eclipse launched) is run using java-6-sun-1.6.0.15, I'm Windows user so I don't know how to tell which JRE is used for /usr/lib/jsvc (looking at it though), but my guess would be it is some OpenJDK... Could this be the difference?

update: jsvc probably uses the same JRE Sysdeo Tomcat launcher does

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文