tar包拷贝的GLASSFISH 3.1 启动报错

tar包拷贝的GLASSFISH 3.1 启动报错

1.报错

近日在做某系统的优化,glassfish没有重新装,而直接从生产机打包过来。
解包改配置后启动无响应,netstat看端口没有出来,明显是各个容器都没有初始化成功。

asadmin start-domain somedomain

300秒后超时了。

改用verbose选项看看究竟是怎么回事。

asadmin start-domain -v somedomain

报错如下

Nov 14, 2016 2:45:03 PM Main install
WARNING: Failed to install file:/glassfish3/glassfish/modules/ha-shoal-cache-bootstrap.jar
org.osgi.framework.BundleException: Bundle symbolic name and version are not unique: org.glassfish.ha.shoal-cache-bootstrap:3.1.0
at org.apache.felix.framework.BundleImpl.createModule(BundleImpl.java:1180)
at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:79)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2528)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2436)
at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:129)
at org.jvnet.hk2.osgimain.Main.install(Main.java:363)
at org.jvnet.hk2.osgimain.Main.traverse(Main.java:293)
at org.jvnet.hk2.osgimain.Main.start(Main.java:144)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1835)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1752)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1156)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:745)

Nov 14, 2016 2:45:03 PM Main install
WARNING: Failed to install file:/glassfish3/glassfish/modules/grizzly-rcm.jar
org.osgi.framework.BundleException: Bundle symbolic name and version are not unique: com.sun.grizzly.rcm:1.9.31
at org.apache.felix.framework.BundleImpl.createModule(BundleImpl.java:1180)
at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:79)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2528)
at org.apache.felix.framework.Felix.installBundle(Felix.java:2436)
at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:129)
at org.jvnet.hk2.osgimain.Main.install(Main.java:363)
at org.jvnet.hk2.osgimain.Main.traverse(Main.java:293)
at org.jvnet.hk2.osgimain.Main.start(Main.java:144)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:629)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1835)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1752)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1156)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:745)
.....后面省略了

2.解决

$ cd /glassfish3/glassfish/modules
$ ls
acc-config.jar console-common-help.jar flashlight-framework.jar javax.resource.jar org.apache.felix.shell.remote.jar
admin-cli.jar console-common.jar gf-client-module.jar javax.security.auth.message.jar org.apache.felix.shell.tui.jar
admin-cli-l10n.jar console-common-l10n.jar gf-connectors-connector.jar javax.security.jacc.jar org.eclipse.persistence.antlr.jar
admin-core.jar console-community-branding-plugin.jar gf-ejb-connector.jar
后面输出省略

几乎所有module都load报错,那看来就是模块加载的问题了, 后来想到会不会是缓存问题。

实际上glassfish的模块是基于osgi的,而每个domain下都有个osgi缓存,于是清空cache试试。

cd /glassfish3/glassfish/domains/somedomain/
cp -pr osgi-cache bak-osgi-cache
mkdir osgi-cache

真的就解决了

问题就这么解决了。所以有时候拍拍脑袋还是管用的。 :D

asadmin start-domain somedomain
正常启动,console正常打开

3 其它资料

什么是OSGI? 百度了一下:
OSGi(Open Service Gateway Initiative)技术是Java动态化模块化系统的一系列规范。OSGi一方面指维护OSGi规范的OSGI官>方联盟,另一方面指的是该组织维护的基于Java语言的服务(业务)规范。简单来说,OSGi可以认为是Java平台的模块>层。

stackoverflow上给的详细文档
http://stackoverflow.com/questions/14464125/what-is-glassfish-osgi-cache
GlassFish modularity layers on top of OSGi, and the OSGi runtime that ships with GlassFish is Apache Felix. The OSGi >specification states that the OSGi runtime must cache bundles and store bundle runtime state. You can learn more here about >the Apache Felix OSGi Cache.

felix文档:
https://felix.apache.org/documentation/subprojects/apache-felix-framework/apache-felix-framework-bundle-cache.html