Windows Services, Timers & Threading
I have a self hosted WCF service. I have 2 methods that need to run periodically so the Host Service has 2 System.Threading.Timers.
Timer1 has a long running process. May take up to a minute to run.
Timer2 has a method that is quick but MUST run every 10 seconds.
My first thought was that each timer would run on a separate thread and I should be able to get this right out of the box. I was incorrect. I can't get Timer2 to be consistent because there seems to be a dependency between the two timers
and/or the server load. Timer2 doesn't give me a clean execution pattern.
In trying to fix this, I put a System.Threading.Tasks.Task around the method call on Timer1. I expected this to release resources so that Timer2 can run cleanly. Still, no luck.
This has me stumped. Any idea why Timer2 doesn't fire on a consistent pattern?
Thanks for your help, Joel.
Application Developer Manufacturing
Timer2 has a method that is quick but MUST run every 10 seconds.
Timer2 doesn't give me a clean execution pattern.
Hi Joel. What doe you mean by clean execution pattern? Is the timer taking longer than 10 seconds to execute the callback or is it random when the call back happens based on server load?
What I can tell you is that any thread execution is always dependent on the O/S. If the O/S is busy with a process dubbed as high priority which takes up all the resources then your application would also suffer as would any other application running on
that server. This could be seen in the form of threads not being allocated to run your application, timers not being fired, longer wait times than usual for resource requests etc.
As stated above if thread 1 is doing some heavy lifting and using up more CPU cycles/resources on the O/S is willing to allocate to your process then thread 1 (example of processing started on timer1) could affect thread 2 (example of processing
started on timer 2).
As far as timers go the timer is System.Threading namespace will always execute independent of each other unless you have added syncronization logic or thread 1 (example of processing started on timer1) blocks on a resource thread 2 (example
of processing started on timer 2) is requesting.
Let me know if I am way off on what I think you are asking here.
Mark as answer or vote as helpful if you find it useful | Igor
Similar Messages
-
Window service Timers.Timer
Hi Guys Please help me.
Actully i create a window service. This window service has timer for update record once in a day at 5 pm.
I have write a code but it is not working fin
Here is my code.
App.Config File:-
<appSettings>
<add key="IsTrace" value="YES"/>
<add key="SourceServerPath" value="Server=DATASERVER\SQL2008R2;database=WDSBHN;User ID=Wireless;pwd=chetu@123"/>
<add key="ArchiveServerPath" value="Server=CHETUIWK091\SQL2008R2;database=Demo;User ID=sa;pwd=Chetu@123"/>
<add key="ReportHour" value="22"/>
<add key="ReportMinut" value="01"/>
<add key="ReportSecond" value="20"/>
<add key="ReportMilisecond" value="230"/>
<add key="DailyTimer" value="tmrProductionDataTransfer"/>
<add key="MonthlyTimer" value="tmrProductionCleanUp"/>
<add key="ActionParameter" value="WDS-DataTransfer"/>
</appSettings>
Vb.Net Code:-
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
Try
LoggingTracing.WriteTrace("DataTransfer Service START " & Now.ToLongDateString & " " & Now.ToLongTimeString())
'***Get the Time of service run
Dim svcRunTime As System.DateTime = Configuration.ConfigurationManager.AppSettings("ServiceRunTime")
'***differance of these two time
Dim ts As TimeSpan = DateTime.Now.Subtract(svcRunTime)
'***production data transfer
tmrProductionDataTransfer.Enabled = True
tmrProductionDataTransfer.Interval = 1000
tmrProductionDataTransfer.Start()
Catch ex As Exception
LoggingTracing.WriteError(ex.ToString())
End Try
End Sub
Private Sub tmrProductionDataTransfer_Elapsed(sender As Object, e As Timers.ElapsedEventArgs) Handles tmrProductionDataTransfer.Elapsed
Try
Dim time As Date = Date.Now
Dim currHour As Integer
Dim currMinute As Integer
Dim currnSecond As Integer
Dim reportHour As Integer
Dim reportMinute As Integer
Dim reportSecond As Integer
Dim reportMiliSecond As Integer
Dim actionParameter As String = Configuration.ConfigurationManager.AppSettings("ActionParameter")
Dim actionTimerName As String = Configuration.ConfigurationManager.AppSettings("DailyTimer")
currHour = time.Hour
currMinute = time.Minute
currnSecond = time.Second
reportHour = Convert.ToInt32(Configuration.ConfigurationManager.AppSettings("ReportHour"))
reportMinute = Convert.ToInt32(Configuration.ConfigurationManager.AppSettings("ReportMinut"))
reportSecond = Convert.ToInt32(Configuration.ConfigurationManager.AppSettings("ReportSecond"))
reportMiliSecond = Convert.ToInt32(Configuration.ConfigurationManager.AppSettings("ReportMilisecond"))
If currHour = reportHour AndAlso currMinute = reportMinute AndAlso currnSecond = reportSecond Then
ObjProductionDataTransfer.CopyDataToArchiveServerDayWiseDL(Configuration.ConfigurationManager.AppSettings("SourceServerPath"), Configuration.ConfigurationManager.AppSettings("ArchiveServerPath"),
actionTimerName, time, actionParameter)
End If
Catch ex As Exception
LoggingTracing.WriteError(ex.ToString())
End Try
End Sub
It is running at 5 pm , but run 3 times, for that records has updated 3 time
How i can resolve it, If any problem in this code please give me the write direction or code. And this thing i have been searching for 3 days , but stile i didn't get any solution
soneshSonesh,
Sorry but you have posted to a forum that deals exclusively with questions/issues about customizing and programming Microsoft Project, a planning and scheduling application. I suggest you delete this post and find a forum appropriate for your issue.
John -
How to get a Thread Dump from Windows Service?
We're running WLS 8.1 as a Windows Service, but we can't seem to generate a Thread Dump when the server locks up (apparently).
Can anybody recommend a wrapper that will do this?
--KurtHi,
Please refer to the following URL for more information http://e-docs.bea.com/wls/docs81/adminguide/winservice.html
To cause the WebLogic Server instance to print a thread dump to standard out, do either of the following:
Use the weblogic.Admin THREAD_DUMP command. For more information, refer to "THREAD_DUMP" in the WebLogic Server Command Reference.
Open a command prompt and enter the following command:
WL_HOME\bin\beasvc -dump -svcname:service-name
where WL_HOME is the directory in which you installed WebLogic Server and
service-name is the Windows service that is running a server instance.
For example:
D:\bea\weblogic81\server\bin\beasvc -dump -svcname:mydomain_myserver
Cheers
Raj -
Different thread/memory limits when running Java via Windows Service?
My company is developing a Java application that employs a "black-box" interface, which generates several memory-intensive threads. When we run the application via a batch file, the threads seem to run in parallel on a quad-core server. However, when we install the application as a Windows Service on the same server, it appears that we hit a hard limit of 35 threads, and the process pegs out one of the server's CPU's at 100%. Does anyone know why we don't see the parallelism when we run it as a Windows Service? Does anyone know if Windows imposes different memory or thread restrictions on services, as opposed to normal desktop applications?
My company is developing a Java application that employs a "black-box" interface, which generates several memory-intensive threads. When we run the application via a batch file, the threads seem to run in parallel on a quad-core server. However, when we install the application as a Windows Service on the same server, it appears that we hit a hard limit of 35 threads, and the process pegs out one of the server's CPU's at 100%. Does anyone know why we don't see the parallelism when we run it as a Windows Service? Does anyone know if Windows imposes different memory or thread restrictions on services, as opposed to normal desktop applications?
-
Windows service write to event log
Have strange conduct of code within my application. I've created windows service the same as according to MSDN default instruction:
https://msdn.microso...=vs.110%29.aspx
its working and logging to event log correctly. After that i copied that project and based on it i started to create second one almost similar one. my issue is within below part of code belongs to ProjectInstaller.vb when i installed it and tried to Start i
get message that Windows service started and stoped imedietly.
Imports System.ComponentModel
Imports System.Configuration.Install
Public Class ProjectInstaller
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
'Add initialization code after the call to InitializeComponent
End Sub
Protected Overrides Sub OnBeforeInstall(ByVal savedState As IDictionary)
Dim parameter As String = "MySvcDeon2"" ""MyLogFileSvcDeon2"
Context.Parameters("assemblypath") = """" + Context.Parameters("assemblypath") + """ """ + parameter + """"
MyBase.OnBeforeInstall(savedState)
End Sub
End Class
Within this line: Dim parameter As String = "MySvcDeon2"" ""MyLogFileSvcDeon2"
When i change it to this form then service its starting correctly without any error meassage:
Dim parameter As String = "MySvcDeon1"" ""MyLogFileSvcDeon1"
its working. But Deon2 is already created by my first windows service. Whats wrong?i also tried from official msdn site but same error, anyhow, see my code below:
ProjectInstaller.vb:
Imports System.ComponentModelImports System.Configuration.InstallPublic Class ProjectInstaller Public Sub New() MyBase.New() 'This call is required by the Component Designer. InitializeComponent() 'Add initialization code after the call to InitializeComponent End SubEnd Class
ProjectInstaller.Designer.vb
<System.ComponentModel.RunInstaller(True)> Partial Class ProjectInstaller Inherits System.Configuration.Install.Installer 'Installer overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub 'Required by the Component Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Component Designer 'It can be modified using the Component Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller() Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller() ' 'ServiceProcessInstaller1 ' Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem Me.ServiceProcessInstaller1.Password = Nothing Me.ServiceProcessInstaller1.Username = Nothing ' 'ServiceInstaller1 ' Me.ServiceInstaller1.Description = "Chorus windows service collector" Me.ServiceInstaller1.DisplayName = "SvcChorusCollector" Me.ServiceInstaller1.ServiceName = "SvcChorusCollector" Me.ServiceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic ' 'ProjectInstaller ' Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1}) End Sub Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstallerEnd Class
SvcChorusCollector.vb:
Public Class SvcChorusCollector
Private Const EvtLogSource As String = "MySourceSvcChorusCollector"
Private Const EvtLogName As String = "MyLogSvcChorusCollector"
Private syncRoot As New Object
Dim timer As System.Timers.Timer = New System.Timers.Timer()
Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
If Not System.Diagnostics.EventLog.SourceExists(EvtLogSource) Then
System.Diagnostics.EventLog.CreateEventSource(EvtLogSource, EvtLogName)
End If
EventLog1.Source = EvtLogSource
End Sub
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
EventLog1.WriteEntry("In OnStart")
' Set up a timer to trigger every minute.
timer.Interval = 1000 ' 1 seconds
'unfortunetly OnTimer event handler will be executed even already one is running if Interval is riched by default.
'This is because it will go multiple threading and not in main thread unless a SynchronizingObject is supplied. (Which it wasn't.) below :
'timer.SynchronizingObject = Me
'this is solving problem. OTher way is to make lock within OnTimer event handler as its done right now.
AddHandler timer.Elapsed, AddressOf Me.OnTimer
timer.Start()
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
EventLog1.WriteEntry("In OnStop")
End Sub
Protected Overrides Sub OnContinue()
EventLog1.WriteEntry("In OnContinue.")
End Sub
Private Sub OnTimer(ByVal sender As Object, ByVal e As Timers.ElapsedEventArgs)
End Sub
End Class
SvcChorusCollector.Designer.vb
Imports System.ServiceProcess<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _Partial Class SvcChorusCollector Inherits System.ServiceProcess.ServiceBase 'UserService overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub ' The main entry point for the process <MTAThread()> _ <System.Diagnostics.DebuggerNonUserCode()> _ Shared Sub Main() Dim ServicesToRun() As System.ServiceProcess.ServiceBase ' More than one NT Service may run within the same process. To add ' another service to this process, change the following line to ' create a second service object. For example, ' ' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService} ' ServicesToRun = New System.ServiceProcess.ServiceBase() {New SvcChorusCollector} System.ServiceProcess.ServiceBase.Run(ServicesToRun) End Sub 'Required by the Component Designer Private components As System.ComponentModel.IContainer ' NOTE: The following procedure is required by the Component Designer ' It can be modified using the Component Designer. ' Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.EventLog1 = New System.Diagnostics.EventLog() CType(Me.EventLog1, System.ComponentModel.ISupportInitialize).BeginInit() ' 'EventLog1 ' ' 'SvcChorusCollector ' Me.ServiceName = "SvcChorusCollector" Me.CanStop = True 'if this is not set to true then will be not possible to stop service manually from service window services.msc !!! Me.AutoLog = True CType(Me.EventLog1, System.ComponentModel.ISupportInitialize).EndInit() End Sub Friend WithEvents EventLog1 As System.Diagnostics.EventLogEnd Class
The second service is on same basis, of course service names, source,logname are diffrent. What i do wrong? Error message appearing really fast after ~8 sec -
Call a program via windows service
Hi! I have write a windows service,and it works. I want to call a .exe file,and my .exe file is signature. The program can not work when I call it through my service. How can I solve my problem? Thanks!
Hi Hassan,
Thank you for sharing the code with us!
As I understand it, your code handles the situation of an user that is already logged on to an interactive window station (those of you, who need to create a UI-process of a user not yet logged on, could use
CreateProcessWithLogon, or
LogonUser to get the token). Because calling CreateProcessAsUser() requires advanced privileges (such as "Replace a process token level", or "Act as part of the operating system", privileges usually not held by a user unless specified so by the security
policy), the code also implies a service running in the local system account (or equivalent).
To make it easier to read, I'll post here the C#-version of your code:
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace WindowsServiceLaunchingExe
class NativeMethods
[StructLayout(LayoutKind.Sequential)]
public struct PROCESS_INFORMATION {
public IntPtr hProcess;
public IntPtr hThread;
public System.UInt32 dwProcessId;
public System.UInt32 dwThreadId;
[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES {
public System.UInt32 nLength;
public IntPtr lpSecurityDescriptor;
public bool bInheritHandle;
[StructLayout(LayoutKind.Sequential)]
public struct STARTUPINFO {
public System.UInt32 cb;
public string lpReserved;
public string lpDesktop;
public string lpTitle;
public System.UInt32 dwX;
public System.UInt32 dwY;
public System.UInt32 dwXSize;
public System.UInt32 dwYSize;
public System.UInt32 dwXCountChars;
public System.UInt32 dwYCountChars;
public System.UInt32 dwFillAttribute;
public System.UInt32 dwFlags;
public short wShowWindow;
public short cbReserved2;
public IntPtr lpReserved2;
public IntPtr hStdInput;
public IntPtr hStdOutput;
public IntPtr hStdError;
[StructLayout(LayoutKind.Sequential)]
public struct PROFILEINFO {
public int dwSize;
public int dwFlags;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpUserName;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpProfilePath;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpDefaultPath;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpServerName;
[MarshalAs(UnmanagedType.LPTStr)]
public string lpPolicyPath;
public IntPtr hProfile;
internal enum SECURITY_IMPERSONATION_LEVEL {
SecurityAnonymous = 0,
SecurityIdentification = 1,
SecurityImpersonation = 2,
SecurityDelegation = 3
internal enum TOKEN_TYPE {
TokenPrimary = 1,
TokenImpersonation = 2
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool CreateProcessAsUser(IntPtr hToken, string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION lpProcessInformation);
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool DuplicateTokenEx(IntPtr hExistingToken, uint dwDesiredAccess, ref SECURITY_ATTRIBUTES lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, ref IntPtr phNewToken);
[DllImport("advapi32.dll", SetLastError = true)]
private static extern bool OpenProcessToken(IntPtr ProcessHandle, int DesiredAccess, ref IntPtr TokenHandle);
[DllImport("userenv.dll", SetLastError = true)]
private static extern bool CreateEnvironmentBlock(ref IntPtr lpEnvironment, IntPtr hToken, bool bInherit);
[DllImport("userenv.dll", SetLastError = true)]
private static extern bool DestroyEnvironmentBlock(IntPtr lpEnvironment);
private const short SW_SHOW = 1;
private const short SW_SHOWMAXIMIZED = 7;
private const int TOKEN_QUERY = 8;
private const int TOKEN_DUPLICATE = 2;
private const int TOKEN_ASSIGN_PRIMARY = 1;
private const int GENERIC_ALL_ACCESS = 268435456;
private const int STARTF_USESHOWWINDOW = 1;
private const int STARTF_FORCEONFEEDBACK = 64;
private const int CREATE_UNICODE_ENVIRONMENT = 0x00000400;
private const string gs_EXPLORER = "explorer";
public static void LaunchProcess(string Ps_CmdLine)
IntPtr li_Token = default(IntPtr);
IntPtr li_EnvBlock = default(IntPtr);
Process[] lObj_Processes = Process.GetProcessesByName(gs_EXPLORER);
// Get explorer.exe id
// If process not found
if (lObj_Processes.Length == 0)
// Exit routine
return;
// Get primary token for the user currently logged in
li_Token = GetPrimaryToken(lObj_Processes[0].Id);
// If token is nothing
if (li_Token.Equals(IntPtr.Zero))
// Exit routine
return;
// Get environment block
li_EnvBlock = GetEnvironmentBlock(li_Token);
// Launch the process using the environment block and primary token
LaunchProcessAsUser(Ps_CmdLine, li_Token, li_EnvBlock);
// If no valid enviroment block found
if (li_EnvBlock.Equals(IntPtr.Zero))
// Exit routine
return;
// Destroy environment block. Free environment variables created by the
// CreateEnvironmentBlock function.
DestroyEnvironmentBlock(li_EnvBlock);
private static IntPtr GetPrimaryToken(int Pi_ProcessId) {
IntPtr li_Token = IntPtr.Zero;
IntPtr li_PrimaryToken = IntPtr.Zero;
bool lb_ReturnValue = false;
Process lObj_Process = Process.GetProcessById(Pi_ProcessId);
SECURITY_ATTRIBUTES lObj_SecurityAttributes = default(SECURITY_ATTRIBUTES);
// Get process by id
// Open a handle to the access token associated with a process. The access token
// is a runtime object that represents a user account.
lb_ReturnValue = OpenProcessToken(lObj_Process.Handle, TOKEN_DUPLICATE, ref li_Token);
// If successfull in opening handle to token associated with process
if (lb_ReturnValue) {
// Create security attributes to pass to the DuplicateTokenEx function
lObj_SecurityAttributes = new SECURITY_ATTRIBUTES();
lObj_SecurityAttributes.nLength = Convert.ToUInt32(Marshal.SizeOf(lObj_SecurityAttributes));
// Create a new access token that duplicates an existing token. This function
// can create either a primary token or an impersonation token.
lb_ReturnValue = DuplicateTokenEx(li_Token, Convert.ToUInt32(TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_QUERY), ref lObj_SecurityAttributes, SECURITY_IMPERSONATION_LEVEL.SecurityIdentification, TOKEN_TYPE.TokenPrimary, ref li_PrimaryToken);
// If un-successful in duplication of the token
if (!lb_ReturnValue) {
// Throw exception
throw new Exception(string.Format("DuplicateTokenEx Error: {0}", Marshal.GetLastWin32Error()));
else {
// If un-successful in opening handle for token then throw exception
throw new Exception(string.Format("OpenProcessToken Error: {0}", Marshal.GetLastWin32Error()));
// Return primary token
return li_PrimaryToken;
private static IntPtr GetEnvironmentBlock(IntPtr Pi_Token) {
IntPtr li_EnvBlock = IntPtr.Zero;
bool lb_ReturnValue = CreateEnvironmentBlock(ref li_EnvBlock, Pi_Token, false);
// Retrieve the environment variables for the specified user.
// This block can then be passed to the CreateProcessAsUser function.
// If not successful in creation of environment block then
if (!lb_ReturnValue) {
// Throw exception
throw new Exception(string.Format("CreateEnvironmentBlock Error: {0}", Marshal.GetLastWin32Error()));
// Return the retrieved environment block
return li_EnvBlock;
private static void LaunchProcessAsUser(string Ps_CmdLine, IntPtr Pi_Token, IntPtr Pi_EnvBlock) {
bool lb_Result = false;
PROCESS_INFORMATION lObj_ProcessInformation = default(PROCESS_INFORMATION);
SECURITY_ATTRIBUTES lObj_ProcessAttributes = default(SECURITY_ATTRIBUTES);
SECURITY_ATTRIBUTES lObj_ThreadAttributes = default(SECURITY_ATTRIBUTES);
STARTUPINFO lObj_StartupInfo = default(STARTUPINFO);
// Information about the newly created process and its primary thread.
lObj_ProcessInformation = new PROCESS_INFORMATION();
// Create security attributes to pass to the CreateProcessAsUser function
lObj_ProcessAttributes = new SECURITY_ATTRIBUTES();
lObj_ProcessAttributes.nLength = Convert.ToUInt32(Marshal.SizeOf(lObj_ProcessAttributes));
lObj_ThreadAttributes = new SECURITY_ATTRIBUTES();
lObj_ThreadAttributes.nLength = Convert.ToUInt32(Marshal.SizeOf(lObj_ThreadAttributes));
// To specify the window station, desktop, standard handles, and appearance of the
// main window for the new process.
lObj_StartupInfo = new STARTUPINFO();
lObj_StartupInfo.cb = Convert.ToUInt32(Marshal.SizeOf(lObj_StartupInfo));
lObj_StartupInfo.lpDesktop = null;
lObj_StartupInfo.dwFlags = Convert.ToUInt32(STARTF_USESHOWWINDOW | STARTF_FORCEONFEEDBACK);
lObj_StartupInfo.wShowWindow = SW_SHOW;
// Creates a new process and its primary thread. The new process runs in the
// security context of the user represented by the specified token.
lb_Result = CreateProcessAsUser(Pi_Token, null, Ps_CmdLine, ref lObj_ProcessAttributes, ref lObj_ThreadAttributes, true, CREATE_UNICODE_ENVIRONMENT, Pi_EnvBlock, null, ref lObj_StartupInfo, ref lObj_ProcessInformation);
// If create process return false then
if (!lb_Result) {
// Throw exception
throw new Exception(string.Format("CreateProcessAsUser Error: {0}", Marshal.GetLastWin32Error()));
To use the code, create a new windows service project, and add code like the following one:
using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Timers;
namespace WindowsServiceLaunchingExe
public partial class ExeLauncherSvc : ServiceBase
public ExeLauncherSvc() {
InitializeComponent();
Timer timer;
protected override void OnStart(string[] args) {
timer = new Timer(5000);
timer.Elapsed += (sender, e) => {
try {
timer.Stop();
EventLog.WriteEntry("WindowsServiceLaunchingExe", "Launching process...");
NativeMethods.LaunchProcess(@"C:\Windows\notepad.exe");
} catch (Exception ex) {
EventLog.WriteEntry("WindowsServiceLaunchingExe", ex.Message);
timer.Start();
protected override void OnStop() {
Because NativeMethods.LaunchProcess() throws exceptions on errors, be sure to enclose calling code in a try/catch-block.
I also would recommend reading this:
Stephen Martin - The Perils and Pitfalls of Launching a Process Under New Credentials
http://asprosys.blogspot.com/2009/03/perils-and-pitfalls-of-launching.html
Stephen Martin - Launch Process From Service (code download)
http://www.asprosys.com/Downloads/LaunchProcessFromService.zip
Marcel -
How create Windows Services in Azure using Visual Studio 2012
Hi,
I have a need to write a Windows Service (Batch Job), which would execute everyday at a specified time, say 4:00AM. This job will do some processing and will send out an email to predefined users. I am using Visual Studio 2012 for the development.
Based on some research, it looks like that Azure doesn't have a concept of Windows Service. Rather, we need to create WorkerRole to achieve the same.
I wrote the code to implement the WorkerRole. The problem, I am facing is that
1. How to prevent the continuous looping of the code below? I want the task to be executed only once a day at 4:00AM
2. How do I schedule this functionality in Azure?
Any help will be highly appreciated. I have provided the code sample below.
Thanks.
public class WorkerRole : RoleEntryPoint
public override void Run()
while (true)
SendNewsEmail();
Thread.Sleep(10000);
private void SendNewsEmail()
/*Email Logic Goes Here*/
public override bool OnStart()
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
return base.OnStart();HI
I think JuneT's answer is what you want.
However it's for Azure website.
If you still want to use a workerRole, you need much harder work.
You can use Timers Class to do such things:
http://stick2basic.wordpress.com/2013/02/22/how-to-schedule-a-c-windows-service-to-run-a-method-daily/
How do I schedule this functionality in Azure
I suggest you save the settings file in a cloud table, and notify your webrole using WCF service to let the service get the new settings when your changed it.
My Blog
Please use Make as Answer if my post solved your problem and use
Vote As Helpful if a post was useful. -
How to create a client console to connect to server in windows service using c#
my code is error
can you check the code please
client console code
partial class Program : ServiceBase
public static void Main(string[] args)
serverservice ss = new serverservice();
ss.myserver();
TcpClient tcpc = new TcpClient();
Console.WriteLine("connecting.......");
tcpc.Connect("10.128.1.116", 80);
Console.WriteLine("connected........");
Console.Write("enter msg to be transimitt");
string str = Console.ReadLine();
Stream stm = tcpc.GetStream();
ASCIIEncoding asc = new ASCIIEncoding();
byte[] ba = asc.GetBytes(str);
Console.WriteLine("transmitting..........");
stm.Write(ba, 0, ba.Length);
byte[] bb = new byte[100];
int k = stm.Read(bb, 0, 100);
for (int i = 0; i < k; i++)
Console.Write(Convert.ToChar(bb[i]));
tcpc.Close();
windows service for server code is
public partial class serverservice : ServiceBase
public serverservice()
InitializeComponent();
protected override void OnStart(string[] args)
myserver();
Thread mythread = new Thread(new ThreadStart(myserver));
mythread.Start();
public void myserver()
char d;
IPAddress ipad1 = IPAddress.Parse("10.128.1.116");
TcpListener tcpc = new TcpListener(ipad1, 80);
tcpc.Start();
// System.Diagnostics.Process.Start(@"C:\Users\PC\Documents\Visual Studio 2010\Projects\WindowsFormsApplication1\webs\webs\clientconsole\clientconsole\bin\Debug\clientconsole.exe");
Console.WriteLine("server is running at port 80");
Console.WriteLine("local end point is" + tcpc.LocalEndpoint);
Console.WriteLine("waiting for connection");
// var client=new TestExecutionEngine
Socket s = tcpc.AcceptSocket();
Console.WriteLine("connection is accepted from" + s.RemoteEndPoint);
byte[] b = new byte[100];
int k = s.Receive(b);
Console.WriteLine("received");
for (int i = 0; i < k; i++)
d = Convert.ToChar(b[i]);
Console.WriteLine(char.ToUpper(d));
ASCIIEncoding asc = new ASCIIEncoding();
s.Send(asc.GetBytes("msg is recveived"));
Console.WriteLine("\n send aknwldge");
s.Close();
tcpc.Stop();
protected override void OnStop()
EventLog.WriteEntry("stopped");kavya --
You have erroneously posted this question in a user forum dedicated to questions about Project Online, an enterprise project management application. I would recommend you repost your question in a user forum that deals with C sharp programming questions.
Hope this helps.
Dale A. Howard [MVP] -
Permissions for Windows Service on Server
Post Author: bdimon
CA Forum: Authentication
I wrote a Windows service running as an Active Directory user. It cannot print on the Windows Server so I wrote a windows application to test the permissions. When a user with local admin rights runs the test application, it prints. He starts the program using the "Run As" option and enters the Active Directory user from the service, he gets the same error as the Windows Service gets. This must be permissions-based.
When I installed this Windows Service on a staging server, everything was fine. However the staging server was not "secured" by the network team so the Active Directory user had Read/Execute permissions on the C: drive. I do not want to ask for these permissions on the production server's C: drive.
The error is:
System.Exception: Load report failed. ---> System.Runtime.InteropServices.COMException (0x800002AD): Error in File UNKNOWN.RPT:
The request could not be submitted for background processing.
at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
--- End of inner exception stack trace ---
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)
at WindowsApplication1.frmTestServerPrint.PrintCrystalReport(String& ErrorText, String ReportFileName, String PrinterLocation, Int32 PayTransStatusCode)Post Author: jgreg311
CA Forum: Authentication
I believe I'm having a similar problem, and was hoping to see if either you have found an answer to the problem or reactivate this thread in hopes someone will finally answer us.I'm creating reports using a windows service as well. The report files are compiled into the DLL, and they are being exported to save them to disk. The error is being generated when the report object is first accessed (which happens to be when attempting to set the Text property on a TextObject). It works fine on my development machine. I've installed the service on the production server using a Visual Studio 2005 Setup and Deployment project. I added the 2005 Crystal merge module to the setup, so all necessary files should exist on the server. The service is running as a domain user that has admin rights on the local machine, but we're still getting this error that seems, according to posts I've found online, to be a permissions issue.Here is the exception in its entirety:
Exception Type:
System.Exception
Exception Message:
Load report failed.
Exception Stack Trace:
at
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()
at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String
filename, OpenReportMethod openMethod, Int16 parentJob) at
CrystalDecisions.CrystalReports.Engine.ReportClass.Load(String
reportName, OpenReportMethod openMethod, Int16 parentJob) at
CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport()
at
CrystalDecisions.CrystalReports.Engine.ReportDocument.get_ReportDefinition()
at ...
Inner Exception:
System.Runtime.InteropServices.COMException (0x800002AD): Error in File
UNKNOWN.RPT: The request could not be submitted for background
processing. at
CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object&
DocumentPath, Int32 Options) at
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object&
DocumentPath, Int32 Options) at
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() Any help with this would be GREATLY appreciated. Once again Crystal Reports are the only thing holding up an important project. -
Here is the case:
OS environment: Windows 7
There are two user accounts in my system, standard user "S" and administrator account "A", and there is a windows service running with "Local System" privilege.
Now i logged-in with account "S", and i want to launch an application with elevated administrator account "A" from that service program, so here is the code snippet:
int LaunchAppWithElevatedPrivilege (
LPTSTR lpszUsername, // client to log on
LPTSTR lpszDomain, // domain of client's account
LPTSTR lpszPassword, // client's password
LPTSTR lpCommandLine // command line to execute e.g. L"C:\\windows\\regedit.exe"
DWORD dwExitCode = 0;
HANDLE hToken = NULL;
HANDLE hFullToken = NULL;
HANDLE hPrimaryFullToken = NULL;
HANDLE lsa = NULL;
BOOL bResult = FALSE;
LUID luid;
MSV1_0_INTERACTIVE_PROFILE* profile = NULL;
DWORD err;
PTOKEN_GROUPS LocalGroups = NULL;
DWORD dwLength = 0;
DWORD dwSessionId = 0;
LPVOID pEnv = NULL;
DWORD dwCreationFlags = 0;
PROCESS_INFORMATION pi = {0};
STARTUPINFO si = {0};
__try
if (!LogonUser( lpszUsername,
lpszDomain,
lpszPassword,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
&hToken))
LOG_FAILED(L"GetTokenInformation failed!");
__leave;
if( !GetTokenInformation(hToken, (TOKEN_INFORMATION_CLASS)19, (VOID*)&hFullToken,
sizeof(HANDLE), &dwLength))
LOG_FAILED(L"GetTokenInformation failed!");
__leave;
if(!DuplicateTokenEx(hFullToken, MAXIMUM_ALLOWED, NULL,
SecurityIdentification, TokenPrimary, &hPrimaryFullToken))
LOG_FAILED(L"DuplicateTokenEx failed!");
__leave;
DWORD dwSessionId = 0;
WTS_SESSION_INFO* sessionInfo = NULL;
DWORD ndSessionInfoCount;
bResult = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &sessionInfo, &ndSessionInfoCount);
if (!bResult)
dwSessionId = WTSGetActiveConsoleSessionId();
else
for(unsigned int i=0; i<ndSessionInfoCount; i++)
if( sessionInfo[i].State == WTSActive )
dwSessionId = sessionInfo[i].SessionId;
if(0 == dwSessionId)
LOG_FAILED(L"Get active session id failed!");
__leave;
if(!SetTokenInformation(hPrimaryFullToken, TokenSessionId, &dwSessionId, sizeof(DWORD)))
LOG_FAILED(L"SetTokenInformation failed!");
__leave;
if(CreateEnvironmentBlock(&pEnv, hPrimaryFullToken, FALSE))
dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT;
else
pEnv=NULL;
if (! ImpersonateLoggedOnUser(hPrimaryFullToken) )
LOG_FAILED(L"ImpersonateLoggedOnUser failed!");
__leave;
si.cb= sizeof(STARTUPINFO);
si.lpDesktop = L"winsta0\\default";
bResult = CreateProcessAsUser(
hPrimaryFullToken, // client's access token
NULL, // file to execute
lpCommandLine, // command line
NULL, // pointer to process SECURITY_ATTRIBUTES
NULL, // pointer to thread SECURITY_ATTRIBUTES
FALSE, // handles are not inheritable
dwCreationFlags, // creation flags
pEnv, // pointer to new environment block
NULL, // name of current directory
&si, // pointer to STARTUPINFO structure
&pi // receives information about new process
RevertToSelf();
if (bResult && pi.hProcess != INVALID_HANDLE_VALUE)
WaitForSingleObject(pi.hProcess, INFINITE);
GetExitCodeProcess(pi.hProcess, &dwExitCode);
else
LOG_FAILED(L"CreateProcessAsUser failed!");
__finally
if (pi.hProcess != INVALID_HANDLE_VALUE)
CloseHandle(pi.hProcess);
if (pi.hThread != INVALID_HANDLE_VALUE)
CloseHandle(pi.hThread);
if(LocalGroups)
LocalFree(LocalGroups);
if(pEnv)
DestroyEnvironmentBlock(pEnv);
if(hToken)
CloseHandle(hToken);
if(hFullToken)
CloseHandle(hFullToken);
if(hPrimaryFullToken)
CloseHandle(hPrimaryFullToken);
return dwExitCode;
I passed in username and password of account "A" to method "LaunchAppWithElevatedPrivilege", and also the application i want to launch, e.g. "C:\windows\regedit.exe", but when i run the service program, i found it do launch
"regedit.exe" with elevated account "A", but the content of regedit.exe is pure back. screenshot as below:
Can anyone help me on this?You code is not dealing with the DACL access to Winsta0\Default. Only the LocalSystem account will have full access and the interactively logged on user which is why regedit is not displaying properly. You'll need to grant access to your user.
You also need to deal with UAC since that code is going to give you a non-elevated token via LogonUser(). You need to get the full token via a call to GetTokenInformation() + TokenLinkedToken.
thanks
Frank K [MSFT]
Follow us on Twitter, www.twitter.com/WindowsSDK. -
Unable to start Admin Server as a windows service
I installed Admin Server as a windows service and when I started it, I got the below errors. Do you have any ideas?
I'm using SOA Suite 11.1.1.2.0 and WL 10.3.2 on Windows
Thanks,
[Mon Mar 15 11:16:19 2010] [initLog] initializing logger
[Mon Mar 15 11:16:19 2010] [E] [initLog] No 'ROTATION_TYPE' header found. 'TIME' based rotation will be used by default.
[Mon Mar 15 11:16:19 2010] [E] [initLog] No 'TIME_START_DATE' header found or value is invalid. Rotation will take place every 24 hours beginning today at 23:59:59
[Mon Mar 15 11:16:19 2010] [E] [initLog] No 'TIME_INTERVAL_MINS' header found. Using the default value of 24 hours.
[Mon Mar 15 11:16:19 2010] [I] [initLog] TIME based log rotation is ON
[Mon Mar 15 11:16:19 2010] [I] [trigger] First rotation due in 45820 secs
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] console allocation successful. THREAD_DUMP redirection enabled
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] About to execute CreateThread()
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] lpszCmdLine = -jrockit -Xms128m -Xmx256m -Xverify:none -classpath "C:\ORACLE~1\MIDDLE~1\patch_wls1032\profiles\default\sys_manifest_classpath\weblogic_patch.jar;C:\ORACLE~1\MIDDLE~1\JROCKI~1.5-3\lib\tools.jar;C:\ORACLE~1\MIDDLE~1\utils\config\10.3\config-launch.jar;C:\ORACLE~1\MIDDLE~1\WLSERV~1.3\server\lib\weblogic_sp.jar;C:\ORACLE~1\MIDDLE~1\WLSERV~1.3\server\lib\weblogic.jar;C:\ORACLE~1\MIDDLE~1\modules\features\weblogic.server.modules_10.3.2.0.jar;C:\ORACLE~1\MIDDLE~1\WLSERV~1.3\server\lib\webservices.jar;C:\ORACLE~1\MIDDLE~1\modules\ORGAPA~1.0/lib/ant-all.jar;C:\ORACLE~1\MIDDLE~1\modules\NETSFA~1.0_1/lib/ant-contrib.jar;C:\ORACLE~1\MIDDLE~1\JROCKI~1.5-3\jre\lib\rt.jar;C:\ORACLE~1\MIDDLE~1\WLSERV~1.3\server\lib\webservices.jar;" -Dweblogic.Name=AdminServer -Dweblogic.management.username= -Dweblogic.ProductionModeEnabled= -Djava.security.policy="C:\ORACLE~1\MIDDLE~1\WLSERV~1.3\server\lib\weblogic.policy" weblogic.Server
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] lpszJavaHome = C:\ORACLE~1\MIDDLE~1\JROCKI~1.5-3
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] lpszExecDir = C:\Oracle11112\Middleware\user_projects\domains\soadev_domain
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] lpszOldPath = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] lpszNewPath = C:\ORACLE~1\MIDDLE~1\WLSERV~1.3\server\native\win\32;C:\ORACLE~1\MIDDLE~1\WLSERV~1.3\server\bin;C:\ORACLE~1\MIDDLE~1\JROCKI~1.5-3\jre\bin;C:\ORACLE~1\MIDDLE~1\JROCKI~1.5-3\bin;C:\ORACLE~1\MIDDLE~1\WLSERV~1.3\server\native\win\32\oci920_8;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] lpszDelay = 0
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] lpszStopClass = []
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] lpszLog = [C:\Oracle11112\Middleware\user_projects\domains\soadev_domain\servers\AdminServer\logs\AdminServerSvc.log]
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] Thread created successfully
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] Reporting SCM of SERVICE_START_PENDING with delay=0
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] lpszHost = []
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] lpszPort = []
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] Reporting SCM of SERVICE_RUNNING
[Mon Mar 15 11:16:19 2010] [I] [ServiceStart] waiting for multiple events
[Mon Mar 15 11:16:19 2010] [I] [StartJVM] Parsing JVM Arguments
[Mon Mar 15 11:16:19 2010] [I] [StartJVM] Initializing JVM
[Mon Mar 15 11:16:20 2010] [I] [RunJavaApp] Loading class - weblogic.Server
[Mon Mar 15 11:16:20 2010] [I] [RunJavaApp] Locating method "public static void main([]String)" in main class
[Mon Mar 15 11:16:20 2010] [I] [RunJavaApp] Building arguments for main class
[Mon Mar 15 11:16:20 2010] [I] [RunJavaApp] Invoking main class
<Mar 15, 2010 11:16:22 AM PDT> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with BEA JRockit(R) Version R27.6.5-32_o-121899-1.6.0_14-20091001-2107-windows-ia32 from BEA Systems, Inc.>
<Mar 15, 2010 11:16:23 AM PDT> <Info> <Management> <BEA-141107> <Version: WebLogic Server 10.3.2.0 Tue Oct 20 12:16:15 PDT 2009 1267925 >
<Mar 15, 2010 11:16:27 AM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
<Mar 15, 2010 11:16:27 AM PDT> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool>
<Mar 15, 2010 11:16:27 AM PDT> <Notice> <LoggingService> <BEA-320400> <The log file C:\Oracle11112\Middleware\user_projects\domains\soadev_domain\servers\AdminServer\logs\AdminServer.log will be rotated. Reopen the log file if tailing has stopped. This can happen on some platforms like Windows.>
<Mar 15, 2010 11:16:27 AM PDT> <Notice> <LoggingService> <BEA-320401> <The log file has been rotated to C:\Oracle11112\Middleware\user_projects\domains\soadev_domain\servers\AdminServer\logs\AdminServer.log00005. Log messages will continue to be logged in C:\Oracle11112\Middleware\user_projects\domains\soadev_domain\servers\AdminServer\logs\AdminServer.log.>
<Mar 15, 2010 11:16:27 AM PDT> <Notice> <Log Management> <BEA-170019> <The server log file C:\Oracle11112\Middleware\user_projects\domains\soadev_domain\servers\AdminServer\logs\AdminServer.log is opened. All server side log events will be written to this file.>
<Mar 15, 2010 11:16:34 AM PDT> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.>
<Mar 15, 2010 11:16:41 AM PDT> <Critical> <WebLogicServer> <BEA-000286> <Failed to invoke startup class "JRF Startup Class", java.lang.ClassNotFoundException: oracle.jrf.wls.JRFStartup
java.lang.ClassNotFoundException: oracle.jrf.wls.JRFStartup
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClass(ClassDeploymentManager.java:253)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.access$000(ClassDeploymentManager.java:54)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:205)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:41 AM PDT> <Critical> <WebLogicServer> <BEA-000286> <Failed to invoke startup class "JPS Startup Class", java.lang.ClassNotFoundException: oracle.security.jps.wls.JpsWlsStartupClass
java.lang.ClassNotFoundException: oracle.security.jps.wls.JpsWlsStartupClass
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClass(ClassDeploymentManager.java:253)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.access$000(ClassDeploymentManager.java:54)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:205)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:41 AM PDT> <Critical> <WebLogicServer> <BEA-000286> <Failed to invoke startup class "ODL-Startup", java.lang.ClassNotFoundException: oracle.core.ojdl.weblogic.ODLConfiguration
java.lang.ClassNotFoundException: oracle.core.ojdl.weblogic.ODLConfiguration
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClass(ClassDeploymentManager.java:253)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.access$000(ClassDeploymentManager.java:54)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:205)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:41 AM PDT> <Critical> <WebLogicServer> <BEA-000286> <Failed to invoke startup class "AWT Application Context Startup Class", java.lang.ClassNotFoundException: oracle.jrf.AppContextStartup
java.lang.ClassNotFoundException: oracle.jrf.AppContextStartup
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClass(ClassDeploymentManager.java:253)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.access$000(ClassDeploymentManager.java:54)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:205)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:41 AM PDT> <Critical> <WebLogicServer> <BEA-000286> <Failed to invoke startup class "JMX Framework Startup Class", java.lang.ClassNotFoundException: oracle.as.jmx.framework.wls.spi.StartupListener
java.lang.ClassNotFoundException: oracle.as.jmx.framework.wls.spi.StartupListener
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClass(ClassDeploymentManager.java:253)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.access$000(ClassDeploymentManager.java:54)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:205)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:41 AM PDT> <Critical> <WebLogicServer> <BEA-000286> <Failed to invoke startup class "JOC-Startup", java.lang.ClassNotFoundException: oracle.ias.cache.Startup
java.lang.ClassNotFoundException: oracle.ias.cache.Startup
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClass(ClassDeploymentManager.java:253)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.access$000(ClassDeploymentManager.java:54)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:205)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:41 AM PDT> <Critical> <WebLogicServer> <BEA-000286> <Failed to invoke startup class "DMS-Startup", java.lang.ClassNotFoundException: oracle.dms.wls.DMSStartup
java.lang.ClassNotFoundException: oracle.dms.wls.DMSStartup
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClass(ClassDeploymentManager.java:253)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.access$000(ClassDeploymentManager.java:54)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:205)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:43 AM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY>
<Mar 15, 2010 11:16:43 AM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
<Mar 15, 2010 11:16:47 AM PDT> <Error> <HTTP> <BEA-101371> <There was a failure when processing annotations for application C:\Oracle11112\Middleware\user_projects\domains\soadev_domain\servers\AdminServer\tmp\_WL_user\FMW Welcome Page Application_11.1.0.0.0\cb7uge\fmw-welcome.war. Please make sure that the annotations are valid. The error is oracle.dms.wls.DMSServletFilter>
<Mar 15, 2010 11:16:47 AM PDT> <Error> <Deployer> <BEA-149205> <Failed to initialize the application 'FMW Welcome Page Application [Version=11.1.0.0.0]' due to error weblogic.application.ModuleException: Failed to load webapp: '/'.
weblogic.application.ModuleException: Failed to load webapp: '/'
at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:378)
at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:391)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: oracle.dms.wls.DMSServletFilter
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
Truncated. see log file for complete stacktrace
>
When processing WebService module 'wsil.war'. Failed to load servlet Class: oracle.j2ee.ws.server.wsil.WSILServlet
Ignoring: unable to load class:java.lang.ClassNotFoundException: oracle.j2ee.ws.server.wsil.WSILServlet at: weblogic.xml.schema.binding.util.ClassUtil.loadClass(ClassUtil.java:76)
When processing WebService module 'wsil.war'. Failed to load servlet Class: oracle.j2ee.ws.server.wsil.WSILServlet
Ignoring: unable to load class:java.lang.ClassNotFoundException: oracle.j2ee.ws.server.wsil.WSILServlet at: weblogic.xml.schema.binding.util.ClassUtil.loadClass(ClassUtil.java:76)
<Mar 15, 2010 11:16:47 AM PDT> <Error> <Deployer> <BEA-149205> <Failed to initialize the application 'em' due to error weblogic.management.DeploymentException: .
weblogic.management.DeploymentException:
at weblogic.application.internal.flow.BaseLifecycleFlow$CreateListenerAction.run(BaseLifecycleFlow.java:176)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.application.internal.flow.BaseLifecycleFlow$BaseAction.invoke(BaseLifecycleFlow.java:104)
at weblogic.application.internal.flow.HeadLifecycleFlow.createListener(HeadLifecycleFlow.java:117)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: oracle.security.jps.wls.listeners.JpsApplicationLifecycleListener
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.application.internal.flow.BaseLifecycleFlow$CreateListenerAction.run(BaseLifecycleFlow.java:140)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:47 AM PDT> <Error> <HTTP> <BEA-101165> <Could not load user defined filter in web.xml: ServletContext@11450347[app:DMS Application module:dms.war path:/dms spec-version:2.5 version:11.1.1.1.0] oracle.dms.wls.DMSServletFilter.
java.lang.ClassNotFoundException: oracle.dms.wls.DMSServletFilter
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:47 AM PDT> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application 'DMS Application [Version=11.1.1.1.0]'.
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1399)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:460)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: oracle.dms.wls.DMSServletFilter
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:47 AM PDT> <Error> <HTTP> <BEA-101165> <Could not load user defined filter in web.xml: ServletContext@12124116[app:wsil-wls module:/inspection.wsil path:/inspection.wsil spec-version:2.5] oracle.dms.wls.DMSServletFilter.
java.lang.ClassNotFoundException: oracle.dms.wls.DMSServletFilter
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:47 AM PDT> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application 'wsil-wls'.
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1399)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:460)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: oracle.dms.wls.DMSServletFilter
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <LoggingService> <BEA-320400> <The log file C:\Oracle11112\Middleware\user_projects\domains\soadev_domain\servers\AdminServer\logs\soadev_domain.log will be rotated. Reopen the log file if tailing has stopped. This can happen on some platforms like Windows.>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <LoggingService> <BEA-320401> <The log file has been rotated to C:\Oracle11112\Middleware\user_projects\domains\soadev_domain\servers\AdminServer\logs\soadev_domain.log00004. Log messages will continue to be logged in C:\Oracle11112\Middleware\user_projects\domains\soadev_domain\servers\AdminServer\logs\soadev_domain.log.>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <Log Management> <BEA-170027> <The Server has established connection with the Domain level Diagnostic Service successfully.>
<Mar 15, 2010 11:16:48 AM PDT> <Critical> <WebLogicServer> <BEA-000286> <Failed to invoke startup class "Audit Loader Startup Class", java.lang.ClassNotFoundException: oracle.security.audit.ajl.loader.JEEAuditLoader
java.lang.ClassNotFoundException: oracle.security.audit.ajl.loader.JEEAuditLoader
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.invokeClass(ClassDeploymentManager.java:253)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager.access$000(ClassDeploymentManager.java:54)
at weblogic.management.deploy.classdeployment.ClassDeploymentManager$1.run(ClassDeploymentManager.java:205)
Truncated. see log file for complete stacktrace
>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <Server> <BEA-002613> <Channel "Default[2]" is now listening on fe80:0:0:0:0:5efe:a01:1b5:7001 for protocols iiop, t3, ldap, snmp, http.>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <Server> <BEA-002613> <Channel "Default[3]" is now listening on fe80:0:0:0:0:100:7f:fffe:7001 for protocols iiop, t3, ldap, snmp, http.>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <Server> <BEA-002613> <Channel "Default[5]" is now listening on 127.0.0.1:7001 for protocols iiop, t3, ldap, snmp, http.>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <Server> <BEA-002613> <Channel "Default[4]" is now listening on 0:0:0:0:0:0:0:1:7001 for protocols iiop, t3, ldap, snmp, http.>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <Server> <BEA-002613> <Channel "Default[1]" is now listening on fe80:0:0:0:4b5:ea73:59f2:2e1a:7001 for protocols iiop, t3, ldap, snmp, http.>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 10.1.1.181:7001 for protocols iiop, t3, ldap, snmp, http.>
<Mar 15, 2010 11:16:48 AM PDT> <Notice> <WebLogicServer> <BEA-000331> <Started WebLogic Admin Server "AdminServer" for domain "soadev_domain" running in Development Mode>
<Mar 15, 2010 11:16:48 AM PDT> <Warning> <Server> <BEA-002611> <Hostname "mycomputer.abc.com", maps to multiple IP addresses: 10.1.1.100, bf80:0:0:0:3gr:kdab:43f3:2e1a%10>
<Mar 15, 2010 11:16:49 AM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING>
<Mar 15, 2010 11:16:49 AM PDT> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>Hi,
If you see your logs, you server has actually started in "RUNNING" mode. Its only throwing lot of "ClassNotFoundException" because I guess they classes are not available in classpaths. If you know the "jar" which contains which are being complained, copy the jar files to "DOMAIN_HOME/lib" which is simple way to add jars to classpath.
<Mar 15, 2010 11:16:49 AM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING>
<Mar 15, 2010 11:16:49 AM PDT> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>
Thanks.
Vijay Bheemineni. -
Problems with ShutdownHook and Windows Service
Hi friends,
I am facing a problem with the ShutdownHook when a Java program is run as a Windows Service. In the program I am having a Daemon Thread which will be run in an infinite while loop accoridng to a boolean variable. I have a shutdown hook also which sets the boolean variable so that the Daemon Thread will be stopped gracefully. When i am using Ctrl-C the shutdown Hook is started and the Thread is stopped gracefully.
Later i have made my program as a Windows Service using a utility Java Service Wrapper. But when i stop the service though the Services Window the ShutdownHook is not getting called. I was not able to fnd out why it is happening like that.
Any help will be highly appreciated. Thanks in advance.Hi Drmetz
If you are waiting on a reply it could be some time, as this is the *Mac OS X v10.3 & earlier* forum and few here know about Windows, parallels MacBooks or the Tiger OS.
Mac's cover a wide field.
You could try reposting in this forum which would be your best best I think.
Windows Compatibility forum
http://discussions.apple.com/forum.jspa?forumID=687
also
MacBook forum
http://discussions.apple.com/category.jspa?categoryID=218
or even the Tiger Forum
http://discussions.apple.com/category.jspa?categoryID=160
Good luck,
regards roam -
Windows Service Manager 32-Bit Has Stopped Responding/iPod not showing up in iTunes
Hello,
I've scoured this forum for answers but I cannot find any result that works. I have an iPod classic that I've connected to my Gateway running Windows Vista for over four years without issue. When I was using iTunes 9 the other day, I plugged my iPod into my computer, but it only connected to My Computer and didn't connect to iTunes and update my iPod accordingly. So, the iPod is charging and the iPod is showing the "Connected, Eject before disconnecting" screen, but it isn't adding new music (which kind of defeats the purpose of buying new music). I thought it was because I was using 9, so I downloaded iTunes 10, but the issue still popped up.
This hasn't pop up today after I installed 10, but back when I was using iTunes 9 the following error came up on my computer: "Windows Service Manager 32-bit Has Stopped Working." Now, no error messages pop up, even though the problem persists.
I've tried suggestions in this post as well as in this post. Also, with the fix being recommended in those threads to change the code in Notepad by clicking "edit" under the System tab under My Computer? There's one problem - there is no edit button on my options. I've included a screen grab to prove this.
I don't know if the relative age of the discussions makes any difference - maybe a new fix has com up and i'm just not finding it? Plus, since this issue began with iTunes 9, I can't help but feel like getting rid of iTunes 10 is going to help the issue, either.
This is incredibly frustrating, not being able to add new music to my iPod, so if anyone can help me out, I would greatly appreciate it, as previously recommended ones aren't useful.
Screen grab of iPod connecting to My Computer, but not iTunes:
Screen grab of the lack of an "Edit" button in the place to edit codes as recommended in previous topics:One again shamelessly asking for help
-
Windows Service no longer able to print PDF files using Adobe Reader 11.0.07.79
We have a Windows Service that watches a folder for PDF files to be deposited. Once awakened, it executes the Adobe Reader in command line mode to print the PDF files to secure check printers. The Windows Service was working fine with 11.0.06.70 but no longer works with 11.0.07.79.
There are no event viewer errors or errors returned to our Process.Start() call. The Windows Service is running under the identify of an administrator account and has explicit full access to the printer. We have also tried the local computer's Administrator account as well as the default Local Service, but none work.
Using ProcMon to examine the failure, it showed Adobe Reader making many successful registry and file accesses. Adobe Reader then creates a new process, another instance of itself to read in the PDF file and print to the printer. However, ProcMon only shows Adobe Reader accessing AcroRd32.exe, syswow.dll (sp) and ntdll.dll and then the thread and process immediately exits with an exit code of 0 (no file or registry accesses). So, something is causing the instantiated process to fail immediately.
After more research and trying many things, we disabled "Enable Protected Mode at Startup". This enabled things to work again.
We are concerned that disabling this feature might expose security concerns for our customers.
We are suspecting that some security concerns were tightened with 11.0.07.79 that has inadvertently caused printing from Windows Services to falsely be identified as security violations. Can you please investigate and provide a resolution?
Thank you.
Craig Keating
Alliance Enterprises, Inc.
[email protected]Hi,
Can you please give the following details:
1) Command (given in command line)used to print PDF files?
2) Is the issue reproducible with other printers as well?
3) Is directly printing the PDF from that folder using command line i.e without using windows service works fine or not?
Thanks,
Shakti K -
Windows Service (SMB) does not start automatically
I have a client with an Xserve G5 running 10.4.8 with all software updates applied. Recently, the client decided to buy a new Ricoh multi-function printer, copier, fax machine. We've configured a share point on the server that the Ricoh uses to deposit the incoming faxes and scans. It works fine, but the downside is that it only works over SMB or FTP. I went with SMB (Windows Sharing) because of Apple's flakey implementation of FTP over the years.
The problem is that when the server gets rebooted -- due to power outtage, software update, whatever -- the Windows sharing does not turn itself on like all of the services do. I have to go into Server Admin and turn on Windows sharing manually.
Is there any way to get the Windows Sharing to turn on automatically at boot up like all of the other services do?I had the exact same problem after applying the 10.4.8 combo update. This thread solved my problem:
http://discussions.apple.com/thread.jspa?messageID=2962778�
In short, I had to disable the "Workgroup Master Browser" setting in Server Admin > Windows Service > Settings > Advanced. This is enabled by default, by the way.
Maybe you are looking for
-
Reg:Insert the record in another ztable
Hi Experts, My scenerio is that when a record is inserted from a program to a table i need to added the same values to another table which is on different server(ex: BW). Is it necessary to create events to do that because i don't n
-
Exporting Video without lossing quality. A Nightmare!
Hi all, a recently bought a Sony Handycam HDR-CX160e, which records videos in HD, in AVCHD format (.MTS files). I cannot import / export a file using imovie without lossing quality. What I do is: a) Record the video in HD Standard Quality. It saves t
-
Passing Values to a BW Template through Java - Dynpage
Hello All! -I have one Java-Dynpage Application. I have created an Iview from that PAR file. -This Dynpage accepts some input from user(say his employee number) and displays some data from SQL server. -Now I want that when the user enters the input a
-
I apply the below function to the range that has the same dimension as x or defaultdata. However the function does not seem to work properly and returns #Value mistake. The function is run in Microsoft Office 2010. Cant figure out why the mistake occ
-
Exporting Adobe Illustrator CS files to DXF or DWG
How do I export Adobe Illustrator CS files to AutoCAD DXF or DWG files and still keep the size 100%. The engineer opening my .DXF and .DWG files said my drawings are over 300% larger than actual. Thx in advance!