glassfish 4.1 无法在 ubuntu 服务器 14.04 上启动

glashfish 4.1 not start on ubuntu server 14.04

我按照 http://www.lyonlabs.org/howto/howdoi-glassfish.html 在 Ubuntu 14.04 服务器上安装 Glassfish 4.1。

但是当我尝试启动 glassfish 服务器时,它显示: 远程服务器不监听 [localhost:4848] 上的请求是服务器

谢谢

不需要安装 GlassFish。您需要做的就是下载 ZIP 文件,解压到正确的目录,然后 运行 $GF_HOME/bin/asadmin start-domain.

输出应如下所示:

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

有几种方法可以查明服务器是否已启动。

你可以运行 jps -l:

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

可以看到GlassFish进程有12301 "ASMain".

jps是JDK自带的工具,所以如果你没有,或者你的路径设置不正确找不到,您可以使用 ps auxgrep 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

您应该至少获得两个条目。一个是实际的 GlassFish 进程,而且会很长,另一个是您刚刚 运行 的命令(因为其中包含 ASMain)。

另一种查看 GlassFish 是否启动的有用方法是使用 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      

所以你可以看到上面的端口4848被一个进程绑定了,这个进程是12301/java,我们之前看到的是GlassFish。

确保你 sudo 命令 (sudo netstat -lntp) 因为末尾的 p 需要超级用户权限。这是告诉我们进程名称的重要部分,因此我们可以看到它是 Java.

今天我根据这个问题做了一些搜索并在 https://www.stagejava.net/forum/topic/glassfish/glassfish/issues-starting-glassfish-server 上得到了同样的问题。如果您给 Asadmin 错误的选项,则会出现此错误消息。我更正选项并尝试它工作。 感谢大家