0
votes

I created "Timer Job" in two ways,

1.Created a SharePoint Project through the Visual Studio 2010 and added several Features and webparts that's successfully deployed later i added the "Timer job" through the feature with the scope "Site" the timerjob not available in "Job Definitions".

2.When created a project with timer job feature only it's available in "Job Definitions".

I need to deploy the timer job along with other features as mention in first scenario

Regards, Pavan.

3

3 Answers

0
votes

You should deploy timer jobs in features scoped "Web Application". Please post the code you register your job with if this does not resolve your issue.

0
votes

I've successfully deployed timer jobs to features scoped as tightly as 'Web' with no issues.

Doing it this way made it easier for me get the job settings to associate with specific list instances and I don't have to hard code any site collection URLs or whatever into the job code.

You still have to make sure you get it registered with the Web Application, and here's how I designed my feature activation for my web-scoped feature:

Public Overrides Sub FeatureActivated(ByVal properties As SPFeatureReceiverProperties)

    Dim web As SPWeb = DirectCast(properties.Feature.Parent, SPWeb)


    ' Remove job if it exists.
    DeleteJobAndSettings(web.Site.WebApplication)

    ' Create the job.
    Dim job As New TimerJob_myClass(TimerJob_myClass.JobName, web.Site.WebApplication)

Also, even though it's a Web feature and shows up under 'Manage Features', it's better to mark it hidden. This type of feature can only be activated by running an stsadm command line from PowerShell. For example:

stsadm -o activatefeature -url http://intranet.contoso.local/ -id 01234567-AAAA-BBBB-CCCC-DDDDEEEEFFFF

You should run PowerShell as a user who has rights on the content database associated with the site your working with. The app pool that would have normally run the feature receiver code during a GUI activation does not have access to the config database and that's why it fails via GUI.

0
votes

my problem solved in production by activating feature with the following powershell

Enable-SPFeature -identity "sample_Job Definition" -URL http://portaluat

my job definition scope was Site