Spring と Quartz の基本的な例を機能させようとしています。これが私がフォローしているチュートリアルです: http://www.mkyong.com/spring/spring-quartz-scheduler-example/
わかる限りすべてを正確にコピーしましたが、出力ウィンドウに何も表示されません。
spring-quartz.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="runMeTask" class="com.ksc.jobs.RunMeTask" />
<!-- Spring Quartz -->
<bean name="runMeJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.ksc.jobs.RunMeJob" />
<property name="jobDataAsMap">
<map>
<entry key="runMeTask" value-ref="runMeTask" />
</map>
</property>
</bean>
<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="runMeJob" />
<property name="repeatInterval" value="5000" />
<property name="startDelay" value="1000" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="jobDetails">
<list>
<ref bean="runMeJob" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="simpleTrigger" />
</list>
</property>
</bean>
</beans>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<import resource="spring-quartz.xml"/>
</beans>
プロジェクトの構造
編集
どうにかしてジョブを手動で開始する必要がありますか? そのチュートリアルや他のチュートリアルでは、通常、main()
メソッド内でクォーツジョブを開始します。main
デスクトップ アプリにあるメソッドしか知らないので、私には少し奇妙に思える .NET バックグラウンドから来ています。ウェブアプリではありません。ASP.NET にはGlobal.asax
、Web アプリの起動時に実行するコードを呼び出す場所があります。Javaに相当するものはありますか? それとも、これはまったく問題ではないのでしょうか? 私はここで推測しています。誰かがこれを解決する方法について何か考えがある場合、または実際のサンプルを提供してくれる場合(上記のものとは異なる場合もあります。私はうるさいわけではありません)...それをいただければ幸いです。後で要件に合わせて変更できる基本的な作業サンプルが必要です。
編集2
これが役立つ場合、グラスフィッシュサーバーの出力は次のとおりです。
[注: この投稿の本文の長さが長すぎるため、削除されました。そうしないと、以下の編集 #3 を投稿できません。]
編集3
多少の進歩はありますが、まだ機能していません。@shuttsy の提案に従って log4j ファイルを追加しました。これは、glassfish からの新しい出力です。
Launching GlassFish on Felix platform
INFO: Running GlassFish Version: GlassFish Server Open Source Edition 3.1.2.2 (build 5)
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
INFO: Grizzly Framework 1.9.50 started in: 0ms - bound to [0.0.0.0:3700]
INFO: Grizzly Framework 1.9.50 started in: 31ms - bound to [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.50 started in: 15ms - bound to [0.0.0.0:8181]
INFO: Grizzly Framework 1.9.50 started in: 15ms - bound to [0.0.0.0:4848]
INFO: Grizzly Framework 1.9.50 started in: 0ms - bound to [0.0.0.0:7676]
INFO: The Admin Console is already installed, but not yet loaded.
INFO: GlassFish Server Open Source Edition 3.1.2.2 (5) startup time : Felix (1,750ms), startup services(771ms), total(2,521ms)
INFO: HV000001: Hibernate Validator 4.3.0.Final
INFO: JMX005: JMXStartupService had Started JMXConnector on JMXService URL service:jmx:rmi://Matt-Laptop:8686/jndi/rmi://Matt-Laptop:8686/jmxrmi
INFO: Grizzly Framework 1.9.50 started in: 0ms - bound to [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.50 started in: 0ms - bound to [0.0.0.0:8181]
INFO: Created EjbThreadPoolExecutor with thread-core-pool-size 16 thread-max-pool-size 32 thread-keep-alive-seconds 60 thread-queue-capacity 2147483647 allow-core-thread-timeout false
INFO: SEC1002: Security Manager is OFF.
INFO: SEC1010: Entering Security Startup Service
INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
INFO: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
INFO: SEC1011: Security Service(s) Started Successfully
INFO: WEB0169: Created HTTP listener [http-listener-1] on host/port [0.0.0.0:8080]
INFO: WEB0169: Created HTTP listener [http-listener-2] on host/port [0.0.0.0:8181]
INFO: WEB0169: Created HTTP listener [admin-listener] on host/port [0.0.0.0:4848]
INFO: WEB0171: Created virtual server [server]
INFO: WEB0171: Created virtual server [__asadmin]
INFO: WEB0172: Virtual server [server] loaded default web module []
SEVERE: Exception while visiting com/sun/gjc/spi/JdbcObjectsFactory.class of size 3615
java.lang.NullPointerException
at org.glassfish.hk2.classmodel.reflect.impl.TypesImpl.getType(TypesImpl.java:78)
at org.glassfish.hk2.classmodel.reflect.impl.ModelClassVisitor.visit(ModelClassVisitor.java:119)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:363)
at org.glassfish.hk2.classmodel.reflect.util.JarArchive.onSelectedEntries(JarArchive.java:125)
at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:348)
at org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:70)
at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:307)
at org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:296)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
INFO: EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
INFO: file:/C:/Users/Matt/Documents/NetBeansProjects/KSC/build/web/WEB-INF/classes/_KSCPU login successful
WARNING: Multiple [2] JMX MBeanServer instances exist, we will use the server at index [0] : [com.sun.enterprise.v3.admin.DynamicInterceptor@28245558].
WARNING: JMX MBeanServer in use: [com.sun.enterprise.v3.admin.DynamicInterceptor@28245558] from index [0]
WARNING: JMX MBeanServer in use: [com.sun.jmx.mbeanserver.JmxMBeanServer@3a683b33] from index [1]
SEVERE: log4j:ERROR log4j called after unloading, see http://logging.apache.org/log4j/1.2/faq.html#unload.
SEVERE: java.lang.IllegalStateException: Class invariant violation
at org.apache.log4j.LogManager.getLoggerRepository(LogManager.java:199)
at org.apache.log4j.LogManager.getLogger(LogManager.java:228)
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
at org.springframework.beans.TypeConverterDelegate.<clinit>(TypeConverterDelegate.java:53)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:140)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:949)
at java.lang.reflect.Field.getFieldAccessor(Field.java:930)
at java.lang.reflect.Field.get(Field.java:372)
at org.glassfish.web.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1833)
at org.glassfish.web.loader.WebappClassLoader.stop(WebappClassLoader.java:1662)
at org.glassfish.web.loader.WebappClassLoader.preDestroy(WebappClassLoader.java:1631)
at org.glassfish.deployment.common.DeploymentContextImpl.getClassLoader(DeploymentContextImpl.java:236)
at org.glassfish.deployment.common.DeploymentContextImpl.getClassLoader(DeploymentContextImpl.java:186)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:450)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
SEVERE: at org.apache.log4j.LogManager.getLoggerRepository(LogManager.java:199)
SEVERE: at org.apache.log4j.LogManager.getLogger(LogManager.java:228)
SEVERE: at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
SEVERE: at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
SEVERE: at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
SEVERE: at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
SEVERE: at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
SEVERE: at org.springframework.beans.TypeConverterDelegate.<clinit>(TypeConverterDelegate.java:53)
SEVERE: at sun.misc.Unsafe.ensureClassInitialized(Native Method)
SEVERE: at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
SEVERE: at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:140)
SEVERE: at java.lang.reflect.Field.acquireFieldAccessor(Field.java:949)
SEVERE: at java.lang.reflect.Field.getFieldAccessor(Field.java:930)
SEVERE: at java.lang.reflect.Field.get(Field.java:372)
SEVERE: at org.glassfish.web.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1833)
SEVERE: at org.glassfish.web.loader.WebappClassLoader.stop(WebappClassLoader.java:1662)
SEVERE: at org.glassfish.web.loader.WebappClassLoader.preDestroy(WebappClassLoader.java:1631)
SEVERE: at org.glassfish.deployment.common.DeploymentContextImpl.getClassLoader(DeploymentContextImpl.java:236)
SEVERE: at org.glassfish.deployment.common.DeploymentContextImpl.getClassLoader(DeploymentContextImpl.java:186)
SEVERE: at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:450)
SEVERE: at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
SEVERE: at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
SEVERE: at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
SEVERE: at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
SEVERE: at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
SEVERE: at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
SEVERE: at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
SEVERE: at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
SEVERE: at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
SEVERE: at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
SEVERE: at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
SEVERE: at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
SEVERE: at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
SEVERE: at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
SEVERE: at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
SEVERE: at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
SEVERE: at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
SEVERE: at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
SEVERE: at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
SEVERE: at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
SEVERE: at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
SEVERE: at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
SEVERE: at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
SEVERE: at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
SEVERE: at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
SEVERE: at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
SEVERE: at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
SEVERE: at java.lang.Thread.run(Thread.java:722)
INFO: EJB5181:Portable JNDI names for EJB EventApplicationService: [java:global/KSC/EventApplicationService!com.ksc.services.EventApplicationService, java:global/KSC/EventApplicationService]
INFO: EJB5181:Portable JNDI names for EJB SiteSettingService: [java:global/KSC/SiteSettingService!com.ksc.services.SiteSettingService, java:global/KSC/SiteSettingService]
INFO: EJB5181:Portable JNDI names for EJB EventsService: [java:global/KSC/EventsService, java:global/KSC/EventsService!com.ksc.services.EventsService]
INFO: EJB5181:Portable JNDI names for EJB UserService: [java:global/KSC/UserService, java:global/KSC/UserService!com.ksc.services.UserService]
INFO: EJB5181:Portable JNDI names for EJB RoleService: [java:global/KSC/RoleService!com.ksc.services.RoleService, java:global/KSC/RoleService]
INFO: EJB5181:Portable JNDI names for EJB AnnouncementService: [java:global/KSC/AnnouncementService!com.ksc.services.AnnouncementService, java:global/KSC/AnnouncementService]
INFO: EJB5181:Portable JNDI names for EJB UserInRoleService: [java:global/KSC/UserInRoleService, java:global/KSC/UserInRoleService!com.ksc.services.UserInRoleService]
INFO: WELD-000900 1.1.8 (Final)
INFO: PWC1412: WebModule[null] ServletContext.log():No Spring WebApplicationInitializer types detected on classpath
INFO: PWC1412: WebModule[null] ServletContext.log():Initializing Spring root WebApplicationContext
SEVERE: log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
INFO: PWC1412: WebModule[null] ServletContext.log():Initializing Spring FrameworkServlet 'dispatcher'
INFO: WEB0671: Loading application [KSC] at [/KSC]
INFO: KSC was successfully deployed in 10,070 milliseconds.
ここで、Quartz に関する新しいエラー (私の元の質問に関連する場合と関連しない場合があります) があります。エラーはJDBC関連のようです。sqljdbc4 ドライバーを使用しています: http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774