Our scheduled jobs started failing since yesterday with the following error message:
CustomUpdate.Execute - System.NullReferenceException: Object reference
not set to an instance of an object. at
System.Web.Security.Roles.GetRolesForUser(String username) at
EPiServer.Security.PrincipalInfo.CreatePrincipal(String username)
The scheduled job uses anonymous execution and logs in programmatically using the following call:
if (PrincipalInfo.CurrentPrincipal.Identity.Name == string.Empty)
{
PrincipalInfo.CurrentPrincipal = PrincipalInfo.CreatePrincipal(ApplicationSettings.ScheduledJobUsername);
}
I have put in some more logging around PrincipalInfo.CreatePrincipal call which is in Episerver.Security and noticed that PrincipalInfo.CreatePrincipal calls System.Web.Security.Roles.GetRolesForUser(username) and Roles.GetRolesForUser(username) returns an empty string array.
There were no changes code wise or on the server (updates, etc).
I checked that the user name used to run the task is in the database and has roles associated with it.
I checked that applicationname is set up correctly and is associated with the user
If i run the job manually using the same user it executes with no issues (i know there is a difference between running the job manually and using the scheduler)
I also tried creating a new user, that didn’t work either.
Has anyone come across the same or similar issue? Any thoughts how to resolve this issue?
I have finally found a problem - application pool running with more than one worker processes (in my instance I had two worker processes). Once I set worker processes limit to one everything started to work again.
Related
I have added some custom steps to some of my SSRS jobs however they are being removed after a couple of days every time. I know that if you add custom jobs and then change the report or the subscription in the UI then it overwrites the jobs. However they are not being touched yet they are still disappearing.
Has anyone else come across this problem ?
Although I often customize jobs that run subscriptions - no, I haven't come across that problem. I did not customize the jobs that were created automatically, instead I created my own ones.
For a subscription to successfully fire, the name of the job isn't important. Instead, the SQL code to execute the subscription (to be more specific: the SubscriptionID) is what you need to know. Since you were able to find the jobs that execute specific subscriptions, I think that you don't have a problem in finding this information, neither. The code you need looks like this:
exec [ReportServer].dbo.AddEvent #EventType='TimedSubscription', #EventData='<YourSubscriptionID>'
You can use this code in your own jobs as well, and it will work as long as the subscription is there.
The name of the SSRS-generated job is the ID of the report schedule that you define for the subscription. This name is needed by SSRS to know where to change the schedule when you change the schedule of the subscription. As you found out, SSRS resets these jobs not only when a subscription is changed. But you don't need all these jobs when creating your own jobs that run the subscription.
To get rid of the auto-generated job with that cryptic name, don't just delete it yourself (as SSRS would re-create it), instead change the schedule of the subscription to a shared schedule that will never run. For this, I created a shared schedule (under site settings) named "Disabled Schedule" and disabled that schedule.
I'm wondering is there a way to recognize the OfflineComamd is being executed or internal flag or something to represent this command has been passed or mark it has been executed successfully. I have issue in recognizing the command is passed or not with unstable internet. I keep retrieve the records from database and comparing each and every time to see this has been passed or not. But due to the flow of my application, I'm finding it very difficult to avoid duplicates.IS there any automatic process to make sure commands executed automatically or something else?
2nd question, I can use UITimer to check isOffline() to make sure internet is connected or not on the forms. Is there something equivalent on server page or where queries is written to see internet is disconnected or not. When the control moved to queries and internet is disconnected I see the dialog open from form page being frozen for unlimited time and will not end. I have to close and re-open the app to continue the synchronization process.At the same time I cannot set a timeout for dialog because I'm not sure how long it will take the complete the Synchronization process. Please advise.
Extending on the same topic but I have created a new issue just to give more clarity on my questions.
executeOfflineCommand skips a command while executing from storage on Android
There is no way to know if a connection will stay stable as it requires knowledge of the future. You can work like transaction services do where the server side processes an offline command as a transaction using the approach of 2-phase commit.
In this approach you have an algorithm similar to this:
Client sends command to server
Server returns a special unique ID for the command
Client asks server to perform the unique id
Server acknowledges that the command was performed
If the first 2 stages didn't complete you just do that again. The worst thing that could happen is some orphan commands on the server.
If the 3rd option didn't complete you just do it again. The server knows whether it processed the command and will just acknowledge it if it was already processed.
I succesfully connected jbpm to my database (PostgreSQL) and i store logs into it. I made it by:
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession("WorkflowSession");
EntityManagerFactory emf = new EnvironmentProducer().getEntityManagerFactory();
AbstractAuditLogger auditLogger = AuditLoggerFactory.newJPAInstance(emf);
kSession.addEventListener(auditLogger);
I would like to restore all active processes after server falling. For example:
Start scenario (start process)
Server fall down (the process is in database register as active)
After turn on server again have this process loaded to my new KieSession
Please help me with this problem.
Thanks
There's no need to reload process instances after server shutdown. Process instances are always stored in the database, and whenever they are needed, they are loaded from there. This includes user requests related to the process instance (e.g. tasks completed, signals sent), but also timers firing etc.
The only thing you should try to do upon initialization of the application in case you embed the engine yourself is to make sure the runtime manager is instantiated (for keeping track of timers). If you use the execution server (part of the jbpm-console), it will automatically do that for you.
I have several HTTP callouts that are in a schedulable and set to run ever hour or so. After I deployed the app on the app exchange and had a salesforce user download it to test, it seems the jobs are not executing.
I can see the jobs are being scheduled to run accordingly however the database never seems to change. Is there any reason this could be happening or is there a good chance the flaw lies in my code?
I was thinking that it could be permissions however I am not sure (its the first app I am deploying).
Check if the organisation of your end user has added your endpoint to "remote site settings" in the setup. By endpoint I mean an address that's being called (or just the domain).
If the class is scheduled properly (which I believe would be a manual action, not just something that magically happens after installation... unless you've used a post-install script?) you could also examine Setup -> Apex Jobs and check if there are any errors. If I'm right, there will be an error about callout not allowed due to remote site settings. If not - there's still a chance you'll see something that will make you think. For example batch job has executed successfully but there were 0 iterations -> problem?
Last but not least - you can always try the debug logs :) Enable them in Setup (or open the developer console), fire the scheduled class's execute() manually and observe the results? How to fire it manually? Sth like this pasted to "execute anonymous":
MySchedulableClass sched = new MySchedubulableClass();
sched.execute(null);
Or - since you know what's inside the scheduled class - simply experiment.
Please note that if the updates you might be performing somehow violate for example validation rules your client has - yes, the database will be unchanged. But in such case you should still be able to see failures in Setup -> Apex Jobs.
We are building an application which makes every week a very large amount of request over the database, concurrently.
We have ~15-20 threads which query the database concurrently.
We are actually encountering a lot of problems:
On the database side(not enough RAM): being resolved.
But on the client too. We have Exception when trying to get a connection or execute commands. Those commande are mades through entity framework.
The application has two part: one website and one console application.
So can anyone tell me how to increase the following values?
Connection Timeout
Command Timeout
Connection pool size
I think that there several things that have to be done on the server side(SQL Server or IIS), but I can't find where?
Command timeout can be set on ObjectContext instance. Connect timeout and connection pool size is configured in connection string but if you have only 15-20 threads your problem will most probably be somewhere else because default connection pool size is 100.
Enclose your objectContext in a using block so the context disposes after you have done your work.
you can make a method to pass in thread which uses your entity context to do the work you want and then dispose the connection after the work is finished, you can use the stateinfo object variable to pass in different parameters to use during the life of your method.
void DoContextWork(object stateInfo)
{
// wrap your context in a using clause
using(var objectContext = new YourEntity()
{
// Do work here
}
}
you can have multiple threads call this method and each time your connection gets called you can do your work on your DB without getting the issues you mentioned above.