Set the JDK Path in GlassFish

GlassFish version: 5.1.0
Windows version: 10

Motivation

You may have several version of the JDK installed on your machine. By default you may be using JDK 11 or even 13, but GlassFish requires JDK 8.

Issue

Running asadmin generates the following error

Exception in thread “main” java.lang.NullPointerException
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.initializeServiceLocator(AbstractModulesRegistryImpl.java:128)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.newServiceLocator(AbstractModulesRegistryImpl.java:120)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:194)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:200)
at com.sun.enterprise.module.single.StaticModulesRegistry.createServiceLocator(StaticModulesRegistry.java:64)
at com.sun.enterprise.admin.cli.CLIContainer.getServiceLocator(CLIContainer.java:193)
at com.sun.enterprise.admin.cli.CLIContainer.getLocalCommand(CLIContainer.java:231)
at com.sun.enterprise.admin.cli.CLICommand.getCommand(CLICommand.java:207)
at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:347)
at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:282)
at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:33)

Fix

Edit: ~\glassfish\config\asenv.bat
Assuming JDK 8 installation path is C:\Program Files\Java\jdk1.8.0_241

Add the line:

set AS_JAVA=C:\Program Files\Java\jdk1.8.0_241

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com
%d bloggers like this: