Problems Running Sharepoint Custom Timer Jobs
-
Hello everybody, I have created a Custom Timer Job by extending SPJobDefinition class. The code is given below: public class TaskLoggerJob : SPJobDefinition{ /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> public TaskLoggerJob () : base(){ } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="service">The service.</param> /// <param name="server">The server.</param> /// <param name="targetType">Type of the target.</param> public TaskLoggerJob (string jobName, SPService service, SPServer server, SPJobLockType targetType) : base (jobName, service, server, targetType) { } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="webApplication">The web application.</param> public TaskLoggerJob (string jobName, SPWebApplication webApplication) : base (jobName, webApplication, null, SPJobLockType.ContentDatabase) { this.Title = "Task Logger"; } public override void Execute(Guid targetInstanceId) { foreach (SPSite siteCollection in this.WebApplication.Sites) { WarmUpSiteCollection(siteCollection); siteCollection.RootWeb.Dispose(); siteCollection.Dispose(); } } private void WarmUpSiteCollection(SPSite siteCollection) { WebRequest request = WebRequest.Create(siteCollection.Url); request.Credentials = CredentialCache.DefaultCredentials; request.Method = "GET"; WebResponse response = request.GetResponse(); response.Close(); } } I have successfull deployed and activated the web solution package file. The job is also there in the Timer Job Defeinition list. It runs in one minute and everytime it runs it throws the following error in event log: The Execute method of job definition MOSSTaskLoggerJob.TaskLoggerJob (ID 342cb188-8b01-4c53-b709-5750ac5a7062) threw an exception. More information is included below. Value does not fall within the expected range. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. I checked the details in the sharepoi
-
Hello everybody, I have created a Custom Timer Job by extending SPJobDefinition class. The code is given below: public class TaskLoggerJob : SPJobDefinition{ /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> public TaskLoggerJob () : base(){ } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="service">The service.</param> /// <param name="server">The server.</param> /// <param name="targetType">Type of the target.</param> public TaskLoggerJob (string jobName, SPService service, SPServer server, SPJobLockType targetType) : base (jobName, service, server, targetType) { } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="webApplication">The web application.</param> public TaskLoggerJob (string jobName, SPWebApplication webApplication) : base (jobName, webApplication, null, SPJobLockType.ContentDatabase) { this.Title = "Task Logger"; } public override void Execute(Guid targetInstanceId) { foreach (SPSite siteCollection in this.WebApplication.Sites) { WarmUpSiteCollection(siteCollection); siteCollection.RootWeb.Dispose(); siteCollection.Dispose(); } } private void WarmUpSiteCollection(SPSite siteCollection) { WebRequest request = WebRequest.Create(siteCollection.Url); request.Credentials = CredentialCache.DefaultCredentials; request.Method = "GET"; WebResponse response = request.GetResponse(); response.Close(); } } I have successfull deployed and activated the web solution package file. The job is also there in the Timer Job Defeinition list. It runs in one minute and everytime it runs it throws the following error in event log: The Execute method of job definition MOSSTaskLoggerJob.TaskLoggerJob (ID 342cb188-8b01-4c53-b709-5750ac5a7062) threw an exception. More information is included below. Value does not fall within the expected range. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. I checked the details in the sharepoi
Hello everybody, Problem solved :-O. I deployed the solution(wsp) in the central administration site. I also activated the feature in the centreal administration site which caused the problem. In the execute method, it was repeatedly showing ArgumentNullException. So, I just deactivated the feature from the central administration site and activated it in one of the sharepoint site. The timer job started and didn't throw any error int the Sharepoint Timer Job Status and in the Windows Event Viewer's error log. I really did a silly mistake which caused me to be puzzled over few extra hours. Well, I was also able to debug the Timer Job class by doing the following things: (i) Deploying the pdb file to GAC. (ii) Attaching the class file with the two processes simultaneously: w3wp.exe and owstimer.exe. I am happy and relaxed now. If anyone of you had faced this problem, steps and descriptions mentioned above may help. :-\ Regards Saanj
Either you love IT or leave IT...
-
Hello everybody, I have created a Custom Timer Job by extending SPJobDefinition class. The code is given below: public class TaskLoggerJob : SPJobDefinition{ /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> public TaskLoggerJob () : base(){ } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="service">The service.</param> /// <param name="server">The server.</param> /// <param name="targetType">Type of the target.</param> public TaskLoggerJob (string jobName, SPService service, SPServer server, SPJobLockType targetType) : base (jobName, service, server, targetType) { } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="webApplication">The web application.</param> public TaskLoggerJob (string jobName, SPWebApplication webApplication) : base (jobName, webApplication, null, SPJobLockType.ContentDatabase) { this.Title = "Task Logger"; } public override void Execute(Guid targetInstanceId) { foreach (SPSite siteCollection in this.WebApplication.Sites) { WarmUpSiteCollection(siteCollection); siteCollection.RootWeb.Dispose(); siteCollection.Dispose(); } } private void WarmUpSiteCollection(SPSite siteCollection) { WebRequest request = WebRequest.Create(siteCollection.Url); request.Credentials = CredentialCache.DefaultCredentials; request.Method = "GET"; WebResponse response = request.GetResponse(); response.Close(); } } I have successfull deployed and activated the web solution package file. The job is also there in the Timer Job Defeinition list. It runs in one minute and everytime it runs it throws the following error in event log: The Execute method of job definition MOSSTaskLoggerJob.TaskLoggerJob (ID 342cb188-8b01-4c53-b709-5750ac5a7062) threw an exception. More information is included below. Value does not fall within the expected range. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. I checked the details in the sharepoi
When we want to run a task (like sending emails or deleting the list items etc. . . ) in Daily basis or in Hourly basis then we can use a Timer job to this task .To see the timer job you can move to the Central Administrations then click on the operations tab, then in the Global Configuration section you can see the Timer job status and timer job definition. In timer job definition you can get the details of the timer job i.e. the title , the web application to which it is attached and the schedule type i.e. Daily, Weekly or hourly basis. To get the status of the timer job go to the timer job status, here you can view status. Steps To create a custom timer job: 1. We need to create a class that inherits the SPJobDefinition Class. Then we need add the constructor s and the Execute () method. namespace TestTimerJob { public class CustomTimerJob : SPJobDefinition{ public CustomTimerJob (): base(){ } Hope you find this tips useful and of assistance. http://www.mindfiresolutions.com/How-to-create-a-Custom-Timer-job-in-SharePoint-957.php[^] Thanks, Bijayani
-
When we want to run a task (like sending emails or deleting the list items etc. . . ) in Daily basis or in Hourly basis then we can use a Timer job to this task .To see the timer job you can move to the Central Administrations then click on the operations tab, then in the Global Configuration section you can see the Timer job status and timer job definition. In timer job definition you can get the details of the timer job i.e. the title , the web application to which it is attached and the schedule type i.e. Daily, Weekly or hourly basis. To get the status of the timer job go to the timer job status, here you can view status. Steps To create a custom timer job: 1. We need to create a class that inherits the SPJobDefinition Class. Then we need add the constructor s and the Execute () method. namespace TestTimerJob { public class CustomTimerJob : SPJobDefinition{ public CustomTimerJob (): base(){ } Hope you find this tips useful and of assistance. http://www.mindfiresolutions.com/How-to-create-a-Custom-Timer-job-in-SharePoint-957.php[^] Thanks, Bijayani
-
Hello everybody, I have created a Custom Timer Job by extending SPJobDefinition class. The code is given below: public class TaskLoggerJob : SPJobDefinition{ /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> public TaskLoggerJob () : base(){ } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="service">The service.</param> /// <param name="server">The server.</param> /// <param name="targetType">Type of the target.</param> public TaskLoggerJob (string jobName, SPService service, SPServer server, SPJobLockType targetType) : base (jobName, service, server, targetType) { } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="webApplication">The web application.</param> public TaskLoggerJob (string jobName, SPWebApplication webApplication) : base (jobName, webApplication, null, SPJobLockType.ContentDatabase) { this.Title = "Task Logger"; } public override void Execute(Guid targetInstanceId) { foreach (SPSite siteCollection in this.WebApplication.Sites) { WarmUpSiteCollection(siteCollection); siteCollection.RootWeb.Dispose(); siteCollection.Dispose(); } } private void WarmUpSiteCollection(SPSite siteCollection) { WebRequest request = WebRequest.Create(siteCollection.Url); request.Credentials = CredentialCache.DefaultCredentials; request.Method = "GET"; WebResponse response = request.GetResponse(); response.Close(); } } I have successfull deployed and activated the web solution package file. The job is also there in the Timer Job Defeinition list. It runs in one minute and everytime it runs it throws the following error in event log: The Execute method of job definition MOSSTaskLoggerJob.TaskLoggerJob (ID 342cb188-8b01-4c53-b709-5750ac5a7062) threw an exception. More information is included below. Value does not fall within the expected range. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. I checked the details in the sharepoi
When we want to run a task (like sending emails or deleting the list items etc. . . ) in Daily basis or in Hourly basis then we can use a Timer job to this task .To see the timer job you can move to the Central Administrations then click on the operations tab, then in the Global Configuration section you can see the Timer job status and timer job definition. In timer job definition you can get the details of the timer job i.e. the title , the web application to which it is attached and the schedule type i.e. Daily, Weekly or hourly basis. To get the status of the timer job go to the timer job status, here you can view status. http://www.mindfiresolutions.com/How-to-create-a-Custom-Timer-job-in-SharePoint-957.php[^]
Cheers, Eliza