views:

1279

answers:

6

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

A: 

Were you able to solve this please?
I'm facing the same issue. Under Jetty (Google Eclipse plug-in) Hibernate works. When I publish & run my application under Tomcat (or redirect Tomcat's docBase to GWT-project directory) I get this error.
I'm experiencing this error only under Linux, under Windows it works just fine.

Jaroslav Záruba
No I haven't. I experience the exact same problem. I will report back as soon as I have a solution. I have to solve it because it is part of a product release we're doing. What Linux distribution do you run?
Subtwo
Better yet, when running using Sysdeo Tomcat launcher plug-in from within Eclipse it works.I have a suspicion it could be somehow related to the fact that both these run under different users, one of them being unable to access something somewhere...
Jaroslav Záruba
I'm trying to make it run on Ubuntu desktop. (I would like to drop the Windows WebServer it currently resides on.)
Jaroslav Záruba
Do you by any chance have the Tomcat6 installed by using the repository? Have you seen the article: http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/
Subtwo
I'm not sure now, but it is very likely that I installed Tomcat from the Ubuntu repository. I tried already some howto-recipe before, but I will sure try this one too.Thanks for your replies, Subtwo!
Jaroslav Záruba
A: 

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

Jaroslav Záruba
I'm using the java-6-sun-1.6.0.15 jdk so I doubt that the version of Java is to blame.
Subtwo
+2  A: 

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.

Subtwo
Both guides use Tomcat's startup.sh and shutdown.sh scripts to control the Tomcat instance. This is fine for development, but in production, you should use jsvc to run Tomcat with a dedicated, low privilege account.You need to build jsvc - sources ship with Tomcat in $CATALINA_HOME/bin/jsvc-src.tar.gz Tomcat5.sh in this archive provides a suitable install script - it'll need tweaking for your jvm/environment.More details here from Apache: http://tomcat.apache.org/tomcat-6.0-doc/setup.html This only applies to *nix installations - the Windows installer magically creates a jsvc service.
Alan Donnelly
+1  A: 

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.

Anonymouse
Sounds interesting. I'll take a look at it once I get some time to spend on this issue again.
Subtwo
+1  A: 

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.

Bogumił Laska
Thanks for your input. I don't think it's a problem with the *.hbm.xml files for a few different reasons; but I guess this problem has many roots and reasons.
Subtwo
A: 

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

ashweta