Quartz.NET integration in Castle Windsor

966 views
Skip to first unread message

Edwin Vliet

unread,
May 14, 2014, 3:13:15 AM5/14/14
to castle-pro...@googlegroups.com

I'm trying to integrate Quartz in Castle Windsor. I'm using Quartz 2.2.3. and Windsor.QuartzIntegration 0.3.1.
Windsor is version 3.2.1.
But I'm getting the following error.

    An exception of type 'Quartz.SchedulerException' occurred in Quartz.dll but was not handled in user code
    Additional information: SchedulerPlugin of type '' could not be instantiated.
   
    InnerException:
    Cannot instantiate null
    Parameter name: type

I have already tried for over a day to solve this issue, but I don't have a clue how to fix this anymore. Does anyone have a solution for this problem?

Quartz config

    <quartz>
      <add key="quartz.scheduler.instanceName">XmlConfiguredInstance</add>
      <add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
      <add key="quartz.threadPool.threadCount">5</add>
      <add key="quartz.threadPool.threadPriority">2</add>
      <add key="quartz.jobStore.misfireThreshold">60000</add>
      <add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz" />
      <add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz" />
      <add key="quartz.plugin.xml.fileNames" value="~/quartz_jobs.xml" />
      <add key="quartz.plugin.xml.ScanInterval">10</add>
    </quartz>

Jonathon Rossi

unread,
May 14, 2014, 3:24:03 AM5/14/14
to Castle Project Users
Do you have a full stack trace of where that exception is being thrown?

I thought the Quartz.NET Windsor facility required those configuration items to be set under the facility element in your configuration file. i.e. like the docs: http://docs.castleproject.org/Contrib.Quartz-Net-integration.ashx

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-u...@googlegroups.com.
To post to this group, send email to castle-pro...@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.



--
Jono
Message has been deleted

Jonathon Rossi

unread,
May 14, 2014, 4:18:02 AM5/14/14
to Castle Project Users
I'm pretty sure it is because some of those items you've got in your configuration have a empty XML element value, the facility uses the XML element's value not a "value" attribute. If you look at the example configuration on the page I linked to in my previous reply you'll see the items it defines as an example.


On Wed, May 14, 2014 at 6:04 PM, Edwin Vliet <edwinvan...@gmail.com> wrote:
Stacktrace:  

at Quartz.Impl.StdSchedulerFactory.Instantiate() in c:\Work\OpenSource\Quartz.NET\quartznet\src\Quartz\Impl\StdSchedulerFactory.cs:line 748
   at Quartz.Impl.StdSchedulerFactory.GetScheduler() in c:\Work\OpenSource\Quartz.NET\quartznet\src\Quartz\Impl\StdSchedulerFactory.cs:line 1118
   at Castle.Facilities.QuartzIntegration.QuartzNetScheduler..ctor(IDictionary`2 props, IJobFactory jobFactory, IKernel kernel) in g:\prg\QuartzNetIntegration.gitsvn\QuartzNetIntegration\QuartzNetIntegration\QuartzNetScheduler.cs:line 38



This is the full configuration for Castle.

<castle>
<facilities>
<facility id="startable.facility" type="Castle.Facilities.Startable.StartableFacility, Castle.Windsor" />
<facility id="quartznet" type="Castle.Facilities.QuartzIntegration.QuartzFacility, Castle.Facilities.QuartzIntegration">
<schedulerListeners>
<listener>${schedulerListener}</listener>
</schedulerListeners>
<jobListeners>
<job name="defaultJob">
<listener>${jobListener}</listener>
</job>
</jobListeners>
<triggerListeners>
<trigger name="defaultTrigger">
<listener>${triggerListener}</listener>
</trigger>
</triggerListeners>
<quartz>
<add key="quartz.scheduler.instanceName" value="QuartzScheduler" />

<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz">
<add key="quartz.threadPool.threadCount">5</add>
<add key="quartz.threadPool.threadPriority">2</add>
<add key="quartz.jobStore.misfireThreshold">60000</add>
<add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz" />
<add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz" />
<add key="quartz.plugin.xml.fileNames" value="~/quartz_jobs.xml" />
<add key="quartz.plugin.xml.ScanInterval">10</add>
</quartz>
</facility>
</facilities>
<components>
<component id="jobListener" type="HelpLine.Application.WebAPI.Quartz.SampleJobListener, HelpLine.Application.WebAPI" />
<component id="triggerListener" type="HelpLine.Application.WebAPI.Quartz.SampleTriggerListener, HelpLine.Application.WebAPI" />
<component id="schedulerListener" type="HelpLine.Application.WebAPI.Quartz.SampleSchedulerListener, HelpLine.Application.WebAPI" />
</components>
</castle>




Op woensdag 14 mei 2014 09:24:03 UTC+2 schreef Jonathon Rossi:
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-users+unsub...@googlegroups.com.
To post to this group, send email to castle-pro...@googlegroups.com.



--
Jono

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-u...@googlegroups.com.
To post to this group, send email to castle-pro...@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.



--
Jono

Edwin Vliet

unread,
May 14, 2014, 4:53:59 AM5/14/14
to castle-pro...@googlegroups.com
That did the job. Thank you very much for the help!
Now I see a FileScanJob every 10 seconds as specified.

Still need to configure my own job correctly. Getting type errors, but I guess I will manage that myself :)


Op woensdag 14 mei 2014 10:18:02 UTC+2 schreef Jonathon Rossi:
...

Edwin Vliet

unread,
May 14, 2014, 6:28:24 AM5/14/14
to castle-pro...@googlegroups.com
I thought it wouldn't be much trouble configuring the job correctly.

But it simply does not execute.
In my output I see the following lines which concern me:

A first chance exception of type 'Castle.MicroKernel.ComponentNotFoundException' occurred in Castle.Windsor.dll

A first chance exception of type 'Quartz.SchedulerException' occurred in Quartz.dll

But I can't figure out what component is not found...
I got my JobType in my quartz_jobs.xml by using the GetType() function.

<?xml version="1.0" encoding="utf-8" ?>
<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"version="2.0">

<processing-directives>
<overwrite-existing-data>true</overwrite-existing-data>
</processing-directives>
<schedule>
<job>





<name>defaultJob</name>
<description>test job</description>
<job-type>HelpLine.Application.WebAPI.Quartz.SampleJob, HelpLine.Application.WebAPI</job-type>
<durable>true</durable>
<recover>true</recover>
</job>
<trigger>
<cron>
<name>defaultTrigger</name>
<job-name>defaultJob</job-name>
<cron-expression>0 0/1 * * * ?</cron-expression>
</cron>
</trigger>
</schedule>
</job-scheduling-data>



Op woensdag 14 mei 2014 10:18:02 UTC+2 schreef Jonathon Rossi:
I'm pretty sure it is because some of those items you've got in your configuration have a empty XML element value, the facility uses the XML element's value not a "value" attribute. If you look at the example configuration on the page I linked to in my previous reply you'll see the items it defines as an example.
...

Jonathon Rossi

unread,
May 14, 2014, 6:36:19 AM5/14/14
to Castle Project Users
I assume you have registered the SampleJob in your Windsor container. If so, it might be a transitive component injected via the constructor that it cannot find.

Can you try turning on catch all CLR exceptions in VS and run it again so you can get the message text from the ComponentNotFoundException.

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-u...@googlegroups.com.
To post to this group, send email to castle-pro...@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.



--
Jono

Edwin Vliet

unread,
May 14, 2014, 7:35:00 AM5/14/14
to castle-pro...@googlegroups.com
Stacktrace for the ComponentNotFoundException. What I assume is that Quartz can't find the SampleJob.


   at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)
   at Castle.MicroKernel.DefaultKernel.Resolve(Type service)
   at Castle.Facilities.QuartzIntegration.WindsorJobFactory.NewJob(TriggerFiredBundle bundle, IScheduler scheduler) in g:\prg\QuartzNetIntegration.gitsvn\QuartzNetIntegration\QuartzNetIntegration\WindsorJobFactory.cs:line 51


In my eyes the job-type is correct. First the FullName and then the Assembly:

<job-type>HelpLine.Application.WebAPI.Quartz.SampleJob, HelpLine.Application.WebAPI</job-type>


I get the exception at the first component I want to register in my container.
Even when I put :

container.Register(Component.For<IJob>().ImplementedBy<SampleJob>().LifestyleTransient());


When I initialize the Windsor container I use the XmlInterpreter. Then when it is initialized, the container contains the following items:
-QuartzNetScheduler
-QuartzNetSimpleScheduler
-WindsorJobFactory
-SampleJobListener
-SampleTriggerListener
-SampleSchedulerListener
-FileScanJob

But when I try to register something to the container, it throws this exception. So it never get's to the point where I am able to register the SampleJob.



Op woensdag 14 mei 2014 12:36:19 UTC+2 schreef Jonathon Rossi:
<add key="quartz.threadPool.threadCount">5<font co
...

Edwin Vliet

unread,
May 14, 2014, 7:38:58 AM5/14/14
to castle-pro...@googlegroups.com
One small change: it registers the SampleJob now, but still get the exception after a while. And SampleJob will not be executed.

Op woensdag 14 mei 2014 13:35:00 UTC+2 schreef Edwin Vliet:

</<font color="#a31515" face="C

...

Jonathon Rossi

unread,
May 14, 2014, 7:51:10 AM5/14/14
to Castle Project Users
If you want to use the job-type element you need to register SampleJob as the service rather than IJob. Otherwise you can use named components and register it with IJob as the service.

... or did you mean you got that bit working and get a different exception?

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-u...@googlegroups.com.
To post to this group, send email to castle-pro...@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.



--
Jono

Edwin Vliet

unread,
May 14, 2014, 8:18:46 AM5/14/14
to castle-pro...@googlegroups.com

container.Register(Component.For<SampleJob>().ImplementedBy<SampleJob>());

That's working now :) Job got executed.
I'm pretty new to Windsor (and Dependency Injection) so this really gave me a headache...

Thanks for the great help. :)

Op woensdag 14 mei 2014 13:51:10 UTC+2 schreef Jonathon Rossi:

Jonathon Rossi

unread,
May 14, 2014, 10:11:15 AM5/14/14
to Castle Project Users
For a very basic view of services vs components, you can think of the service as the key and the component as the value in a dictionary. You usually ask Windsor to resolve by service and so that is why you needed to register the service as SampleJob because that is what you put in the config which it'll ask Windsor for. You can also use the Quartz facility with IJob as the service if you assign names to components (they automatically get a name too), but you need to enable that on the facility.

I highly recommend the Windsor documentation as a good intro to understand the concepts and how to use the API as there is quite a bit in there if you just try and follow it via IntelliSense.
http://docs.castleproject.org/Windsor.MainPage.ashx

By the way you can also shorten that registration to just:
container.Register(Component.For<SampleJob>());

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-u...@googlegroups.com.
To post to this group, send email to castle-pro...@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.



--
Jono
Reply all
Reply to author
Forward
0 new messages