Glassfish is a Java Library for creating Java Message Queues. Regular readers my be surprised to know I am also a Java coder since I usually talk about Python and C++, but just as I occasionally speak Italian, I am multilingual. In this case, though, this is all about Java.
Unfortunately, despite what it’s billed to be, Glassfish 5 isn’t as turn-key an application as it appears to be and therefore I wanted to fill in the gaps for would be message queuers—whatever the word is—who may be struggling.
First, let’s download Glassfish: https://javaee.github.io/glassfish/download
When you check out the readme file, you’ll see the following text:
The GlassFish README.txt file.
2. Starting GlassFish
The 'asadmin' command-line utility is used to control and manage GlassFish (start, stop, configure, deploy applications, etc).
To start GlassFish, just go in the directory where GlassFish is located and type:
On Unix: glassfish5/glassfish/bin asadmin start-domain
On Windows: glassfish5\glassfish\bin asadmin start-domain
After a few seconds, GlassFish will be up and ready to accept requests. The default 'domain1' domain is configured to listen on port 8080. In your browser, go to http://localhost:8080 to see the default landing page.
To manage GlassFish, just go to web administration console: http://localhost:4848
That’s all well and good, but, if you’ve never used Glassfish before, when you follow those steps, you’ll see the following cryptic error:
Exception in thread “main” java.lang.NullPointerException: Cannot invoke “org.glassfish.hk2.api.DynamicConfigurationService.createDynamicConfiguration()” because “dcs” is null$ glassfish5/glassfish/bin/asadmin start-domain
Clearly, Glashfish is not a turn-key installation.
From here, it was up to me. Google was no help.
"dcs" is null as a search term was too generic and including the full, topmost error only gave a page with sample Java code, not how to actually start the server.
To the best of my ability, I believe the error is related to the
DynamicConfigurationService object—that’s what
dcs stands for.
Looking through the QuickStart document I thought maybe it’s because I didn’t install to my home directory,
~, but moving it there produced the same results.
The next thing to try is to downgrade to Java 8. I’m not fond of Java 8 as it was one of the last Java versions to be 32-bit—which is incompatible with MacOS Catalina—but fortunately, Oracle provides a 64-bit, Catalina-compatible version.
Once Java 8 was installed, I just needed to tell my terminal to use that version instead of the default one. First, I needed to get the location for Java 8 in the list of installed Java VMs:
What Java VMs are available?
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
15, x86_64: "OpenJDK 15" /Users/username/Library/Java/JavaVirtualMachines/openjdk-15/Contents/Home
13.0.4, x86_64: "Zulu 13.33.25" /Users/username/Library/Java/JavaVirtualMachines/azul-13.0.4/Contents/Home
1.8.0_261, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home
Finally, I had to set the local Terminal to use the Java 8 VM:
Set the Java VM to Java 8.
$ export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_261`
$ glassfish5/glassfish/bin/asadmin start-domain
Waiting for domain1 to start ......
Successfully started the domain : domain1
domain Location: /Users/username/glassfish5/glassfish/domains/domain1
Log File: /Users/username/glassfish5/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
I hope that helps and I am so happy with my new job!
Follow my socials!