jvm initialization takes 3 minutes?
Hi,
I have a problem that appears to be associated with jvm start up. I am running SuSE linux v9.0, Spring V1.1.3, Tomcat v5.5.6, jdk 1.5.0 , mysql-standard-4.0.21. My jdbc drivers are (both work with the same results): com.mysql.jdbc.Driver or org.gjt.mm.mysql.Driver contained in mysql-connector-java-3.0.16-ga-bin.jar.
The reason for the preamble is that when I try to connect to a mysql daemon using hibernate the session hangs for 3 minutes. At first I blamed hibernate. However, I found that this long init time always occurred whenever a new jvm was used, either from the command line, my IDE, or ant. So I decided to profile the hibernate test app and see where the hangup was. I ran the following command from the shell:
java -client -Xprof -Xmx512m org.appfuse.hibernatetest.UserCreateTest
These were the results
Flat profile of 190.97 secs (17211 total ticks): main
Interpreted + nativeMethod
99.2%0 + 17066java.net.PlainSocketImpl.initProto
0.1%16 +3java.lang.ClassLoader.defineClass1
0.0%0 +3java.lang.Throwable.fillInStackTrace
0.0%3 +0com.mysql.jdbc.SingleByteCharsetConverter.<clinit>
0.0%1 +1java.lang.ClassLoader.findLoadedClass0
0.0%0 +2java.io.FileOutputStream.writeBytes
0.0%0 +2net.sf.hibernate.impl.SessionFactoryImpl.openSession
0.0%0 +2net.sf.hibernate.cfg.Configuration.add
0.0%1 +1net.sf.hibernate.cfg.Binder$CollectionType.<clinit>
0.0%2 +0com.sun.org.apache.xml.internal.utils.XMLChar.<clinit>
0.0%0 +2com.mysql.jdbc.Connection.createNewIO
0.0%0 +1java.lang.ClassLoader.findBootstrapClass
0.0%0 +1java.io.UnixFileSystem.getBooleanAttributes0
0.0%0 +1java.lang.Class.getDeclaredConstructors0
0.0%0 +1java.lang.Class.forName0
0.0%0 +1java.util.zip.ZipFile.getEntry
0.0%1 +0org.objectweb.asm.Label.<init>
0.0%1 +0java.util.zip.ZipEntry.getSize
0.0%1 +0java.nio.HeapCharBuffer.<init>
0.0%1 +0java.lang.ClassLoader.addClass
0.0%1 +0java.lang.AbstractStringBuilder.<init>
0.0%1 +0sun.reflect.UnsafeStaticFieldAccessorImpl.<init>
0.0%0 +1org.objectweb.asm.ClassWriter.visitMethod
0.0%1 +0com.mysql.jdbc.DatabaseMetaData.getIdentifierQuoteString
0.0%0 +1com.mysql.jdbc.Connection.createStatement
99.8%72 + 17098Total interpreted (including elided)
The code statement which is associated with this problem is the creation of the SessionFactory (line 3, below).
> Configuration config = new Configuration();
> config.addClass(User.class);
> SessionFactory sessionFactory = config.buildSessionFactory();
> Session session = sessionFactory.openSession();
Debugs indicate a hangup at the following location.
[java] 704 [main] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider - total checked-out connections: 0
[java] 705 [main] DEBUG net.sf.hibernate.connection.DriverManagerConnectionProvider - opening new JDBC connection
As you can see, as soon as the connection is attempted, the app hangs. And it hangs at java.net.PlainSocketImpl.initProto.
This seems to point to a jvm problem. If I read this correctly, the initProto() method is hanging for 3 minutes? Is there something I am missing or doing wrong? I have checked jvm.cfg, validated my CLASSPATH, checked and changed my firewall settings, all to no effect. As soon as an application uses a jvm, I pay the up-front cost of a 3 minute startup time.
Any help would be much appreciated.
Thanks,
John Brinnand

