5 Replies Latest reply on Jul 5, 2013 7:54 AM by Valentin Podlovchenko

    Problem with ha cluster singleton service

    Valentin Podlovchenko Newbie

      Hello to everybody!

       

      I try to write HA cluster singleton service under JBoss AS 7 but with no luck((( Looked all documentation for already a few days, tried different approaches found in forums and documentation but it's still doesn't work for me.

       

      I tryed two ways:

      1) With service activator (org.jboss.msc.service.ServiceActivator) but got exception:

       

      ...

      Caused by: org.jboss.msc.inject.InjectionException: Injecting the wrong type (expected class org.jboss.as.server.ServerEnvironment, got class org.jboss.as.server.ServerEnvironment)

                at org.jboss.msc.inject.CastingInjector.inject(CastingInjector.java:53) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                at org.jboss.msc.service.ServiceControllerImpl.doInject(ServiceControllerImpl.java:1549) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                at org.jboss.msc.service.ServiceControllerImpl.access$1900(ServiceControllerImpl.java:49) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.performInjections(ServiceControllerImpl.java:1780) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1741) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                ... 3 more

       

      2) With Service, ServiceStartupBean and ServiceAccessBean (found in EAP 6.1 Migration Guide) but got exception:

       

      ...

      Caused by: java.lang.NullPointerException

                at org.jboss.as.clustering.singleton.SingletonService.build(SingletonService.java:90)

                at org.jboss.as.clustering.singleton.SingletonService.build(SingletonService.java:86)

                at ***MYCLASS**.ServiceStartup.startup(EGMBUpdateServiceStartup.java:39)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [classes.jar:1.6.0_51]

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [classes.jar:1.6.0_51]

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [classes.jar:1.6.0_51]

                at java.lang.reflect.Method.invoke(Method.java:597) [classes.jar:1.6.0_51]

                at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptorFactory$ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptorFactory.java:130) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]

                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]

                at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:73)

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]

                at org.jboss.as.ee.component.ManagedReferenceInterceptorFactory$ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptorFactory.java:95) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]

                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]

                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]

                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:248)

                ... 20 more

       

      it seems that code CurrentServiceContainer.getServiceContainer(); returns NULL.

       

      I tried to do it with JBoss AS 7.1.0.Final and with EAP 6.1 using both standalone and domain configs with ha and full-ha profiles... Operating system: Mac OS X 10.8.4.

       

      ha-clustering-singleton quickstart is building and running with no problem...

       

      I doesn't provide my source code because it's absolutely like in documentation... If you need, I can send it too...

       

      Where I can be wrong?

        • 1. Re: Problem with ha cluster singleton service
          Radoslav Husar Master

          expected class org.jboss.as.server.ServerEnvironment, got class org.jboss.as.server.ServerEnvironment

          That looks like you have messed up dependencies on the classpath. Make sure you are not bundling any AS classes in your war/ear.

          • 2. Re: Problem with ha cluster singleton service
            Valentin Podlovchenko Newbie

            I thought about this, but can't say exactly if I provide any AS libraries with my EAR...

             

            I'm quite a newby in JBoss development and it seems strange comparing to WebSphere (may be I do something wrong). When I develop WebSphere application I set target runtime of application server and see all libraries provided by that target runtime, when I create project(s) for JBoss I doesn't see any server libraries until I add them to maven dependencies... So I added a lot of dependencies to maven... Some simple projects work well with no problem, so the first real problem for me is that cluster singleton service)))

            • 3. Re: Problem with ha cluster singleton service
              Radoslav Husar Master

              Maybe this maven documentation will help http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope especially look at 'provided' scope, make sure that all AS/EAP dependencies are marked as provided.

              1 of 1 people found this helpful
              • 4. Re: Problem with ha cluster singleton service
                Valentin Podlovchenko Newbie

                Thank You for your replies))) I really found some problems in my maven dependency configuration and fixed them (removed all of my dependencies and added some "provided" by application server). But singleton service still doesn't work...

                 

                With ServiceActivator I got exception:

                 

                [0m[31m17:17:10,923 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-12) MSC000001: Failed to start service jboss.deployment.subunit."weather-ear.ear"."weather-ejb-0.0.1-SNAPSHOT.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."weather-ear.ear"."weather-ejb-0.0.1-SNAPSHOT.jar".INSTALL: JBAS018733: Failed to process phase INSTALL of subdeployment "weather-ejb-0.0.1-SNAPSHOT.jar" of deployment "weather-ear.ear"

                          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:127) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [classes.jar:1.6.0_51]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [classes.jar:1.6.0_51]

                          at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_51]

                Caused by: java.lang.NoClassDefFoundError: org/jboss/as/clustering/singleton/SingletonService

                          at ru.libram.weather.service.EGMBUpdateServiceActivator.activate(EGMBUpdateServiceActivator.java:23)

                          at org.jboss.as.server.deployment.service.ServiceActivatorProcessor.deploy(ServiceActivatorProcessor.java:62) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                          ... 5 more

                Caused by: java.lang.ClassNotFoundException: org.jboss.as.clustering.singleton.SingletonService from [Module "deployment.weather-ear.ear.weather-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader]

                          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:399) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          ... 8 more

                 

                 

                With ServiceStartup bean I got exception:

                 

                [0m[31m17:25:18,587 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.subunit."weather-ear.ear"."weather-ejb-0.0.1-SNAPSHOT.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."weather-ear.ear"."weather-ejb-0.0.1-SNAPSHOT.jar".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of subdeployment "weather-ejb-0.0.1-SNAPSHOT.jar" of deployment "weather-ear.ear"

                          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:127) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [classes.jar:1.6.0_51]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) [classes.jar:1.6.0_51]

                          at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_51]

                Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class ru.libram.weather.service.EGMBUpdateServiceStartup with ClassLoader ModuleClassLoader for Module "deployment.weather-ear.ear.weather-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader

                          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:72) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                          at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:58)

                          at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:107)

                          at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:92)

                          at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:77)

                          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                          ... 5 more

                Caused by: java.lang.NoClassDefFoundError: org/jboss/msc/service/ServiceListener

                          at java.lang.Class.getDeclaredFields0(Native Method) [classes.jar:1.6.0_51]

                          at java.lang.Class.privateGetDeclaredFields(Class.java:2339) [classes.jar:1.6.0_51]

                          at java.lang.Class.getDeclaredFields(Class.java:1770) [classes.jar:1.6.0_51]

                          at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:68) [jboss-as-server-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

                          ... 10 more

                Caused by: java.lang.ClassNotFoundException: org.jboss.msc.service.ServiceListener from [Module "deployment.weather-ear.ear.weather-ejb-0.0.1-SNAPSHOT.jar:main" from Service Module Loader]

                          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:399) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119) [jboss-modules.jar:1.2.0.Final-redhat-1]

                          ... 15 more

                 

                Both seems to be very like each other, like server doesn't have jboss-msc or jboss-as-clustering-singleton in it classpath...

                 

                I found this post https://community.jboss.org/thread/196380, but recipe from it doesn't help(((

                • 5. Re: Problem with ha cluster singleton service
                  Valentin Podlovchenko Newbie

                  The problem was I forget to add manifest dependencies generation to my pom.xml:

                   

                  <archive>

                       <manifestEntries>

                            <Dependencies>org.jboss.msc,

                                 org.jboss.as.clustering.singleton,

                                 org.jboss.as.server</Dependencies>

                       </manifestEntries>

                  </archive>