-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: JVM will not close
PostPosted: Mon Mar 23, 2009 3:09 pm 
Beginner
Beginner

Joined: Wed Dec 17, 2008 12:10 pm
Posts: 47
I'm using Hibernate Search (3.1 GA).

Everything works great, except when I'm using it outside the context of a web app. I have a process which synchronizes data from a SQL database provided by an outside vendor. This process adds entities to our database via Hibernate. When new objects are persisted, or existing objects are updated and the lucene index is updated, the process never terminates. All the code is executed properly, data is committed properly, the indexes are written properly, but the process never ends. I have looked at the thread dump but nothing jumps out at me. Here's the thread dump:

Code:
Full thread dump Java HotSpot(TM) 64-Bit Server VM (11.0-b15 mixed mode):

"DestroyJavaVM" prio=10 tid=0x0000000041b88000 nid=0x170 waiting on condition [0x0000000000000000..0x0000000040733cf0]
   java.lang.Thread.State: RUNNABLE

"pool-1-thread-1" prio=10 tid=0x00007f8537d0c400 nid=0x1a3 waiting on condition [0x0000000040935000..0x0000000040935a00]
   java.lang.Thread.State: WAITING (parking)
   at sun.misc.Unsafe.park(Native Method)
   - parking to wait for  <0x00007f85429b6540> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
   at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
   at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1925)
   at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:358)
   at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
   at java.lang.Thread.run(Thread.java:619)

"MySQL Statement Cancellation Timer" daemon prio=10 tid=0x00007f85370f5000 nid=0x17c in Object.wait() [0x0000000040a4e000..0x0000000040a4ed80]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00007f854279f9f0> (a java.util.TaskQueue)
   at java.lang.Object.wait(Object.java:485)
   at java.util.TimerThread.mainLoop(Timer.java:483)
   - locked <0x00007f854279f9f0> (a java.util.TaskQueue)
   at java.util.TimerThread.run(Timer.java:462)

