Drago Ban
Drago Ban

Reputation: 123

Glassfish5 Error: Exception in thread "main" java.lang.NullPointerException

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?

Upvotes: 3

Views: 12336

Answers (4)

mouserat
mouserat

Reputation: 2005

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

Upvotes: 0

Luis Colorado
Luis Colorado

Reputation: 12708

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.

Upvotes: 6

Bryam Guzmán
Bryam Guzmán

Reputation: 51

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

Upvotes: 3

Goran Ferbišek
Goran Ferbišek

Reputation: 41

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

Upvotes: 2

Related Questions