28

I just downloaded the GlassFish 5.0 archive - Full Platform, unzipped it, I run it through the command line.

asadmin start-domain

problem:

Exception in thread "main" java.lang.NullPointerException
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.initializeServiceLocator(AbstractModulesRegistryImpl.java:152)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.newServiceLocator(AbstractModulesRegistryImpl.java:144)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:218)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:224)
at com.sun.enterprise.module.single.StaticModulesRegistry.createServiceLocator(StaticModulesRegistry.java:88)
at com.sun.enterprise.admin.cli.CLIContainer.getServiceLocator(CLIContainer.java:217)
at com.sun.enterprise.admin.cli.CLIContainer.getLocalCommand(CLIContainer.java:255)
at com.sun.enterprise.admin.cli.CLICommand.getCommand(CLICommand.java:231)
at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:371)
at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:306)
at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:57)

I tried to set the path in the file asenv.bat -> set path = C:/.../Java/bin - did not help. Tried so to launch: asadmin start-domain domain1 - did not help.

Installed: jdk-9.0.1 Also tried on the 8th, did not help. What to do???

moldovean
  • 3,132
  • 33
  • 36
Oleksandr
  • 450
  • 1
  • 6
  • 13
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Digvijaysinh Gohil Nov 23 '17 at 14:49
  • 32
    Are you seriously?? Please read my description! – Oleksandr Nov 23 '17 at 14:53
  • I did already, that's why I'm saying `Possible` duplicate. Not `exact` – Digvijaysinh Gohil Nov 23 '17 at 14:55
  • Like @Jonathan said, GlassFish 5 in not compatible with Java 9, for my case I was using GlassFish 5.1, Clear/Uninstall java 9 from your system and install Java 8. Make sure when you type java -version on command line the response you get is java 8 and not 9 – crakama Apr 02 '18 at 15:05
  • Vifier Lockla provided the solution: you just need to specify which version of Java you want to use for Glassfih or Payara. I had the same issue for Payara server. – moldovean Aug 26 '18 at 08:57

8 Answers8

31

OK, Glassfish 5.1 doesn't exist for the moment. Continue with Glassfish 5.0 with this solution:

Just set the AS_JAVA variable in your asenv.bat file located here: C:\DEVENV\glassfish5\glassfish\config.

File to edit: add last line screenshot of code

Relaunch your server....enjoy : screenshot of relaunch command to start your server

ascripter
  • 5,665
  • 12
  • 45
  • 68
Vifier Lockla
  • 512
  • 5
  • 6
  • That worked; but how you get there? what was the hint? it's sad, that such a popular server needs to be hacked to start. – Giorgi Tsiklauri Sep 08 '19 at 20:40
  • @Vifier Lockla Should this work with replacing jdk1.8.0_172 with jdk1.8.0_221 ? I tryed but didnt work for me. Even tried entering same thing in asenv.config but without the set before it. – brat Sep 17 '19 at 09:00
  • 2
    for MacOS, update asenv.conf file => AS_JAVA=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home – Harinath May 28 '20 at 02:57
12

This looks to be this issue - https://github.com/eclipse-ee4j/glassfish/issues/22130.

GlassFish 5 does not work on JDK9, however GlassFish 6 works on JDK 11.

Jonathan Coustick
  • 1,127
  • 9
  • 19
  • Damn! What a time waster... Wasted 10 minutes trying to figure out what exactly I did wrong... – RestInPeace May 30 '18 at 15:03
  • This link has died since javaee was moved under the eclipse umbrella. Here is the new link. https://github.com/eclipse-ee4j/glassfish/issues/22130 – klog Dec 18 '18 at 03:30
  • 2
    As of now, with 5.1, still not working out of the box (same exception) – DPM Nov 23 '19 at 11:06
9

For me it didn't work what @Vifier Lockla did. I had to change the path/glassfish5/glassfish/config/asenv.conf file in a linux mint machine. At the bottom of the file the path of the jdk 1.8, i.e.

AS_JAVA="/usr/lib/jvm/jdk1.8.0_191"
Symeon Mattes
  • 1,169
  • 16
  • 40
3

GlassFish 5.1 also not working with Java 9 or later versions.

glassfish 5.1 also needs java 8 with the AS_JAVA hack in asenv.conf/bat file.

Peddi
  • 92
  • 1
  • 9
2

Edit asenv.bat put set AS_JAVA=/usr/lib/jvm/java-8-oracle and asenv.conf AS_JAVA="/usr/lib/jvm/java-8-oracle"

It works

1

When you download the glassfish zip file from the internet and extract it. Its a good practice to read the the readme file. In my case the under the "prerequisites" title in the readme file, it specified: GlassFish 5.0 requires Oracle JDK 8 Update 144. I downloaded and installed the JDK 8 update 144 as demanded. It worked instantly. I initially had JDK 14.0.2 and it was displaying the error @Aleksandr posted.

0

I made the same mistake as the OP, because the release notes said specifically "GlassFish Server Open Source Edition Release 5.0 requires Oracle JDK 8 Update 144 or later" under heading Required JDK Versions in release notes.

However what you can do is drop down each version to see which is the latest jdk version that glassfish 5 will be compatible with Or Just download Java SE Development Kit 8 from https://www.oracle.com/in/java/technologies/javase/javase8-archive-downloads.html.

You also have to add the java variable in asenv.bat as kindly commented by Vifier Lockla. Thanks to Vifier for the suggestion.

Raj Alva
  • 1
  • 2
0

for me I changed to the directory where glassfish is

cd /opt

then

sudo glassfish5/bin/asadmin start-domain

I am sure this works