eclipse - 如何在 OS X 10.10.3 上从 Eclipse 启动 Glassfish 服务器?

标签 eclipse jakarta-ee glassfish osx-yosemite

我在 Eclipse 中使用 Java EE 开发了一个网站,并使用 Glassfish 在本地对其进行了测试,但在更新到 OS X 10.10.3 之后,服务器开始在启动期间超时。当尝试从终端启动时,Glassfish 启动失败,但是当使用 sudo 时,它启动成功。在网上浏览了一下之后,我发现使用 10.10.3 Glassfish 需要 root 权限才能运行。有没有办法让 Eclipse 以 root 权限启动服务器或以其他方式绕过该问题?

编辑:这是使用 Siddharth 的第一个选项后的日志(从 Eclipse 运行时第二个选项没有任何区别):

2015-05-16T16:30:39.877+1000|Info: Running GlassFish Version: GlassFish Server Open Source Edition  4.1  (build 13)
2015-05-16T16:30:39.879+1000|Info: Server log file is using Formatter class: com.sun.enterprise.server.logging.ODLLogFormatter
2015-05-16T16:30:39.980+1000|Info: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
2015-05-16T16:30:39.981+1000|Info: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
2015-05-16T16:30:39.984+1000|Info: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
2015-05-16T16:30:40.104+1000|Info: Authorization Service has successfully initialized.
2015-05-16T16:30:40.130+1000|Info: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
2015-05-16T16:30:40.375+1000|Info: Grizzly Framework 2.3.15 started in: 25ms - bound to [/0.0.0.0:8080]
2015-05-16T16:30:40.391+1000|Info: Grizzly Framework 2.3.15 started in: 1ms - bound to [/0.0.0.0:8181]
2015-05-16T16:30:40.397+1000|Info: Grizzly Framework 2.3.15 started in: 1ms - bound to [/0.0.0.0:4848]
2015-05-16T16:30:40.427+1000|Info: Grizzly Framework 2.3.15 started in: 0ms - bound to [/0.0.0.0:3700]
2015-05-16T16:30:40.428+1000|Info: GlassFish Server Open Source Edition  4.1  (13) startup time : Felix (1,426ms), startup services(619ms), total(2,045ms)
2015-05-16T16:30:40.602+1000|Info: JMXStartupService has started JMXConnector on JMXService URL service:jmx:rmi://olivers-imac.gateway:8686/jndi/rmi://olivers-imac.gateway:8686/jmxrmi

有时它只到达这里。

2015-05-16T16:30:40.602+1000|Info: Grizzly Framework 2.3.15 started in: 0ms - bound to [/0.0.0.0:7676]
2015-05-16T16:30:40.670+1000|Info: Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl@ae372b9 as OSGi service registration: org.apache.felix.framework.ServiceRegistrationImpl@67403656.

有时它只到达这里。

2015-05-16T16:30:40.904+1000|Info: visiting unvisited references
2015-05-16T16:30:41.444+1000|Info: Created HTTP listener http-listener-1 on host/port 0.0.0.0:8080
2015-05-16T16:30:41.450+1000|Info: Created HTTP listener http-listener-2 on host/port 0.0.0.0:8181
2015-05-16T16:30:41.453+1000|Info: Created HTTP listener admin-listener on host/port 0.0.0.0:4848
2015-05-16T16:30:41.471+1000|Info: Created virtual server server
2015-05-16T16:30:41.473+1000|Info: Created virtual server __asadmin
2015-05-16T16:30:41.638+1000|Info: Setting JAAS app name glassfish-web
2015-05-16T16:30:41.639+1000|Info: Virtual server server loaded default web module 
2015-05-16T16:30:41.927+1000|Info: Java security manager is disabled.
2015-05-16T16:30:41.928+1000|Info: Entering Security Startup Service.
2015-05-16T16:30:41.930+1000|Info: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
2015-05-16T16:30:41.969+1000|Info: Security Service(s) started successfully.
2015-05-16T16:30:42.155+1000|Info: visiting unvisited references
2015-05-16T16:30:42.170+1000|Info: visiting unvisited references
2015-05-16T16:30:42.172+1000|Info: visiting unvisited references
2015-05-16T16:30:43.060+1000|Info: Initializing Mojarra 2.2.7 ( 20140610-1547 https://svn.java.net/svn/mojarra~svn/tags/2.2.7@13362) for context ''
2015-05-16T16:30:43.655+1000|Info: HV000001: Hibernate Validator 5.0.0.Final
2015-05-16T16:30:43.965+1000|Info: Loading application [__admingui] at [/]
2015-05-16T16:30:43.966+1000|Info: Loading application __admingui done in 3,296 ms

编辑:我已将 Siddharth 的回答标记为正确,因为它对我的帮助最大,但是只有在更新到 El Capitan 后问题才完全自行解决。

最佳答案

这是一个已知问题,现已修复 (see this)。如果您想继续使用当前版本的 Glassfish,那么您可以考虑发布一个解决方案 here .

在下面引用相同的解决方案:-

It turns out that the Glassfish team made an assumption that they could use launchctl bsexec in their nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java file.

This sub-command now requires root privileges.

Someone has submitted a patch to Glassfish trunk, but if you want to continue using Glassfish immediately, you can create this script somewhere e.g. ~/bin/launchctl.

#!/bin/bash
# A little hack to wrap launchctl in order to
# successfully start Glassfish on Yosemite 10.10.3+
if [[ ${1} == "bsexec" ]]; then
    nohup ${@:3}
else
    /bin/launchctl ${@}
fi

Remember to ‘chmod 755 ~/bin/launchctl’ so that it is executable.

Also remember that your ~/.profile or ~/.bash_profile must have something like this:

export PATH="$HOME/bin:$PATH"

The idea here is that this script is a wrapper for launchctl. As a user in Yosemite 10.10.3, you cannot run bsexec, but you may want to use launchctl for other things.

关于eclipse - 如何在 OS X 10.10.3 上从 Eclipse 启动 Glassfish 服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30135292/

相关文章:

java - Wildfly 10 无法连接数据源 : invalid connection

java - 在 Java 企业应用程序中重新映射 JNDI 资源

java - jvm verbosegc 日志文件问题

java - 在 Maven 存储库中使用已安装的 Java 版本

java - 在java应用程序中通过方法调用我的eclipse插件

java - 如何阻止 Eclipse 对函数加下划线?

java - 从 IntelliJ Idea 2018.1 到 Glassfish 5.0.1 的应用程序未部署

c++ - 如何在 mac 上的 Eclipse CDT 上编译 C++0x 代码?

java - 如何在服务器端执行JS?

java - 好的 Java EE 测试框架?