1

I have written a custom timer job, created a feature, and written a feature receiver to install and uninstall the Timer Job in the web app on Activate/Deactivate. The custom job roughly follows the examples af Andrew Connell here.

The Feature is Site-scoped, and not visible. I am doing all of the feature install/uninstall and activate/deactivate via STSADM.exe.

Deployment is fine, and the feature installs, activates, deactivates, and uninstalls smoothly. The Feature event receiver is working correctly: the custom job definition appears and dissappears from the Central Administration -> Operations -> Timer Job Definitions interface when the feature activates and deactivates.

However, when the job itself is executed by the timer process, I get errors in the ULS logs and the System Event log. From the ULS Logs:

10/12/2010 13:10:00.14  OWSTIMER.EXE (0x1CE8)                       0x2DDC  Windows SharePoint Services     Timer                           7psa    Critical    The Execute method of job definition Example.TimerJobs.RequiredTaskMonitorJob (ID 94f5f3ce-ed38-4e27-b15d-1b00a6a143c1) threw an exception. More information is included below.  Value does not fall within the expected range.  
10/12/2010 13:10:00.14  OWSTIMER.EXE (0x1CE8)                       0x2DDC  Windows SharePoint Services     Timer                           72ae    Unexpected  Exception stack trace:    at Microsoft.SharePoint.SPListCollection.GetListByName(String strListName, Boolean bThrowException)     at Microsoft.SharePoint.SPListCollection.get_Item(String strListName)     at Example.TimerJobs.RequiredTaskMonitorJob.Execute(Guid contentDbId)     at Microsoft.SharePoint.Administration.SPTimerJobInvoke.Invoke(TimerJobExecuteData& data, Int32& result)  

Note that this error occurs no matter what the content of the Execute() method is. Originally I was reading in the details of a SPList used for configuration, and creating Task List items when certain conditions were found to be true.

But in the currently-installed version of the Timer Job, the Execute() method is entirely empty. I don't even call the base class's implementation of it. I have no idea where it is trying to call the SPListCollection.get_Item() method; it's certainly not in my code.

Is anyone able to assist with this error?

Thanks for your help,

Darryl.

1
  • I should note that this is on a WSS 3.0 installation.
    – user1170
    Commented Oct 12, 2010 at 18:46

4 Answers 4

2

In WSS i made a habit of testing my timer jobs in a test harnes, most often a console application, before deploying the timer job to SharePoint.

This is because it is tedious waiting for jobs to start (this is better in SP2010 where you have RunNow).

To test this code either call your method from a console application, or debug the timer job by setting a breakpoint in your Execute code and attaching OWSTIMER.EXE in Visual Studio.

Read more on debugging timer jobs in an earlier discussion here

2
  • I like to create Cmdlets to invoke my timer jobs
    – Steve P
    Commented Oct 13, 2010 at 17:51
  • Thanks Anders. Works great in a console app. So great that I am considering just running it with Windows Task Scheduler. Who needs the heartache of the Timer Job framework? Well, I'm sure lots of people do, but my code payload is local to a single SPWeb on a standalone server, not in a farm or anything, so I don't care about Scope of LockType which TimerJobs help with....
    – user1170
    Commented Oct 13, 2010 at 21:55
1

The Timer Job is trying to find a list - does this work in a brand new web application with an out of the box site collection with no other custom code?

1
  • Thanks James. Yes, deploying to a fresh location caused the error to go away. The code is working in a console app (thanks Anders), and in new deployments of it. But not in the original location. I have deactivated, uninstalled the feature, done an IIS reset and restarted the OWSTIMER service. I think that old code is cached somewhere and causing problems.
    – user1170
    Commented Oct 13, 2010 at 21:52
0

You state that your latest version of your code has an empty execute method yet the log file indicates

Example.TimerJobs.RequiredTaskMonitorJob.Execute

Is calling get_Item this suggests that the latest version of your code is not running.

Have you tried restarting the timer service to flush out your old code?

1
  • Hi Steve, I did deactivate the feature, uninstall the feature, uninstall my dlls from the GAC, did an IISRESET, and restarted the timer service. Then I reinstalled my new dlls (with the empty Execute() method), installed the feature, and reactivated the feature. After that I still got the ArgumentException out of SPListCollection.get_item(). Short of rebooting the physical machine, I don't know what else I can do?
    – user1170
    Commented Oct 18, 2010 at 15:26
0

Have you changed the AssemblyVersion numbers of your assembly?

This might explain why some old code is hanging around.

You should be able to check the GAC to see how many versions of your Assembly are hanging around.

You can see exactly where your TimeJob was loaded from by attaching the debugger to the OWSTIMER.EXE and switching to the Debug/Modules windows it will list exactly what assemblies are loaded and what path they were loaded from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.