Could not load assembly 'Newtonsoft.Json' using ml.net in Azure Web Api - ml.net

TL;DR
In an Azure-hosted Web API, an ML.net model fails to load due to a missing Newtonsoft.Json dependency.
Details
I've a C# net6.0 Azure hosted Web API that loads and calls a pre-built ML.net (v1.7.0) model (multi-classification using SdcaMaximumEntropy, in case that's relevant).
I've tested it locally using a console app to call the localhost web api. This is then deployed, via a GitHub action, to an Azure Api App (action yaml snippet below).
- name: Set up .NET Core
uses: actions/setup-dotnet#v1
with:
dotnet-version: '6.0.x'
include-prerelease: true
Once deployed, I can call the relevant endpoint but an exception is generated from the Model.Load method below. [The api returns a 500 ... the detail is available via Azure App Insights.]
private readonly MLContext _mlContext;
...
var loadedModel = _mlContext.Model.Load(_modelPath, out var _);
Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
The system cannot find the file specified.
Any pointers as to why that's happening gratefully received; let me know if there's any further info required.
Further Info
In the project, Newtonsoft.Json is only required/referenced by the Microsoft.ML package.
I've checked in the Advanced Tools (kudu) to ensure NewtonSoft.Json is being deployed.
I've tried adding an explicit reference to the Newtonsoft.Json package; I've also tried adding another package that has a reference to Newtonsoft; I've switched the Model.Load to the more robust AddPredictionEnginePool variation. None of these had any impact (but still work locally).
I've checked that the _modelPath of the model was being set to the right location [D:\home\site\wwwroot\SupporterCategoriser\Data\model.zip], and that the model exists, in case the missing model was somehow being mis-reported.
n.b. There have been numerous Newtonsoft FileNotFoundException questions posted over the last decade, none seemed to be related.
n.b. There are also plans to remove the Newtonsoft dependency from the ML package but not for any related reason.
Stack trace
System.IO.FileNotFoundException:
at System.Reflection.CustomAttribute._CreateCaObject (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Reflection.CustomAttribute.CreateCaObject (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Reflection.CustomAttribute.AddCustomAttributes (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Reflection.CustomAttribute.GetCustomAttributes (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Reflection.CustomAttribute.GetCustomAttributes (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Reflection.RuntimeAssembly.GetCustomAttributes (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Attribute.GetCustomAttributes (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.ML.Runtime.ComponentCatalog.RegisterAssembly (Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at Microsoft.ML.ModelLoadContext.EnsureLoaderAssemblyIsRegistered (Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at Microsoft.ML.ModelLoadContext.TryLoadModelCore (Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at Microsoft.ML.ModelLoadContext.TryLoadModel (Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at Microsoft.ML.ModelLoadContext.LoadModel (Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at Microsoft.ML.ModelLoadContext.LoadModelOrNull (Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at Microsoft.ML.ModelLoadContext.LoadModel (Microsoft.ML.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at Microsoft.ML.ModelOperationsCatalog.Load (Microsoft.ML.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at Microsoft.ML.ModelOperationsCatalog.Load (Microsoft.ML.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51)
at GolfGuruApi.SupporterCategoriser.Services.CategoryService.PredictIssue (XxxApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\xxx-api\xxx-api\XxxApi\SupporterCategoriser\Services\CategoryService.cs:143)
at XxxApi.SupporterCategoriser.Services.CategoryService.GetCategory (XxxApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\xxx-api\xxx-api\XxxApi\SupporterCategoriser\Services\CategoryService.cs:31)
at lambda_method2 (Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
at Microsoft.AspNetCore.Http.RequestDelegateFactory+<>c__DisplayClass46_3+<<HandleRequestBodyAndCompileRequestDelegate>b__2>d.MoveNext (Microsoft.AspNetCore.Http.Extensions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Routing.EndpointMiddleware+<<Invoke>g__AwaitRequestTask|6_0>d.MoveNext (Microsoft.AspNetCore.Routing, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1+<ProcessRequestAsync>d__2.MoveNext (Microsoft.AspNetCore.Server.IIS, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ML" Version="1.7.0" />
</ItemGroup>
<ItemGroup>
<None Update="SupporterCategoriser\Data\model.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Related

Sitecore 9.2 Helix ,How to use Assets, SitecoreExtension and Dependency Injection that exist in foundation layer of habitat

I am beginner to development in sitecore using Helix Design Principle
i started with blank project and added one feature in feature layer and one layout in project layer as in this image and it works fine.
my issue when i tried to use asset module for styling purpose that exists in foundation layer of habitat to my project, it told me that it needs Dependency Injection and Sitecore Extension
and when i try to load DependenyInjection inside my project , and deploy it with gulpfile as in this image,the sitecore gave me that error
Server Error in '/' Application.
Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 187: try
Line 188: {
Line 189: return assembly.GetExportedTypes();
Line 190: }
Line 191: catch (NotSupportedException)
Source File: D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs Line: 189
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) +0
System.Reflection.RuntimeAssembly.GetExportedTypes() +32
Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.GetExportedTypes(Assembly assembly) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:189
[InvalidOperationException: Unable to load types from assembly Sitecore.XA.JSS.Foundation.Integration, Version=5.9.0.0, Culture=neutral, PublicKeyToken=null. Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.GetExportedTypes(Assembly assembly) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:210
System.Linq.<SelectManyIterator>d__17`2.MoveNext() +265
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +287
System.Linq.WhereEnumerableIterator`1.MoveNext() +255
Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.AddClassesWithServiceAttribute(IServiceCollection serviceCollection, Assembly[] assemblies) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:39
Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.AddClassesWithServiceAttribute(IServiceCollection serviceCollection, String[] assemblyFilters) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:27
Sitecore.Foundation.DependencyInjection.Infrastructure.MvcControllerServicesConfigurator.Configure(IServiceCollection serviceCollection) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\Infrastructure\MvcControllerServicesConfigurator.cs:12
Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +171
Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +171
Sitecore.DependencyInjection.BaseServiceProviderBuilder.ConfigureServiceCollection() +142
Sitecore.DependencyInjection.ServiceLocator.ConfigureServiceProvider() +225
Sitecore.DependencyInjection.ServiceLocator.get_ServiceProvider() +513
Sitecore.DependencyInjection.SitecorePerRequestScopeModule..ctor() +13
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +142
System.Activator.CreateInstance(Type type, Boolean nonPublic) +107
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1476
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +186
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +80
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +234
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1153
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +139
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369
[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +724
First, take a look at this sitecore community question as it feels similar to your case.
Then, if not fixed :
Make sure you have added the sitecore nuget source (https://sitecore.myget.org/F/sc-packages/api/v3/index.json) in your visual studio using nuget package manager -> Package Sources.
Add this source to your nuget.config within your solution as well.
Make sure you don't have any of those following dependencies already installed with some other reference within your project
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.4" />
<PackageReference Include="Microsoft.AspNet.Razor" Version="3.2.4" />
<PackageReference Include="Microsoft.AspNet.WebPages" Version="3.2.4" />
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="1.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Net.Compilers" Version="1.3.2" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="System.ComponentModel" Version="4.0.1" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.0.11" />
<PackageReference Include="System.Globalization" Version="4.0.11" />
<PackageReference Include="System.Linq" Version="4.1.0" />
<PackageReference Include="System.Linq.Expressions" Version="4.1.0" />
<PackageReference Include="System.Reflection" Version="4.1.0" />
<PackageReference Include="System.Resources.ResourceManager" Version="4.0.1" />
</ItemGroup>
From habitat project repos

Testhost.exe has exited with code -1 (0xffffffff)

I am attempting to override a few variables in my integration test with secrets sourced from KeyVault via a variable group within the build pipeline.
I have added a .runsettings file & I'm able to retrieve the dummy variables when I debug through the test. The test however exits abruptly as soon as the instruction to read the dummy value has been executed with the error below:
Value of CrmClientSecret is JustSomeSecret
Step into: Stepping over non-user code
'IntegrationTests.Helpers.Helper.DeleteUserFromCRM' Step into: Stepping over
non-user code 'IntegrationTests.Helpers.Helper. d__4..ctor' 'testhost.exe'
(CLR v4.0.30319: TestSourceHost: Enumering source
(C:\source\repos\Azure\Integrat ionTests\bin\Debug\Tests.dll)): Loaded
'C:\source\repos\Azure\IntegrationTests\bin\Debug\Utilities.dll'. Symbols
loaded. The thread 0x527c has exited with code 0 (0x0). The program '[26720]
testhost.exe' has exited with code -1 (0xffffffff). The program '[26720]
testhost.exe: Program Trace' has exited with code 0 (0x0).
Any help is appreciated
The solution is hosted in Visual Studio Ent 2017. The test project is net 4.61 & the following Nuget packages are installed:
Microsoft.NET.Test.Sdk v 15.9.0
MSTest.TestAdapter v 1.3.2
MSTest.TestFramework v 1.3.2
NUnit3TestAdapter version 3.11.0
Here are my test results:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<MaxCpuCount>2</MaxCpuCount>
<ResultsDirectory>.\TestResults</ResultsDirectory>
<TargetPlatform>x64</TargetPlatform>
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
<TestAdaptersPaths>%systemdrive%\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\Extensions</TestAdaptersPaths>
<TestSessionTimeout>10000</TestSessionTimeout>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
<DataCollector uri="datacollector://microsoft/VideoRecorder/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder.VideoRecorderDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Screen and Voice Recorder">
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<TestRunParameters>
<Parameter name="AmbassadorsDbConnectionString"
value="TheConnectionString" />
<Parameter name="CRMClientSecret" value="JustSomeSecret" />
<Parameter name="webAppPassword" value="Password" />
</TestRunParameters>
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False
<DeploymentEnabled>False</DeploymentEnabled>
<AssemblyResolution>
<Directory path="D:\myfolder\bin\" includeSubDirectories="false"/>
</AssemblyResolution>
</MSTest>
</RunSettings>
You can use the blame option to collect the dump and analyze the cause for the crash
https://github.com/Microsoft/vstest-docs/blob/master/RFCs/0024-Blame-Collector-Options.md

Tracing to LogSource 'All Events' failed. Enterprise Library logging error

I am getting error. I am unable to understand what causing error. There are no exception on UI.
Category tables has values (Information,Exception,Debug,General). When all events failed error occurs there is no record entered into CategoryLog table. Can someone please help me to understand this error and to fix it.
Tracing to LogSource 'All Events' failed. Processing for other sources will continue.
See summary information below for more information. Should this problem persist,
stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks.
Summary for Enterprise Library Distributor Service:
====================================== -->
Message: Timestamp: 11/4/2014 9:35:46 PM
Message: 'Some message'.
WebConfig:-
<listeners>
<add name="DatabaseTraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=########"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=#######"
databaseInstanceName="LoggingDatabase" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory"
formatter="Text Formatter"
traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=#####"
template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="Error" name="Error">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</add>
<add switchValue="Information" name="Information">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</add>
<add switchValue="Warning" name="Warning">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</notProcessed>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</errors>
</specialSources>
Error record in log table looks like this
LogID: ######
EventID : 6352
Priority: -1
Severity: Error
Title :
Timestamp: 2014-11-10 00:55:51.770
MachineName : ########
AppDomainName: /LM/W3SVC/3/ROOT-######
ProcessID: 5272
ProcessName: c:\windows\system32\inetsrv\w3wp.exe
ThreadName: NULL
Win32ThreadId: 8852
Message :Tracing to LogSource 'All Events' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks. Summary for Enterprise Library Distributor Service:
====================================== --> Message: Timestamp:
FormattedMessage :
You are encountering an error logging to your database. But it seems that it is not totally catastrophic since it seems errors are being logged. This rules out a common cause such as invalid connection string.
You need to find out what the actual error is. To do this change the errors special source to log to a file (in a location with proper permissions). So add a flat file trace listener:
<listeners>
<add name="DatabaseTraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=########"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=6.0.0.0, Culture=neutral, PublicKeyToken=#######"
databaseInstanceName="LoggingDatabase" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory"
formatter="Text Formatter"
traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack" />
<add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="trace.log" />
</listeners>
and then set the error special source to use the flat file trace listener:
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category">
<listeners>
<add name="DatabaseTraceListener" />
</listeners>
</notProcessed>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
With that setting you should hopefully see the full details of the error.
Making the user tries to write the log as admin is the solution for this problem. UAC setting can also be changed to make the IIS user as admin.

jetty startup errors with signer information errors

Since I've set some maven dependencies to "provided" instead of "compile" scope I got this error when starting up jetty:
JEE5 application
should run on WebSphere 7 and Jetty 7
Spring 3
The error:
java.lang.SecurityException: class "javax.servlet.ServletRequestListener"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:806)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:625)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:386)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
at org.eclipse.jetty.server.handler.ContextHandler.setEventListeners(ContextHandler.java:554)
at org.eclipse.jetty.webapp.WebAppContext.setEventListeners(WebAppContext.java:946)
at org.eclipse.jetty.webapp.WebAppContext.addEventListener(WebAppContext.java:972)
at org.eclipse.jetty.webapp.TagLibConfiguration.preConfigure(TagLibConfiguration.java:492)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:418)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:256)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
at org.eclipse.jetty.server.Server.doStart(Server.java:260)
at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:511)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:364)
at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:516)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
The maven section is:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<artifactId>myApp.war</artifactId>
<!--name??-->
<parent>
<groupId>com.example</groupId>
<artifactId>myApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<properties>
<java-version>1.5</java-version>
<org.springframework-version>3.0.5.RELEASE</org.springframework-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.aspectj-version>1.6.9</org.aspectj-version>
<org.slf4j-version>1.6.1</org.slf4j-version>
<cxf.version>2.5.2</cxf.version>
<jetty.version>7.6.3.v20120416</jetty.version>
<skipTests>true</skipTests>
<log4j.version>1.2.15</log4j.version>
</properties>
<!-- … -->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<dependencies>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1</version>
<type>jar</type>
</dependency>
</dependencies>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
<connectors>
<connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
<port>8080</port>
<!-- this connector defaults to 1300 for some reason -->
</connector>
</connectors>
<!--
<useProvided>true</useProvided>
-->
</configuration>
</plugin>
Can't get the cause. Any hints welcome ;)
It looks as though you are including the servlet API as a provided dependency, and adding this to Jetty's classpath. This is colliding with Jetty's own bundled servlet API classes and causing the exception.
It is absolutely correct to include the servlet API as a provided dependency- the problem is in the <useProvided> parameter in the plugin configuration, which is adding the servlet API to the classpath. It would be better to exclude this, and, if you have any other dependencies with provided scope that aren't already in Jetty, then add them to the plugin dependencies, as you have done with commons-dbcp.
See also the comments in http://jira.codehaus.org/browse/JETTY-429, which discuss similar potential confusions.
I've had similar problem with javax.servlet because there were both 2.4 an 3.0.0 jar-versions in Eclipse Libraries/Maven Dependencies.
To fix it in Eclipse open project's pom.xml, Dependency hierarchy tab, filter by "servlet", choose (right mouse button) unnecessary 2.4(or 2.5) and "Exclude Maven Artifact ..." Thanks to Valery Gorbunov for the hint :)
I removed the
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1</version>
<type>jar</type>
</dependency>
in jetty and now it works...seems to another Logger implementation conflicts with commons-logging?! Didn't get the clue yet but for now...it works... Sometimes maven and java are not the best friends or I'm too stupid ;)

MS Test .orderedtest file details

I'm using scaffolding to dynamically generate UI tests with MS Test and Selenium. I've generated the selenium tests just fine and want to generate .orderedtest files to order the test.
The .orderedtest file is xml based:
<?xml version="1.0" encoding="UTF-8"?>
<OrderedTest name="CRUD_VendorRemark" storage="c:\users\mikeb\documents\visualstudio2010\projects\edimanagementqa\edimanagement.uitesting\orderedtests\crud_vendorremark.orderedtest" id="ca31cb3f-6802-46c5-9f17-53c3632b6681" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<TestLinks>
<TestLink id="d20974aa-59c6-fb5f-2567-dfff025078f2" name="CreateNew_Invalid_ErrorMessagePresent" storage="..\bin\debug\edimanagement.uitesting.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<TestLink id="2408cc97-59b6-7344-e5e1-0dd05592a6d8" name="CreateNew_Valid_SuccessMessagePresent" storage="..\bin\debug\edimanagement.uitesting.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<TestLink id="02528772-e3b7-3102-893c-808b3b8c50a8" name="Edit_LastItemInvalid_ErrorMessagePresent" storage="..\bin\debug\edimanagement.uitesting.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<TestLink id="1c215986-cfd9-9a57-9049-2f203199461f" name="Edit_LastItemValid_SuccessMessagePresent" storage="..\bin\debug\edimanagement.uitesting.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<TestLink id="16cd31fb-a73b-75b3-a886-48e4b0e4697b" name="Delete_LastItem_SuccessMessagePresent" storage="..\bin\debug\edimanagement.uitesting.dll" type="Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</TestLinks>
</OrderedTest>
It seems the individual test methods are being referenced by the id="guid", but I don't see it anywhere else in the project.
Any insight as to how the tests are being referenced?
Can the .orderedtest file be generated purely by writing xml?
They need to be loaded & resolved inside the test project. The ID is per-test type. if you look at a manual test, or other file based test type, you'll see theres a test ID guid element; it's pretty much a GUID.
However, for unit tests... well, thats a different conversation. I posted details here that should help you get to the end result that you need.