简体   繁体   English

Glassfish上的Hazelcast作为OSGI捆绑包

[英]Hazelcast on Glassfish as an OSGI bundle

Good day. 美好的一天。 I have some difficulties using the Hazelcast in Glassfish OSGi environment. 在Glassfish OSGi环境中使用Hazelcast时遇到一些困难。

I have an OSGi bundle, which provides some EJBs and intended to be deployed on glassfish. 我有一个OSGi捆绑软件,该捆绑软件提供了一些EJB,并打算部署在glassfish上。 This bundle uses Hazelcast and imports some hazelcast packages. 该捆绑软件使用Hazelcast并导入一些hazelcast软件包。 I don't want to embed hazelcast jar so I tried to deploy it in Glassfish prior to deploying the subj. 我不想嵌入hazelcast jar,因此在部署subj之前,我尝试将其部署在Glassfish中。 bundle. 束。

$ asadmin deploy --type=osgi minimal-json-0.9.1.jar
$ asadmin deploy --type=osgi hazelcast-3.3.3.jar

Hazelcast deployed successfully. Hazelcast已成功部署。 But when I deploy my bundle, and when one of the EJBs from this bundle tries to create a HazelcastInstance, I get the following exception: 但是,当我部署我的捆绑软件时,以及当该捆绑软件中的一个EJB试图创建HazelcastInstance时,都会出现以下异常:

org.glassfish.osgijavaeebase.DeploymentException: Deployment of xxx.xxx.platon-cache [398] failed because of following reason: Failed while deploying bundle xxx.xxx.platon-cache [398] : java.lang.RuntimeException: Failed to deploy bundle [ xxx.xxx.platon-cache [398] ], root cause: Exception while loading the app
    at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:127)
    at org.glassfish.osgijavaeebase.OSGiContainer.deploy(OSGiContainer.java:154)
    at org.glassfish.osgijavaeebase.JavaEEExtender.deploy(JavaEEExtender.java:109)
    at org.glassfish.osgijavaeebase.JavaEEExtender.access$200(JavaEEExtender.java:61)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:153)
    at org.glassfish.osgijavaeebase.JavaEEExtender$HybridBundleTrackerCustomizer$1.call(JavaEEExtender.java:150)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Failed to deploy bundle [ xxx.xxx.platon-cache [398] ], root cause: Exception while loading the app
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:198)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.execute(OSGiDeploymentRequest.java:120)
    at org.glassfish.osgijavaeebase.AbstractOSGiDeployer.deploy(AbstractOSGiDeployer.java:123)
    ... 9 more
Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Initialization failed for Singleton HazelcastService
    at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:656)
    at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:396)
    at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:219)
    at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:180)
    at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:158)
    at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:166)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.osgijavaeebase.OSGiDeploymentRequest.deploy(OSGiDeploymentRequest.java:185)
    ... 11 more
Caused by: javax.ejb.CreateException: Initialization failed for Singleton HazelcastService
    at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:483)
    at com.sun.ejb.containers.AbstractSingletonContainer.access$000(AbstractSingletonContainer.java:81)
    at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:654)
    ... 22 more
Caused by: java.lang.IllegalArgumentException: PortableFactory[-17] is already registered! com.hazelcast.concurrent.atomiclong.client.AtomicLongPortableHook$1@682d1719 -> com.hazelcast.concurrent.atomiclong.client.AtomicLongPortableHook$1@68479fbd
    at com.hazelcast.nio.serialization.PortableHookLoader.register(PortableHookLoader.java:84)
    at com.hazelcast.nio.serialization.PortableHookLoader.load(PortableHookLoader.java:51)
    at com.hazelcast.nio.serialization.PortableHookLoader.<init>(PortableHookLoader.java:41)
    at com.hazelcast.nio.serialization.SerializationServiceImpl.<init>(SerializationServiceImpl.java:119)
    at com.hazelcast.nio.serialization.SerializationServiceBuilder.build(SerializationServiceBuilder.java:175)
    at com.hazelcast.instance.Node.createSerializationService(Node.java:195)
    at com.hazelcast.instance.Node.<init>(Node.java:142)
    at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:120)
    at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:153)
    at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:136)
    at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:112)
    at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:58)
    at xxx.xxx.platon.cache.HazelcastService.init(HazelcastService.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1035)
    at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
    at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
    at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
    at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:125)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
    at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:412)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:375)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:1949)
    at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:475)
    ... 24 more
]]

The hazelcast instance is created in the only place, so there shouldn't be any conflicts with some other hazelcast cluster. hazelcast实例是在唯一的位置创建的,因此与其他hazelcast群集不应有任何冲突。 Everything works correctly in non-osgi environment. 一切在非osgi环境中均可正常运行。

The hazelcast config is the simpliest one: hazelcast配置是最简单的配置:

<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.1.xsd" xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <group>
        <name>dev</name>
        <password>dev-pass</password>
    </group>
    <network>
        <port auto-increment="true" port-count="100">5701</port>
        <outbound-ports>
            <ports>0</ports>
        </outbound-ports>
        <join>
            <multicast enabled="false">
                <multicast-group>224.2.2.3</multicast-group>
                <multicast-port>54327</multicast-port>
            </multicast>
            <tcp-ip enabled="true">
                <interface>127.0.0.1</interface>
            </tcp-ip>
        </join>
    </network>
</hazelcast>

What is the reason of this exception? 发生此异常的原因是什么?

it smells very much like this issue: https://github.com/hazelcast/hazelcast/issues/3922 . 它闻起来很像这个问题: https : //github.com/hazelcast/hazelcast/issues/3922 Can you please try it with the latest Hazelcast 3.3.4-SNAPSHOT ? 您可以在最新的Hazelcast 3.3.4-SNAPSHOT中试用吗? It should be fixed there. 它应该固定在那里。

EDIT: This workaround is not needed anymore; 编辑:不再需要此解决方法; Latest releases of both 3.3 and 3.4 branches include this fix. 3.3和3.4分支的最新版本均包含此修复程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OSGI关于Glassfish的捆绑软件间通信 - OSGI Inter-bundle Communication on Glassfish 如何告诉 Glassfish 使用或根本不使用哪个 OSGI 包 - How to tell Glassfish which OSGI bundle to use or not to use it at all Glassfish,OSGi Web应用程序捆绑包(WAB)和虚拟服务器 - Glassfish, OSGi web application bundle (WAB) and virtual servers 使用osgi软件包重新启动服务器时,Glassfish崩溃 - Glassfish crashes when I restart the server with osgi bundle 无法启动OSGiModuleImpl :: Bundle = [org.glassfish.main.admingui.glassfish-osgi-console-plugin [302]],State = [NEW] - Failed to start OSGiModuleImpl:: Bundle = [org.glassfish.main.admingui.glassfish-osgi-console-plugin [302]], State = [NEW] ClassNotFoundException:在嵌入了 cxf 依赖项的 OSGi 包中找不到 org.glassfish.jersey.internal.RuntimeDelegateImpl - ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl cannot be found in OSGi bundle which has embedded cxf dependencies java.util.logging,ResourceBundles,SAAJ:加载Glassfish OSGi Webapp捆绑包时出现异常 - java.util.logging, ResourceBundles, SAAJ: exception on loading Glassfish OSGi webapp bundle Glassfish OSGI Web控制台证书 - Glassfish OSGI Webconsole Credentials Glassfish作为OSGi容器 - Glassfish as an OSGi Container GlassFish如何成为OSGi容器? - How is GlassFish an OSGi container?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM