12 Replies Latest reply on Sep 19, 2013 8:01 AM by WarnerJan Veldhuis

    JBoss 7, subsystem for Quartz

    Cyril Delmas Newbie

      Hello,

      I am trying hard to create a Quartz (2.1.7) subsystem for JBoss 7.1.1.Final.

      I've generated the source with the maven archetype.

       

      Here are the questions :

      I am trying to understand how to build the model from my configuration :

      <?xml version="1.0" encoding="UTF-8"?>

      <subsystem xmlns="urn:com.lectra.fip.jboss:quartz:1.0">

          <config path="${jboss.server.config.dir}/quartz.properties" />

      </subsystem>

      - how do I define the model to match the add operation? In all my attempts (see QuartzExtension.QuartzParser), I have an error  "Operation contains a parameter....". I think I do not understand well how this work, and neither the doc nor the tutorial help.

      Then an architectural question:

      - should I start the Quartz scheduler  in the DeploymentUnitProcessor?

      Finally, a binding question:

      - how to make the scheduler available via JNDI (I can bind the subsystem to JNDI by configuration)?

       

      Please don't tell me to read the doc, I've been reading it for 3 days now; I really need help.

       

      Thanks in advance for any help!

        • 1. Re: JBoss 7, subsystem for Quartz
          Stephen Coy Master

          This is fun stuff.

           

          What is the deployment processor deploying?

          • 2. Re: JBoss 7, subsystem for Quartz
            Cyril Delmas Newbie

            I'm looking into the mail subsystem, which contains everything I need (JNDI binding, similar configuration model). At this time, I'm trying to transform it to my needs, I will let you know.

             

            The deployment processor won't deploy nothing, as it is not made for that. In fact, the add handler creates the service which is responsible for the scheduler creation.

            • 3. Re: JBoss 7, subsystem for Quartz
              Cyril Delmas Newbie

              Finally, I've managed to create a subsystem with Quartz.

              But I have a big problem: I use the BinderService to bind the Quartz scheduler to JNDI. When done, I have many errors such as

               

              INFO: JBAS014774: Service status report
              JBAS014775:    New missing/unsatisfied dependencies:
                    service jboss.naming.context.java.jboss (missing) dependents: [service jboss.naming.context.java.jboss.quartz.Scheduler]
              

               

              When I install the subsystem on my JBoss 7.1.1 installation, I have the following problems :

               

              16:58:03,209 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
              JBAS014775:    New missing/unsatisfied dependencies:
                    service jboss.binding.http (missing) dependents: [service jboss.web.connector.http]
                    service jboss.binding.management-http (missing) dependents: [service jboss.serverManagement.controller.management.http]
                    service jboss.binding.management-native (missing) dependents: [service jboss.remoting.server.management]
                    service jboss.binding.osgi-http (missing) dependents: [service jboss.osgi.as.framework.bootstrap]
                    service jboss.binding.remoting (missing) dependents: [service jboss.remoting.server.remoting-connector]
                    service jboss.binding.txn-recovery-environment (missing) dependents: [service jboss.txn.ArjunaRecoveryManager]
                    service jboss.binding.txn-status-manager (missing) dependents: [service jboss.txn.ArjunaRecoveryManager]
                    service jboss.outbound-socket-binding.mail-smtp (missing) dependents: [service jboss.mail-session.java:jboss/mail/Default]
                    service jboss.socket-binding-manager (missing) dependents: [service jboss.serverManagement.controller.management.http, service jboss.remoting.server.management, service jboss.remoting.server.remoting-connector]
              
              16:58:03,234 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015954: Admin console is not enabled
              16:58:03,235 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 4377ms - Started 108 of 166 services (27 services failed or missing dependencies, 30 services are passive or on-demand)
              

               

              This is the code I use to bind the scheduler :

               

               @Override
                  protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> controllers)
                      throws OperationFailedException {
                      final ServiceTarget serviceTarget = context.getServiceTarget();
              
                      ModelNode fullTree = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
                      final SchedulerConfig config = from(context, fullTree);
                      final QuartzService service = new QuartzService(config); // creates the scheduler internally
                      final String jndiName = getJndiName(operation, service);
              
                      final ServiceName serviceName = SERVICE_NAME_BASE.append(jndiName);
                      final ServiceBuilder<?> schedulerBuilder = serviceTarget.addService(serviceName, service)
                              .setInitialMode(ServiceController.Mode.ACTIVE)
                              .addListener(verificationHandler);
              
                      ManagedReferenceFactory valueManagedReferenceFactory = new ValueManagedReferenceFactory(new ImmediateValue<Object>(service.getValue())); // service.getValue() returns the scheduler
                      final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
                      final BinderService binderService = new BinderService(bindInfo.getBindName());
                      final ServiceBuilder<?> binderBuilder = 
                              serviceTarget.addService(bindInfo.getBinderServiceName(), binderService)
                                  .addInjection(binderService.getManagedObjectInjector(), valueManagedReferenceFactory)
                                  .addDependency(bindInfo.getParentContextServiceName(), 
                                          ServiceBasedNamingStore.class, 
                                          binderService.getNamingStoreInjector())
                                  .setInitialMode(ServiceController.Mode.ACTIVE)
                                  .addListener(verificationHandler);
              
                      controllers.add(schedulerBuilder.install());
                      controllers.add(binderBuilder.install());
                  }
              

               

              I have no errors without the Quartz subsystem. I guess I have a problem registering the services (in SchedulerAdd.java), but I don't see where is the problem.

               

              Maybe should I use the naming subsystem to bind the schedulers?

               

              Thanks for any help!

               

              Edit on 06/06

              • 4. Re: JBoss 7, subsystem for Quartz
                Tomaz Cerar Master

                hi,

                first error is related to some probably mistake in socket binding config.

                 

                does server boot without any problems if you dont enable your subsystem?

                • 5. Re: JBoss 7, subsystem for Quartz
                  Cyril Delmas Newbie

                  Yes. If I disable the subsystem, no error occurs. When I add it, it fails everytime.

                   

                  I added my source code in attachment. Maybe it will help you help me. I use a fresh install of JBoss 7.1.1.Final (download, unzip and run). I added quartz 2.1.7 as a module (org.quartz).

                   

                  Thank you very much for your help!

                   

                  Edit: added standalone.xml.

                  • 6. Re: JBoss 7, subsystem for Quartz
                    Stephen Coy Master

                    What happens if you try binding to java:jboss/QuartzScheduler instead?

                     

                    The java:global JNDI namespace is part of the container ENC namespace and I'm not sure it's legitimate for you to try and bind anything there.

                    • 7. Re: JBoss 7, subsystem for Quartz
                      Cyril Delmas Newbie

                      The same problem occurs with java:jboss instead of java:global; in fact, I tried with java:jboss first.

                      • 8. Re: JBoss 7, subsystem for Quartz
                        Stephen Coy Master

                        Hi Cyril,

                         

                        I think that instead of performing the JNDI binding in

                        {code:xml}<subsystem xmlns="urn:jboss:domain:naming:1.1">

                                  <bindings>

                                            <object-factory name="java:global/quartz/Scheduler"

                                                      module="com.lectra.fip.jboss.quartz" class="com.lectra.fip.jboss.extension.SchedulerObjectFactory" />

                                  </bindings>

                        </subsystem>{code}

                        you should be binding programmatically in the same way that the mail subsystem does it, using APIs that are available in the JBossAS naming subsystem.

                        • 9. Re: JBoss 7, subsystem for Quartz
                          Cyril Delmas Newbie

                          In fact, I'm already binding the scheduler the same way the mail subsystem does, as I just reused this code as-is, renaming the classes to my purpose. In the last version of my standalone.xml file, I don't use the naming subsystem to perform that.

                           

                          You can reproduce the problem using the config I attached in my previous post https://community.jboss.org/message/822209#822209.

                          • 10. Re: JBoss 7, subsystem for Quartz
                            Tomaz Cerar Master

                            I think this should be working version of scheduler subsystem:

                             

                            https://github.com/ctomc/quartz-subsystem

                             

                            didn't test it as part of AS but it should work.

                             

                             

                            when you are done with it, i can remove that code from github given that it is yours and not mine.

                             

                            also as Stephen said, no need to include anything in naming subsystem configuration...

                            --

                            tomaz

                            • 11. Re: JBoss 7, subsystem for Quartz
                              Cyril Delmas Newbie

                              First, thank you for your help.

                              I just tried to deploy the subsystem, and it doesn't work:

                               

                              D:\Apps\Red Hat\jboss-as-7.1.1.Final>bin\standalone.bat
                              Calling "D:\Apps\Red Hat\jboss-as-7.1.1.Final\bin\standalone.conf.bat"
                              ===============================================================================
                              
                                JBoss Bootstrap Environment
                              
                                JBOSS_HOME: D:\Apps\Red Hat\jboss-as-7.1.1.Final
                              
                                JAVA: D:\Apps\Java\jdk-1.6.0_24\bin\java
                              
                                JAVA_OPTS: -XX:+TieredCompilation -Dprogram.name=standalone.bat -Xms64M -Xmx512M -XX:MaxPermSize=256M -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.default.config=standalone.xml
                              
                              ===============================================================================
                              
                              14:13:08,855 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
                              14:13:08,969 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
                              14:13:09,000 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting
                              14:13:09,495 INFO  [org.xnio] XNIO Version 3.0.3.GA
                              14:13:09,495 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
                              14:13:09,502 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
                              14:13:09,509 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
                              14:13:09,509 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
                              14:13:09,516 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 39) JBAS011800: Activating Naming Subsystem
                              14:13:09,518 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 40) JBAS011940: Activating OSGi Subsystem
                              14:13:09,522 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013101: Activating Security Subsystem
                              14:13:09,523 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 49) JBAS015537: Activating WebServices Extension
                              14:13:09,525 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 27) JBAS016200: Activating ConfigAdmin Subsystem
                              14:13:09,525 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.
                              14:13:09,533 INFO  [org.jboss.as.security] (MSC service thread 1-1) JBAS013100: Current PicketBox version=4.0.7.Final
                              14:13:09,537 INFO  [com.lectra.fip.jboss.extension.QuartzService] (ServerService Thread Pool -- 51) Using configuration file D:\Apps\Red Hat\jboss-as-7.1.1.Final\standalone\configuration/quartz.properties
                              14:13:09,565 INFO  [org.jboss.as.naming] (MSC service thread 1-7) JBAS011802: Starting Naming Service
                              14:13:09,576 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-12) JBAS015400: Bound mail session [java:jboss/mail/Default]
                              14:13:09,576 INFO  [org.jboss.as.connector] (MSC service thread 1-14) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)
                              14:13:09,600 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
                              14:13:09,610 INFO  [org.quartz.impl.StdSchedulerFactory] (ServerService Thread Pool -- 51) Using default implementation for ThreadExecutor
                              14:13:09,633 INFO  [org.quartz.core.SchedulerSignalerImpl] (ServerService Thread Pool -- 51) Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
                              14:13:09,635 INFO  [org.quartz.core.QuartzScheduler] (ServerService Thread Pool -- 51) Quartz Scheduler v.2.1.7 created.
                              14:13:09,637 INFO  [org.quartz.simpl.RAMJobStore] (ServerService Thread Pool -- 51) RAMJobStore initialized.
                              14:13:09,646 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-8) JBoss Web Services - Stack CXF Server 4.0.2.GA
                              14:13:09,647 INFO  [org.quartz.core.QuartzScheduler] (ServerService Thread Pool -- 51) Scheduler meta-data: Quartz Scheduler (v2.1.7) 'JBossQuartzScheduler' with instanceId 'NON_CLUSTERED'
                                Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
                                NOT STARTED.
                                Currently in standby mode.
                                Number of jobs executed: 0
                                Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 5 threads.
                                Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
                              
                              14:13:09,657 INFO  [org.quartz.impl.StdSchedulerFactory] (ServerService Thread Pool -- 51) Quartz scheduler 'JBossQuartzScheduler' initialized from the specified file : 'D:\Apps\Red Hat\jboss-as-7.1.1.Final\standalone\configuration/quartz.properties'
                              14:13:09,659 INFO  [org.quartz.impl.StdSchedulerFactory] (ServerService Thread Pool -- 51) Quartz scheduler version: 2.1.7
                              14:13:09,662 INFO  [com.lectra.fip.jboss.extension.QuartzService] (MSC service thread 1-2) Starting the scheduler JBossQuartzScheduler
                              14:13:09,663 INFO  [org.quartz.core.QuartzScheduler] (MSC service thread 1-2) Scheduler JBossQuartzScheduler_$_NON_CLUSTERED started.
                              14:13:09,665 INFO  [com.lectra.fip.jboss.extension.SchedulerAdd] (MSC service thread 1-10) Bound scheduler to: java:jboss/QuartzScheduler
                              14:13:09,929 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) JBAS015012: Started FileSystemDeploymentService for directory D:\Apps\Red Hat\jboss-as-7.1.1.Final\standalone\deployments
                              14:13:12,947 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
                              JBAS014775:    New missing/unsatisfied dependencies:
                                    service jboss.binding.http (missing) dependents: [service jboss.web.connector.http]
                                    service jboss.binding.management-http (missing) dependents: [service jboss.serverManagement.controller.management.http]
                                    service jboss.binding.management-native (missing) dependents: [service jboss.remoting.server.management]
                                    service jboss.binding.osgi-http (missing) dependents: [service jboss.osgi.as.framework.bootstrap]
                                    service jboss.binding.remoting (missing) dependents: [service jboss.remoting.server.remoting-connector]
                                    service jboss.binding.txn-recovery-environment (missing) dependents: [service jboss.txn.ArjunaRecoveryManager]
                                    service jboss.binding.txn-status-manager (missing) dependents: [service jboss.txn.ArjunaRecoveryManager]
                                    service jboss.outbound-socket-binding.mail-smtp (missing) dependents: [service jboss.mail-session.java:jboss/mail/Default]
                                    service jboss.socket-binding-manager (missing) dependents: [service jboss.serverManagement.controller.management.http, service jboss.remoting.server.management, service jboss.remoting.server.remoting-connector]
                              
                              14:13:12,980 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015954: Admin console is not enabled
                              14:13:12,981 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 4279ms - Started 108 of 166 services (27 services failed or missing dependencies, 30 services are passive or on-demand)
                              

                               

                              As you can see, the Quartz scheduler is started (the same) then bound to JNDI (thank you !), but in the end, the same problem occurs. That's really strange, I cannot see why.

                              Note that when I stop the server, I get this log:

                               

                              14:25:00,867 INFO  [org.jboss.as.logging] JBAS011503: Restored bootstrap log handlers
                              14:25:00,868 INFO  [com.lectra.fip.jboss.extension.SchedulerAdd] Removed scheduler: java:jboss/QuartzScheduler
                              14:25:00,874 INFO  [org.jboss.as.controller] JBAS014774: Service status report
                              JBAS014776:    Newly corrected services:
                                    service jboss.binding.http (new available)
                                    service jboss.binding.management-http (new available)
                                    service jboss.binding.management-native (new available)
                                    service jboss.binding.osgi-http (new available)
                                    service jboss.binding.remoting (new available)
                                    service jboss.binding.txn-recovery-environment (new available)
                                    service jboss.binding.txn-status-manager (new available)
                                    service jboss.outbound-socket-binding.mail-smtp (new available)
                                    service jboss.socket-binding-manager (new available)
                              
                              14:25:00,875 INFO  [org.jboss.as] JBAS015950: JBoss AS 7.1.1.Final "Brontes" stopped in 11ms
                              

                               

                              I've been on this code for a long time, maybe there is something I miss. Any suggestions?

                              Once more, thank you for your help!

                              • 12. Re: JBoss 7, subsystem for Quartz
                                WarnerJan Veldhuis Newbie

                                Sorry to wake up a relatively old thread, but did you manage to get the subsystem running? I am migrating from JBoss 4.2.2 GA (I know, don't ask...) to Wildfly 8 and I really would like to see this subsystem nicely integrated. Kudos for your effort so far!