Hot questions for Using GlassFish in logging

Question:

When I add Hibernate 5 to my website, I can't get it to work in Glassfish 4.1.1. I always get an error

java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V

I've tried to replace the jboss-logging library in Glassfish' modules folder, like I read in an answer to a similar problem, but it didn't change anything. I also tried to use Hibernate 4, but that gave an other error.


Answer:

In my case, I was running the Hibernate 5 with JPA annotations on tomcat and stop working when I changed to glassfish 4.1

The error:

hibernate.properties not found

Make sure: src/main/resources/hibernate.cfg.xml exists

And if you only have the dependency of hibernate-core, I was using hibernate-annotations and hibernate-common-annotations and it was creating conflict. The hibernate 5 doesnt need these two, I had read somewhere.Try to remove ;)

After that a new error appears:

java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V

The reason was the oldest jboss-logging.jar at: "YOUR_GLASSFISH_FOLDER/glassfish/modules"

Why? The hibernate 5 has dependency with the newest version of jboss-logging, and the glassfish 4 uses the oldest version even if you declare inside your POM file the newest version. Actually I'm using:

org.jboss.logging jboss-logging 3.3.0.Final

Then I downloaded it and replace the old .jar inside the modules path and it back to work, I spent 2 days trying to solve that and I hope it helps some future issues =D

I used this link to help me: https://medium.com/@mertcal/using-hibernate-5-on-payara-cc242212a5d6#.npq2hdprz

Another solution, in my case, could be back to the last Hibernate 4 version (4.3.11.Final) but it is already too old in my opinion

Question:

I'm using java.util.logging on GlassFish 4.

I'm defining my own class to initialize the LogManager by defining the System property: -Djava.util.logging.config.class.

My class loads the logging.properties file, merges it with some other property file and does some custom replacement.

The following is the relevant part of my logging.properties file:

java.util.logging.FileHandler.pattern=C:/Work/server/glassfish/domains/domain1/logs/JMSFileHandler%g.log
java.util.logging.FileHandler.limit=2000000
java.util.logging.FileHandler.count=20
java.util.logging.FileHandler.append=true
java.util.logging.FileHandler.level=ALL
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=%1$tY:%1$tm:%1$td %1$tH:%1$tM:%1$tS|%4$s: %2$s%n%5$s%n%6$s%n

I'm using the standard FileHandler and configuring it to use the SimpleFormatter as the formatter.

But the java.util.logging.SimpleFormatter.format String is being totally ignored. Instead SimpleFormatter uses its default format.

Where did I go wrong?


Answer:

From the SimpleFormatter docs you have to test for the following conditions:

  1. If this property is not defined or the given format string is illegal, the default format is implementation-specific.
  2. If this property is set in both the logging properties and system properties, the format string specified in the system property will be used.
  3. This property can be defined in the logging properties configuration file.

Here is a sample test case that you can convert and run under GlassFish.

public static void main(String[] args) throws Exception {
    final String format = "%1$tY:%1$tm:%1$td %1$tH:%1$tM:%1$tS|%4$s: %2$s%n%5$s%n%6$s%n";
    final String key = "java.util.logging.SimpleFormatter.format";
    test(format);
    test(System.getProperty(key, format));
    test(LogManager.getLogManager().getProperty(key));
    FileHandler f = new FileHandler();
    System.out.println(f.getFormatter());
    f.close();
}

private static void test(String format) {
    LogRecord record = new LogRecord(Level.INFO, "");
    System.out.println(String.format(format,
                         new java.util.Date(record.getMillis()),
                         record.getSourceClassName(),
                         record.getLoggerName(),
                         record.getLevel().getLocalizedName(),
                         record.getMessage(),
                         String.valueOf(record.getThrown())));
}

You also need to check if GlassFish replaced your SimpleFormatter with the 'com.sun.enterprise.server.logging.UniformLogFormatter'.

private static void findFormatters() {
    final ArrayList<Handler> handlers = new ArrayList<>();
    final LogManager manager = LogManager.getLogManager();
    synchronized (manager) {
        final Enumeration<String> e = manager.getLoggerNames();
        while (e.hasMoreElements()) {
            final Logger l = manager.getLogger(e.nextElement());
            if (l != null) {
                Collections.addAll(handlers, l.getHandlers());
            }
        }
    }

    for (Handler h : handlers) {
        Formatter f = h.getFormatter();
        System.out.println(h.getClass().getName() + "=" + (f == null ? "" : f.getClass().getName()));
    }
}

If you need to check access when the system properties are set you can install a security manager with the -Djava.security.debug=access,stack options to trace when the property is set.

Question:

EDIT: I have a static initializer block in my custom Handler. When I remove this it runs fine. I suspect there is something wrong in the static initializer. It tries to access some System properties and some LogManager properties.

Im running GlassFish from Eclipse Kepler.

I'm adding my own custom logger to GlassFish 4 as described in Chapter 7 of the Administration guide

All I do is to place the new Handler jar into the domain-dir/lib/ext directory and reference it in the logging.properties file as:

handlers=java.util.logging.ConsoleHandler,com.mytools.logging.JMSFileHandler

But when I start GlassFish it hangs at 69% and after a while I get a timeout error:

java.util.concurrent.TimeoutException
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at oracle.eclipse.tools.glassfish.GlassfishGenericServerBehaviour.launchServer(GlassfishGenericServerBehaviour.java:202)
    at oracle.eclipse.tools.glassfish.GlassfishServerLaunchDelegate.startDASAndTarget(GlassfishServerLaunchDelegate.java:206)
    at oracle.eclipse.tools.glassfish.GlassfishServerLaunchDelegate.launch(GlassfishServerLaunchDelegate.java:110)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:858)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:707)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:700)
    at org.eclipse.wst.server.core.internal.Server.startImpl2(Server.java:3537)
    at org.eclipse.wst.server.core.internal.Server.startImpl(Server.java:3473)
    at org.eclipse.wst.server.core.internal.Server$StartJob.run(Server.java:367)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

VisualVM Threaddump:

2014-08-19 17:50:19
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.25-b01 mixed mode):

"FelixFrameworkWiring" daemon prio=6 tid=0x000000000d95a800 nid=0x2a0c in Object.wait() [0x00000000110bf000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000e14d0148> (a java.util.ArrayList)
    at java.lang.Object.wait(Object.java:503)
    at org.apache.felix.framework.FrameworkWiringImpl.run(FrameworkWiringImpl.java:162)
    - locked <0x00000000e14d0148> (a java.util.ArrayList)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"deployment-jar-scanner" daemon prio=6 tid=0x000000000d959800 nid=0x2f00 waiting on condition [0x0000000010f2e000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"deployment-jar-scanner" daemon prio=6 tid=0x000000000d959000 nid=0x27c waiting on condition [0x0000000010d5f000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"deployment-jar-scanner" daemon prio=6 tid=0x000000000d957800 nid=0x1c78 waiting on condition [0x000000001278e000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"deployment-jar-scanner" daemon prio=6 tid=0x000000000d956800 nid=0x3344 waiting on condition [0x00000000115ce000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"deployment-jar-scanner" daemon prio=6 tid=0x000000000d956000 nid=0x2898 waiting on condition [0x0000000010bee000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"transaction-manager" daemon prio=6 tid=0x000000000d953000 nid=0x3320 in Object.wait() [0x00000000107ff000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000e1eb8be8> (a java.util.TaskQueue)
    at java.lang.Object.wait(Object.java:503)
    at java.util.TimerThread.mainLoop(Timer.java:526)
    - locked <0x00000000e1eb8be8> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:505)

   Locked ownable synchronizers:
    - None

"Thread-11" daemon prio=6 tid=0x000000000d952000 nid=0x1f7c waiting on condition [0x000000001013e000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e20a48b8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:374)
    at com.sun.enterprise.server.logging.GFFileHandler.log(GFFileHandler.java:825)
    at com.sun.enterprise.server.logging.GFFileHandler$3.run(GFFileHandler.java:540)

   Locked ownable synchronizers:
    - None

"deployment-jar-scanner" daemon prio=6 tid=0x000000000d951800 nid=0x29c8 waiting on condition [0x00000000106af000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"deployment-jar-scanner" daemon prio=6 tid=0x000000000d950800 nid=0x21e0 waiting on condition [0x00000000104ef000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"deployment-jar-scanner" daemon prio=6 tid=0x000000000d950000 nid=0x1e84 waiting on condition [0x000000000fd9e000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e1f259e8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"pool-3-thread-1" prio=6 tid=0x000000000d94e800 nid=0x2a98 waiting on condition [0x000000001036f000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e1f56a88> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"SCR Component Actor" daemon prio=6 tid=0x000000000d82d000 nid=0x234 in Object.wait() [0x000000000ffee000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000e1fa3df0> (a java.util.LinkedList)
    at java.lang.Object.wait(Object.java:503)
    at org.apache.felix.scr.impl.ComponentActorThread.run(ComponentActorThread.java:74)
    - locked <0x00000000e1fa3df0> (a java.util.LinkedList)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"fileinstall-C:\Work\issue\issRepo\tap-server\server\glassfish\domains\domain1/autodeploy/bundles/plugins/" daemon prio=6 tid=0x000000000da94000 nid=0x30cc in Object.wait() [0x000000000b69e000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000e1fb4648> (a org.apache.felix.fileinstall.internal.DirectoryWatcher)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:268)
    - locked <0x00000000e1fb4648> (a org.apache.felix.fileinstall.internal.DirectoryWatcher)

   Locked ownable synchronizers:
    - None

"Configuration Updater" daemon prio=6 tid=0x000000000d3a7800 nid=0x838 in Object.wait() [0x000000000fbef000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000e1fe1078> (a java.util.LinkedList)
    at java.lang.Object.wait(Object.java:503)
    at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:67)
    - locked <0x00000000e1fe1078> (a java.util.LinkedList)

   Locked ownable synchronizers:
    - None

"DestroyJavaVM" prio=6 tid=0x000000000239c000 nid=0x35ac waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"GlassFish Kernel Main Thread" prio=6 tid=0x000000000cdbb800 nid=0x3498 in Object.wait() [0x000000000fa2f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000e2094990> (a com.sun.enterprise.v3.server.AppServerStartup$1)
    at java.lang.Object.wait(Object.java:503)
    at com.sun.enterprise.v3.server.AppServerStartup$1.run(AppServerStartup.java:245)
    - locked <0x00000000e2094990> (a com.sun.enterprise.v3.server.AppServerStartup$1)

   Locked ownable synchronizers:
    - None

"pool-1-thread-1" daemon prio=6 tid=0x000000000c9aa800 nid=0x908 waiting on condition [0x000000000f78e000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000000e1b99be0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"FelixStartLevel" daemon prio=6 tid=0x000000000c7d5800 nid=0x32e8 in Object.wait() [0x000000000c39f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000e14cfed8> (a java.util.ArrayList)
    at java.lang.Object.wait(Object.java:503)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:279)
    - locked <0x00000000e14cfed8> (a java.util.ArrayList)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"FelixDispatchQueue" daemon prio=6 tid=0x000000000a74f800 nid=0x3644 in Object.wait() [0x000000000c66e000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000e14f7828> (a java.util.ArrayList)
    at java.lang.Object.wait(Object.java:503)
    at org.apache.felix.framework.util.EventDispatcher.run(EventDispatcher.java:1063)
    - locked <0x00000000e14f7828> (a java.util.ArrayList)
    at org.apache.felix.framework.util.EventDispatcher.access$000(EventDispatcher.java:54)
    at org.apache.felix.framework.util.EventDispatcher$1.run(EventDispatcher.java:101)
    at java.lang.Thread.run(Thread.java:724)

   Locked ownable synchronizers:
    - None

"Service Thread" daemon prio=6 tid=0x000000000a489800 nid=0x3464 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"C2 CompilerThread1" daemon prio=10 tid=0x000000000a489000 nid=0x35a0 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"C2 CompilerThread0" daemon prio=10 tid=0x000000000a484000 nid=0x34ec waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"JDWP Event Helper Thread" daemon prio=6 tid=0x000000000a476000 nid=0x2de4 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"JDWP Transport Listener: dt_socket" daemon prio=6 tid=0x000000000a472800 nid=0x20f0 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"Attach Listener" daemon prio=10 tid=0x000000000a3d3000 nid=0x2f78 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"Signal Dispatcher" daemon prio=10 tid=0x000000000a3d2000 nid=0x238 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"Finalizer" daemon prio=8 tid=0x0000000008341800 nid=0x3584 in Object.wait() [0x000000000a27f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000e092a1e8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked <0x00000000e092a1e8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:189)

   Locked ownable synchronizers:
    - None

"Reference Handler" daemon prio=10 tid=0x0000000008337800 nid=0x2258 in Object.wait() [0x000000000a37f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000000e0929ca8> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked <0x00000000e0929ca8> (a java.lang.ref.Reference$Lock)

   Locked ownable synchronizers:
    - None

"VM Thread" prio=10 tid=0x0000000008330000 nid=0x1fd0 runnable 

"GC task thread#0 (ParallelGC)" prio=6 tid=0x00000000023ad000 nid=0x37b8 runnable 

"GC task thread#1 (ParallelGC)" prio=6 tid=0x00000000023af000 nid=0x1a98 runnable 

"GC task thread#2 (ParallelGC)" prio=6 tid=0x00000000023b1800 nid=0x34fc runnable 

"GC task thread#3 (ParallelGC)" prio=6 tid=0x00000000023b3000 nid=0x3368 runnable 

"GC task thread#4 (ParallelGC)" prio=6 tid=0x00000000023b6800 nid=0x2844 runnable 

"GC task thread#5 (ParallelGC)" prio=6 tid=0x00000000023b8000 nid=0xde4 runnable 

"GC task thread#6 (ParallelGC)" prio=6 tid=0x00000000023b9000 nid=0x2ba0 runnable 

"GC task thread#7 (ParallelGC)" prio=6 tid=0x00000000023bc800 nid=0x2c98 runnable 

"VM Periodic Task Thread" prio=10 tid=0x000000000a49e800 nid=0x167c waiting on condition 

JNI global references: 3733

Answer:

After lots of trial and error I have figured out that the problem is in the static initializer of my handler class.

There are two parts that will freeze GlassFish and cause a TimeoutException:

1. Accessing the LogManager:
LogManager logManager = LogManager.getLogManager();
2. Trying to read resources from my package.

Remember that the Jar file will be placed into the domain-dir/lib/ext directory:

    Properties logProperties = new Properties();
    try (InputStream packageStream = JMSFileHandler.class.getResourceAsStream("JMSFileHandler.properties")) {
        if (packageStream != null) {
            logProperties.load(packageStream); //this line causes freeze
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

The critical line here is the one marked with //this line causes freeze. So it is only trying to load the properties that causes a problem.