5 Replies Latest reply: Feb 19, 2007 7:30 PM by 807596 RSS

    jvm initialization takes 3 minutes?

    807596
      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 + native Method
      99.2% 0 + 17066 java.net.PlainSocketImpl.initProto
      0.1% 16 + 3 java.lang.ClassLoader.defineClass1
      0.0% 0 + 3 java.lang.Throwable.fillInStackTrace
      0.0% 3 + 0 com.mysql.jdbc.SingleByteCharsetConverter.<clinit>
      0.0% 1 + 1 java.lang.ClassLoader.findLoadedClass0
      0.0% 0 + 2 java.io.FileOutputStream.writeBytes
      0.0% 0 + 2 net.sf.hibernate.impl.SessionFactoryImpl.openSession
      0.0% 0 + 2 net.sf.hibernate.cfg.Configuration.add
      0.0% 1 + 1 net.sf.hibernate.cfg.Binder$CollectionType.<clinit>
      0.0% 2 + 0 com.sun.org.apache.xml.internal.utils.XMLChar.<clinit>
      0.0% 0 + 2 com.mysql.jdbc.Connection.createNewIO
      0.0% 0 + 1 java.lang.ClassLoader.findBootstrapClass
      0.0% 0 + 1 java.io.UnixFileSystem.getBooleanAttributes0
      0.0% 0 + 1 java.lang.Class.getDeclaredConstructors0
      0.0% 0 + 1 java.lang.Class.forName0
      0.0% 0 + 1 java.util.zip.ZipFile.getEntry
      0.0% 1 + 0 org.objectweb.asm.Label.<init>
      0.0% 1 + 0 java.util.zip.ZipEntry.getSize
      0.0% 1 + 0 java.nio.HeapCharBuffer.<init>
      0.0% 1 + 0 java.lang.ClassLoader.addClass
      0.0% 1 + 0 java.lang.AbstractStringBuilder.<init>
      0.0% 1 + 0 sun.reflect.UnsafeStaticFieldAccessorImpl.<init>
      0.0% 0 + 1 org.objectweb.asm.ClassWriter.visitMethod
      0.0% 1 + 0 com.mysql.jdbc.DatabaseMetaData.getIdentifierQuoteString
      0.0% 0 + 1 com.mysql.jdbc.Connection.createStatement
      99.8% 72 + 17098 Total 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