"Low Memory Detector" daemon prio=10 tid=0x0000000041c3ec00 nid=0x17a runnable [0x0000000000000000..0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread1" daemon prio=10 tid=0x0000000041c3c000 nid=0x179 waiting on condition [0x0000000000000000..0x00000000413cb490]
   java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x0000000041c38400 nid=0x178 waiting on condition [0x0000000000000000..0x00000000412ca410]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x0000000041c36400 nid=0x177 waiting on condition [0x0000000000000000..0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=10 tid=0x0000000041c17400 nid=0x176 in Object.wait() [0x0000000040834000..0x0000000040834a80]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00007f8542630730> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
   - locked <0x00007f8542630730> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
   at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x0000000041c10400 nid=0x175 in Object.wait() [0x0000000040209000..0x0000000040209a00]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00007f85426306e8> (a java.lang.ref.Reference$Lock)
   at java.lang.Object.wait(Object.java:485)
   at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
   - locked <0x00007f85426306e8> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=10 tid=0x0000000041c0ac00 nid=0x174 runnable

"GC task thread#0 (ParallelGC)" prio=10 tid=0x0000000041b92c00 nid=0x171 runnable

"GC task thread#1 (ParallelGC)" prio=10 tid=0x0000000041b94400 nid=0x172 runnable

"GC task thread#2 (ParallelGC)" prio=10 tid=0x0000000041b96000 nid=0x173 runnable

"VM Periodic Task Thread" prio=10 tid=0x0000000041c41000 nid=0x17b waiting on condition

JNI global references: 1049

Heap
PSYoungGen      total 65984K, used 43268K [0x00007f856b6e0000, 0x00007f85712a0000, 0x00007f85800e0000)
  eden space 64640K, 64% used [0x00007f856b6e0000,0x00007f856dfd8fd0,0x00007f856f600000)
  from space 1344K, 97% used [0x00007f8571150000,0x00007f85712980c8,0x00007f85712a0000)
  to   space 2048K, 0% used [0x00007f8570ea0000,0x00007f8570ea0000,0x00007f85710a0000)
PSOldGen        total 42240K, used 28889K [0x00007f85422e0000, 0x00007f8544c20000, 0x00007f856b6e0000)
  object space 42240K, 68% used [0x00007f85422e0000,0x00007f8543f16700,0x00007f8544c20000)
PSPermGen       total 53184K, used 26373K [0x00007f853cee0000, 0x00007f85402d0000, 0x00007f85422e0000)
  object space 53184K, 49% used [0x00007f853cee0000,0x00007f853e8a1678,0x00007f85402d0000)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 24, 2009 3:03 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
are you shuting down the SessionFactory properly?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 27, 2009 9:40 am 
Beginner
Beginner

Joined: Wed Dec 17, 2008 12:10 pm
Posts: 47
That seems to have done it! Excellent. I didn't even know that the session factory had a close method...

That leads me to another question. Do I need to call this method in the context of a web application? When a servlet container shuts down without calling SessionFactory.close(), will this cause any trouble?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 27, 2009 10:20 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
that really depends on a lot of stuff, but of course you should close it if you can; Search is one case but you could have other stuff too.

In practice you may not be interested in a proper cleanup if your application is shutting down, but in that case you should accept that some resources could leak.
I'm sure JBoss is properly closing my entitymanagers, but I have no clue about how this is done in other containers.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 7:27 am 
Newbie

Joined: Thu Apr 02, 2009 7:10 am
Posts: 3
Location: A Coruna, Spain
Hi,

I'm currently developing a web application and I'm dealing with the same problem.

I've tried to explicitly call sessionFactory.close() but even though a latter call to sessionFactory.isClosed() returns true, the problem continues.

Any suggestion?

Thanks in advance.
- Oscar


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 7:50 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
does it ever quit even if you wait for some time?
are you using async indexing?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 12:26 pm 
Newbie

Joined: Thu Apr 02, 2009 7:10 am
Posts: 3
Location: A Coruna, Spain
No, I've not configured async indexing, and after an hour waiting the JVM process doesn't finish (I guess an hour should be time enough ;-))

I'm using Spring's AnnotationSessionFactoryBean as session factory, I've specified destroy-method="destroy" in order to ensure that the sessionfactory is closed. Furthermore, as I've commented in the previous post, I've explicitly called sessionfactory.close() within the contextDestroyed() method of a ServletContextListener. I've have also removed from the app all threads that could cause any kind of deadlock with the indexing process.

In spite of it all, when I shutdown the web container (Apache Tomcat 5.5.27) there is one thread which remains in this state (taken from jconsole):

WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer

The following are the library versions that I'm using:

Code:
<dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>3.3.1.GA</version> 
  </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-annotations</artifactId>
      <version>3.4.0.GA</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-search</artifactId>
      <version>3.1.0.GA</version>
    </dependency>   
    <dependency>
      <groupId>org.apache.solr</groupId>
      <artifactId>solr-core</artifactId>
      <version>1.3.0</version>
    </dependency>             
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring</artifactId>
      <version>2.5.6</version>
    </dependency>


Any extra clue?

Thanks for your attention
- Oscar


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 07, 2009 6:08 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
can you check in your logs that SessionFactory.close() is actually called?
There should be an INFO level log from SessionFactoryImpl saying:

Code:
closing

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 07, 2009 12:49 pm 
Newbie

Joined: Thu Apr 02, 2009 7:10 am
Posts: 3
Location: A Coruna, Spain
Hi again,

i've just checked out my log an the "closing" message was there.

BTW I discovered that my project had a transitive dependency with hibernate 3.2.6!!!! That was the cause of my mysterious problem, I fixed the dependency issue and everything worked fine.

Thank you all for your attention.

- Oscar


Top
 Profile  
 
 Post subject: Re: JVM will not close
PostPosted: Sun Jul 19, 2009 1:41 pm 
Newbie

Joined: Sun Jul 19, 2009 4:47 am
Posts: 5
Could you please post here the dependency section of your pom file?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.