"java.lang.NoClassDefFoundError: java/nio/channels/FileLock" during shutdown and restart

155 views
Skip to first unread message

bakiaba...@gmail.com

unread,
Nov 27, 2018, 10:56:46 AM11/27/18
to ehcache-dev
Hi,

We have implemented Ehcache on ColdFusion 2016. During every single shutdown and restart of ColdFusion, we get the following error:


Nov 27, 2018 8:52:42 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-nio-8013"]
Exception in thread "Thread-8" java.lang.NoClassDefFoundError: java/nio/channels/FileLock
at net.sf.ehcache.DiskStorePathManager$DiskStorePath.unlock(DiskStorePathManager.java:358)
at net.sf.ehcache.DiskStorePathManager.releaseLock(DiskStorePathManager.java:236)
at net.sf.ehcache.CacheManager.shutdown(CacheManager.java:1571)
at coldfusion.tagext.io.cache.ehcache.GenericEhcache$CacheCleanUpAgent.run(GenericEhcache.java:1166)
at coldfusion.scheduling.Scheduler.run(Scheduler.java:245)
at java.lang.Thread.run(Thread.java:748)


I would be grateful for any ideas you may have to fix this.

Henri Tremblay

unread,
Nov 27, 2018, 12:54:15 PM11/27/18
to ehcac...@googlegroups.com
java/nio/channels/FileLock is in the JDK. So it's there. I suspect there is a SecurityManager preventing you from getting it.

Just debugging in DiskStorePath.unlock might help.

--
You received this message because you are subscribed to the Google Groups "ehcache-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-dev/4cf69a43-821d-4ea9-90d6-d4caf07fed1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

bakiaba...@gmail.com

unread,
Nov 28, 2018, 3:25:14 AM11/28/18
to ehcache-dev
Thanks, Henri. I shall follow up your tip

Bakianyor Bakia

unread,
Dec 19, 2018, 10:42:52 AM12/19/18
to ehcache-dev
It shows that the following sequence of events happen at shutdown:

1. When the cache manager shuts down, the DiskStorePathManager makes a call to release the lock file used to detect cache collision. This is the call

public synchronized void releaseLock() {
    try {
        if (path != null) {
        path.unlock();
    }
    } finally {
        path = null;
    }
}

2. However, the method, unlock, is in a static nested class whereas the caller, path, is in the enclosing class.   

I therefore suspect that the cause of the NoClassDefFoundError is the most obvious one. When generating the Ehcache JAR file, the Developer forgot to include java.nio.channels.FileLock.class to the classpath. 

You received this message because you are subscribed to a topic in the Google Groups "ehcache-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ehcache-dev/MutCDstjDs4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ehcache-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-dev/b7c645d1-ac96-4fbc-bd07-0606519fa6a3%40googlegroups.com.

Henri Tremblay

unread,
Dec 19, 2018, 11:29:14 AM12/19/18
to ehcac...@googlegroups.com
FileLock is from the JDK.

So it is there. In a normal unmodified JDK. Are you using OSGi? (I don't think it matters but just to be sure)

Bakianyor Bakia

unread,
Dec 20, 2018, 4:37:03 AM12/20/18
to ehcache-dev
Hi Henri,

Thank you for your reply. Our application, ColdFusion 2016, is running on a normal, unmodified JDK1.8.0_191. The ehcache-2.10.3.jar is in ColdFusion's lib directory. 

Obviously Filelock is there in the JDK. In fact, you can obtain an instance of java.nio.channels.FileLock and net.sf.ehcache.DiskStorePathManager in ColdFusion. But then, during shutdown, you get "java.lang.NoClassDefFoundError: java/nio/channels/FileLock".



Reply all
Reply to author
Forward
0 new messages