2

I have installed glassfish 5 in ubuntu and put it under the directory /opt, but when I typed asadmin start-domain I face this error:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.glassfish.hk2.api.DynamicConfigurationService.createDynamicConfiguration()" because "dcs" is null
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)

How can I solve this problem?

Drago Ban
  • 105
  • 1
  • 8
  • 1
    Which JDK are you using? GF 5 only supports up to JDK 8 if I am not mistaken. – Christoph John Feb 01 '21 at 22:44
  • Does this answer your question? [Glassfish server does not start. NullPointeException](https://stackoverflow.com/questions/47458119/glassfish-server-does-not-start-nullpointeexception) – Jonathan Coustick Feb 02 '21 at 10:02
  • @ChristophJohn java -version -> java version "15.0.2" 2021-01-19 Java(TM) SE Runtime Environment (build 15.0.2+7-27) Java HotSpot(TM) 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing \n javac -version : javac 15.0.2 does these infos clarify the problem ? – Drago Ban Feb 02 '21 at 16:18
  • Yes. See my comment and the comment from Jonathan. – Christoph John Feb 02 '21 at 16:43
  • @JonathanCoustick i did and i edit asevent.bat/conf but i didn't work the same problem occurs – Drago Ban Feb 02 '21 at 16:55

4 Answers4

5

Glassfish version 5 shows that behaviour when run with openjdk15 (at least in my machine) I have configured (see below) it to run with JDK-8 and it starts correctly.

set JAVA_HOME="Your_path_to_jdk8"
set PATH="%JAVA_HOME%/bin;%PATH%"

in windows, or

export JAVA_HOME="Your_path_to_jdk8"
export PATH="${JAVA_HOME}/bin:${PATH}"

in unix/linux. Add this to the script you use to start it, so the environment directs Glassfish to the proper place to find java binaries.

Luis Colorado
  • 10,974
  • 1
  • 16
  • 31
2

You have to put

set AS_JAVA=C:\Program Files\Java\jdk1.5.0_16

on this directory of you glassfish server:

C:\Users\Usuario\Documents\glassfish-5.0.1\glassfish5\glassfish\config\asenv

0

I had the same problem with glassfish 6. Make sure you have JDK installed.

Also the glassfish documentation says you have to set JAVA_HOME environment variable an then the PATH variable to point to JAVA_HOME/bin.

On Linux I edited my ~/.bash_profile:

export JAVA_HOME=/usr/lib64/jvm/java-8-openjdk
export PATH=$JAVA_HOME/bin:$PATH
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
0

Downgrading form JDK 17 to JDK 8 worked. JDK 11 also didn't work.

mouserat
  • 1,565
  • 13
  • 9