5 Replies Latest reply on Sep 11, 2013 12:00 PM by Tomaz Cerar

    Jboss AS 7.1 and Quartz Again

    Rom Axko Newbie

      Hi All!
      I'm trying to implement simple quartz scheduler in my EJB application with JBOSS AS 7.1
      And when I start it I get the following error:

       

      12:07:37,156 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."quartz-first.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."quartz-first.jar".POST_MODULE: Failed to process phase POST_MODULE of deployment "quartz-first.jar"

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

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

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

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_37]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_37]

          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_37]

      Caused by: java.lang.RuntimeException: Error getting reflective information for class org.quartz.first.quartzfirst.SchedulerBean with ClassLoader ModuleClassLoader for Module "deployment.quartz-first.jar:main" from Service Module Loader

          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

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

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

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

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

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

          ... 5 more

      Caused by: java.lang.NoClassDefFoundError: org/quartz/ScheduleBuilder

          at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.6.0_37]

          at java.lang.Class.privateGetDeclaredFields(Class.java:2291) [rt.jar:1.6.0_37]

          at java.lang.Class.getDeclaredFields(Class.java:1743) [rt.jar:1.6.0_37]

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

          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

          ... 10 more

      Caused by: java.lang.ClassNotFoundException: org.quartz.ScheduleBuilder from [Module "deployment.quartz-first.jar:main" from Service Module Loader]

          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

          ... 15 more

       

      I have read about the same problem with JBoss 7 here Quartz Scheduler in Jboss AS 7 and tried to follow advices in this thread but I still have this error.

       

      SchedulerBean class

       

      package org.quartz.first.quartzfirst;
      
      import javax.annotation.PostConstruct;
      import javax.ejb.Singleton;
      import javax.ejb.Startup;
      
      import org.jboss.logging.Logger;
      import org.quartz.JobBuilder;
      import org.quartz.JobDetail;
      import org.quartz.Scheduler;
      import org.quartz.SimpleScheduleBuilder;
      import org.quartz.SimpleTrigger;
      import org.quartz.TriggerBuilder;
      import org.quartz.impl.StdSchedulerFactory;
      
      
      @Startup
      @Singleton
      public class SchedulerBean {
      
          private static final Logger logger = Logger.getLogger(SchedulerBean.class);
         
          @PostConstruct
          void init() {
              try {
                  Scheduler sched = new StdSchedulerFactory().getScheduler();
      
                  JobDetail testjob = JobBuilder.newJob(TestJob.class)
                  .withIdentity("testjob", "testgroup")
                  .build();
                 
                  SimpleTrigger trigger = TriggerBuilder.newTrigger()
                  .withIdentity("testtrigger", "testgroup")
                  .withSchedule(SimpleScheduleBuilder.simpleSchedule()
                  .withIntervalInSeconds(10)
                  .repeatForever())
                  .build();
                 
                  sched.scheduleJob(testjob, trigger);
                  sched.start();
              }
              catch (Throwable t) {
                  logger.info("Exception caught!" + t);
              }
      
          }
      
      }
      
      
      

       

      TestJob class

       

      package org.quartz.first.quartzfirst;
      
      import org.quartz.Job;
      import org.quartz.JobExecutionContext;
      import org.quartz.JobExecutionException;
      
      public class TestJob implements Job {
          @Override
          public void execute(JobExecutionContext context)
                  throws JobExecutionException {
              System.out.println("Quartz test job executed!");
          }
      }
      


      pom.xml:

       

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
      
          <groupId>org.quartz.first</groupId>
          <artifactId>quartz-first</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <packaging>ejb</packaging>
      
          <name>quartz-first</name>
      
          <properties>
              <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          </properties>
      
          <dependencyManagement>
              <dependencies>
                  <dependency>
                      <groupId>org.jboss.spec</groupId>
                      <artifactId>jboss-javaee-6.0</artifactId>
                      <version>3.0.2.Final</version>
                      <type>pom</type>
                      <scope>import</scope>
                  </dependency>
              </dependencies>
          </dependencyManagement>
      
          <dependencies>
          
              <dependency>
                  <groupId>org.jboss.spec.javax.annotation</groupId>
                  <artifactId>jboss-annotations-api_1.1_spec</artifactId>
                  <scope>provided</scope>
              </dependency>
              <dependency>
                  <groupId>org.jboss.spec.javax.ejb</groupId>
                  <artifactId>jboss-ejb-api_3.1_spec</artifactId>
                  <scope>provided</scope>
              </dependency>
              <dependency>
                  <groupId>org.jboss.logging</groupId>
                  <artifactId>jboss-logging</artifactId>
                  <version>3.1.3.GA</version>
              </dependency>
              <dependency>
                  <groupId>org.quartz-scheduler</groupId>
                  <artifactId>quartz</artifactId>
                  <version>2.2.0</version>
              </dependency>
          </dependencies>
      
          <build>
              <finalName>${project.artifactId}</finalName>
              <plugins>
                  <plugin>
                      <groupId>org.jboss.as.plugins</groupId>
                      <artifactId>jboss-as-maven-plugin</artifactId>
                      <version>${version.jboss.maven.plugin}</version>
                      <configuration>
                          <filename>${project.build.finalName}.jar</filename>
                      </configuration>
                  </plugin>
                  <plugin>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <version>2.3.1</version>
                      <configuration>
                          <source>1.6</source>
                          <target>1.6</target>
                      </configuration>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-ejb-plugin</artifactId>
                      <version>2.3</version>
                      <configuration>
                          <ejbVersion>3.1</ejbVersion>
                          <generateClient>true</generateClient>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
      
      </project>