Hot questions for Using Ubuntu in glassfish

Question:

I'm trying to start Glassfish 4.1 in Intellij IDEA 13.1.4. I've set basic settings in Run/debug configurations window - selected application server, jvm, put 2 artifacts to deploy, left startup/connection configurations default. When I try to start it the exception is thrown. Here is full stack trace:

 /home/glassfish/glassfish/bin/asadmin start-domain domain1

   Detected server admin port: 4848
   Detected server http port: 8080
[2014-11-14 03:09:49,839] Artifact ss-ear:ear: Server is no connected.Deploy     is not available.
[2014-11-14 03:09:49,839] Artifact ss-ear:ear exploded: Server is not connected.  Deploy is not available.

java.nio.file.AccessDeniedException: /home/glassfish/glassfish/domains/domain1/logs/server.log.lck
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:177)
at java.nio.channels.FileChannel.open(FileChannel.java:287)
at java.nio.channels.FileChannel.open(FileChannel.java:335)
at java.util.logging.FileHandler.openFiles(FileHandler.java:438)
at java.util.logging.FileHandler.<init>(FileHandler.java:318)
at com.sun.enterprise.admin.launcher.GFLauncherLogger.addLogFileHandler(GFLauncherLogger.java:99)
at com.sun.enterprise.admin.launcher.GFLauncher.setup(GFLauncher.java:192)
at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.createLauncher(StartDomainCommand.java:228)
at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.executeCommand(StartDomainCommand.java:124)
at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:322)
at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:366)
at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:300)
at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:56)

 Waiting for domain1 to start .Error starting domain domain1.
 The server exited prematurely with exit code 1.
 Command start-domain failed.
 Before it died, it produced the following output:

 Listening for transport dt_socket at address: 9009
 Launching GlassFish on Felix platform
 Exception in thread "main" java.lang.RuntimeException: the domain directory is not writable.
at  com.sun.enterprise.glassfish.bootstrap.MainHelper.verifyDomainRoot(MainHelper.java:246)
at   com.sun.enterprise.glassfish.bootstrap.MainHelper.findInstanceRoot(MainHelper.java:349)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:78)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)

I'm using Ubuntu OS 14.04 LTS, java-1.7.0-openjdk-amd64. Glassfish installed in /home/glassfish, asadmin script have 777 permissions. Server starts when i run it from terminal, but not from IDE.

Please help, it makes me mad!


Answer:

Have you tried to start IntelliJ with sudo permission and start the server within the ide?

Question:

I consulted here and here but could not get my problem solved.

When I type this on terminal /opt/glassfish4/glassfish/bin/asadmin start, I get the following result:

Remote server does not listen for requests on [localhost:4848]. Is the server up?
Unable to get remote commands. 
Closest matching local command(s): 
    restart-domain
    restart-local-instance
    start-database
    start-domain
    start-local-instance

Command start failed.

Similarly, when I type this /opt/glassfish4/glassfish/bin/asadmin --port 5656 start-domain, I get

java.io.IOException: Couldn't get lock for /opt/glassfish4/glassfish/domains/domain1/logs/server.log
    at java.util.logging.FileHandler.openFiles(FileHandler.java:389)
    at java.util.logging.FileHandler.<init>(FileHandler.java:287)
    at com.sun.enterprise.admin.launcher.GFLauncherLogger.addLogFileHandler(GFLauncherLogger.java:98)
    at com.sun.enterprise.admin.launcher.GFLauncher.setup(GFLauncher.java:191)
    at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.createLauncher(StartDomainCommand.java:220)
    at com.sun.enterprise.admin.servermgmt.cli.StartDomainCommand.executeCommand(StartDomainCommand.java:117)
    at com.sun.enterprise.admin.cli.CLICommand.execute(CLICommand.java:321)
    at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:360)
    at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:298)
    at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:56)
Waiting for domain1 to start .Error starting domain domain1.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

Launching GlassFish on Felix platform
Exception in thread "main" java.lang.RuntimeException: the domain directory is not writable.
    at com.sun.enterprise.glassfish.bootstrap.MainHelper.verifyDomainRoot(MainHelper.java:244)
    at com.sun.enterprise.glassfish.bootstrap.MainHelper.findInstanceRoot(MainHelper.java:347)
    at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:78)
    at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)

Command start-domain failed.

I sense there is something problem in path /opt/glassfish4/glassfish/bin/asadmin. I am working on my first JSF web application and cannot run glassfish server. I am using Netbeans and ubuntu 13.10. Can anyone show me the way?

Thank you!


Answer:

The error messages

java.io.IOException: Couldn't get lock for /opt/glassfish4/glassfish/domains/domain1/logs/server.log

and

Exception in thread "main" java.lang.RuntimeException: the domain directory is not writable.

indicate that the user account you use to start the server doesn't have write permissions in your Glassfish domain folder.

To solve the problem either change the permissions or start the asadmin command with a user who has sufficient permissions.

If this doesn't solve the problem, there may be another process which has a lock on your server.log file, but I guess you would have noticed that. To make sure you can run

lsof /opt/glassfish4/glassfish/domains/domain1/logs/server.log

to see if any process is using the file.

See also:

  • Failed to start glassfish server because Couldn't get lock for /opt/glassfishv3/glassfish/domains/domain1/logs/server.log

Question:

I have a personal server with Ubuntu 14 and 1GB RAM. I would like to configure Liferay running in a Glassfish in this server.

I'm trying, but the initialization process is giving to me this message:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c8bd7000, 84496384, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 84496384 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /opt/liferay-portal-6.2-ce-ga2/glassfish-3.1.2.2/domains/domain1/config/hs_err_pid6797.log
Command start-domain failed.
The DAS was stopped

Can someone suggest some configuration that I can use without change the server physical memory?

Thanks


Answer:

You may encounter out-of-memory errors when launching the GlassFish with Liferay portal. To avoid these errors, set larger initial and maximum memory heap sizes with the -Xms and -Xmx options on admin console.

If you can't increase the RAM you may try the "Liferay with Glassfish Bundle". This is a preconfigured Glassfish server with Liferay Portal already installed. It is available at http://www.liferay.com/downloads/liferay-portal/available-releases.

According to the wiki docs it has the following requirements:

  • Memory: 1GB RAM Disk Space: 500MB
  • System Architecture: X86/SPARC
  • Operating System: Solaris/Linux/MacOS X/Windows/AIX
  • JDK 1.6.x/1.5.x (Only 1.5.x on Mac)

Question:

I follow http://www.lyonlabs.org/howto/howdoi-glassfish.html to install Glassfish 4.1 on Ubuntu 14.04 server.

But when I try to start glassfish server it show: remote server does not listen for requests on [localhost:4848] is the server up

Thanks


Answer:

GlassFish doesn't need to be installed. All you need to do is download the ZIP file, extract to the right directory, then run $GF_HOME/bin/asadmin start-domain.

The output should look like this:

mike@mike-ProLiant/opt/glassfish/glassfish-4.1$  bin/asadmin start-domain
Waiting for domain1 to start ...
Successfully started the domain : domain1
domain  Location: /opt/glassfish/glassfish-4.1/glassfish/domains/domain1
Log File: /opt/glassfish/glass

There are a few ways to find out if the server is up.

You can run jps -l:

mike@mike-ProLiant/opt/glassfish/glassfish-4.1$  jps -l
12540 sun.tools.jps.Jps
12301 com.sun.enterprise.glassfish.bootstrap.ASMain

You can see the GlassFish process there is 12301 "ASMain".

jps is a tool which comes with the JDK, so if you don't have it, or you don't have your path set up correctly and can't find it, you can use ps aux and grep the output for ASMain:

mike@mike-ProLiant/opt/glassfish/glassfish-4.1$  ps aux | grep ASMain
mike     12301  5.2  1.4 5125688 363452 pts/16 Sl   17:07   0:14 /usr/lib/jvm/java-7-oracle/bin/java -cp /opt/glassfish/glassfish-4.1/glassfish/modules/glassfish.jar -XX:+UnlockDiagnosticVMOptions -XX:MaxPermSize=192m -XX:NewRatio=2 -Xmx512m -client -javaagent:/opt/glassfish/glassfish-4.1/glassfish/lib/monitor/flashlight-agent.jar -Dfelix.fileinstall.disableConfigSave=false -Djavax.net.ssl.keyStore=/opt/glassfish/glassfish-4.1/glassfish/domains/domain1/config/keystore.jks -Djava.awt.headless=true -Dcom.ctc.wstx.returnNullForDefaultNamespace=true -Dfelix.fileinstall.poll=5000 -Djava.endorsed.dirs=/opt/glassfish/glassfish-4.1/glassfish/modules/endorsed:/opt/glassfish/glassfish-4.1/glassfish/lib/endorsed -Dfelix.fileinstall.bundles.startTransient=true -Djavax.net.ssl.trustStore=/opt/glassfish/glassfish-4.1/glassfish/domains/domain1/config/cacerts.jks -Djavax.xml.accessExternalSchema=all -Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as -Djava.security.auth.login.config=/opt/glassfish/glassfish-4.1/glassfish/domains/domain1/config/login.conf -DANTLR_USE_DIRECT_CLASS_LOADING=true -Dgosh.args=--nointeractive -Dosgi.shell.telnet.maxconn=1 -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver -Dfelix.fileinstall.dir=/opt/glassfish/glassfish-4.1/glassfish/modules/autostart/ -Dosgi.shell.telnet.port=6666 -Djava.security.policy=/opt/glassfish/glassfish-4.1/glassfish/domains/domain1/config/server.policy -Dfelix.fileinstall.log.level=2 -Dcom.sun.aas.instanceRoot=/opt/glassfish/glassfish-4.1/glassfish/domains/domain1 -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory -Dosgi.shell.telnet.ip=127.0.0.1 -Dcom.sun.aas.installRoot=/opt/glassfish/glassfish-4.1/glassfish -Djava.ext.dirs=/usr/lib/jvm/java-7-oracle/lib/ext:/usr/lib/jvm/java-7-oracle/jre/lib/ext:/opt/glassfish/glassfish-4.1/glassfish/domains/domain1/lib/ext -Dfelix.fileinstall.bundles.new.start=true -Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command,org.apache.felix.shell.remote,org.apache.felix.fileinstall -Djdk.corba.allowOutputStreamSubclass=true -Djava.library.path=/opt/glassfish/glassfish-4.1/glassfish/lib:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib com.sun.enterprise.glassfish.bootstrap.ASMain -domainname domain1 -asadmin-args --host,,,localhost,,,--port,,,4848,,,--secure=false,,,--terse=false,,,--echo=false,,,--interactive=true,,,start-domain,,,--verbose=false,,,--watchdog=false,,,--debug=false,,,--domaindir,,,/opt/glassfish/glassfish-4.1/glassfish/domains,,,domain1 -instancename server -verbose false -debug false -asadmin-classpath /opt/glassfish/glassfish-4.1/glassfish/lib/client/appserver-cli.jar -asadmin-classname com.sun.enterprise.admin.cli.AdminMain -upgrade false -type DAS -domaindir /opt/glassfish/glassfish-4.1/glassfish/domains/domain1 -read-stdin true
mike     12608  0.0  0.0  18932   932 pts/16   S+   17:12   0:00 grep --color=auto ASMain

You should get at least two entries. One is the actual GlassFish process, and will be really long, the other will be the command you just ran (since it has ASMain in it).

Another useful way to see if GlassFish is up is to check if it's bound to the right ports with netstat:

mike@mike-ProLiant/opt/glassfish/glassfish-4.1$  sudo netstat -lntp
[sudo] password for mike: 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      28775/nodejs    
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      1119/master     
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      5305/cupsd      
tcp6       0      0 :::25                   :::*                    LISTEN      1119/master     
tcp6       0      0 :::7676                 :::*                    LISTEN      12301/java      
tcp6       0      0 :::8686                 :::*                    LISTEN      12301/java      
tcp6       0      0 :::4848                 :::*                    LISTEN      12301/java      
tcp6       0      0 :::8080                 :::*                    LISTEN      12301/java      
tcp6       0      0 :::3700                 :::*                    LISTEN      12301/java      
tcp6       0      0 :::8181                 :::*                    LISTEN      12301/java      
tcp6       0      0 ::1:631                 :::*                    LISTEN      5305/cupsd      

So you can see above that port 4848 is bound by a process, and that the process is 12301/java which we saw earlier was GlassFish.

Make sure you sudo the command (sudo netstat -lntp) because the p at the end needs super-user privileges. It's the important one which tells us the name of the process, so we can see that it's Java.