Sequence contains more than one matching element on endpoint

Discussions relating to the REST API of Jiwa 7.

Re: Sequence contains more than one matching element on endp

Postby sameermoin » Wed Apr 05, 2023 7:12 pm

I can't share the whole plugin code here. secondly, I removed all rest endpoints from the custom plugin, and the Plugin exception policy is already settled to report but it's not printing anything in the event viewer.
sameermoin
Regular Contributor
Regular Contributor
 
Posts: 75
Joined: Wed Jun 15, 2022 4:02 am
Topics Solved: 1

Re: Sequence contains more than one matching element on endp

Postby Mike.Sheen » Thu Apr 06, 2023 10:36 am

sameermoin wrote:I can't share the whole plugin code here. secondly, I removed all rest endpoints from the custom plugin, and the Plugin exception policy is already settled to report but it's not printing anything in the event viewer.


Do you have the Debug Mode system setting checked?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Sequence contains more than one matching element on endp

Postby Mike.Sheen » Thu Apr 06, 2023 10:51 am

sameermoin wrote:I can't share the whole plugin code here. secondly, I removed all rest endpoints from the custom plugin, and the Plugin exception policy is already settled to report but it's not printing anything in the event viewer.


The Exception Policy for plugins only applies to when compiling or loading the plugin - it's purpose is to allow you to chose which plugins can block the login process by setting that to Abort, signaling that the plugin is critical and if it cannot compile or load then to prevent login. An Exception Policy of Report will log the error(s) which occurred during compile or load of the plugin to the event log, or in the case of the Jiwa.exe application it will show in the diagnostics dialog after login.

The DebugMode system setting of the REST API plugin, however - which is what I asked you to turn on - will include the exception stack trace in responses. It still won't log the exception to event log.

If you can get the stack trace for the exception, then you should be able to get a better idea of the source of the exception.

The message you are getting is typically thrown by a Linq expression which is returning multiple results when only one is expected - which would probably occur if your custom plugin added a route whose path already matched a route in our standard plugin, for example.

You also should be able to isolate the problem though a process of refinement by gradually removing code from your plugin and testing after each change. By doing this you'll eventually either find and solve the problem, or end up with a plugin you can share here for us to analyse and provide guidance on. This is troubleshooting 101, and I'm a little surprised you've not already gone down this path.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Sequence contains more than one matching element on endp

Postby sameermoin » Thu Apr 06, 2023 9:15 pm

Hi, I am still working on it. I have already done testing by isolating code sections but it's very hard to know which part is causing this issue. I noticed sometimes it starts occurring from the first request I hit when I restart the IIS server but sometime it occurs after some time.

Here I am getting one error repeatedly on the IIS server. I disabled the custom plugins but still getting this

error.png


error2.png
sameermoin
Regular Contributor
Regular Contributor
 
Posts: 75
Joined: Wed Jun 15, 2022 4:02 am
Topics Solved: 1

Re: Sequence contains more than one matching element on endp

Postby SBarnes » Fri Apr 07, 2023 9:10 am

Although I've not got much experience in using the API under IIS, the self hosted service is much easier, that error is related to database connections, can you confirm that the version of Jiwa in terms of service release installed on the machine matches to what is under IIS, you may find setting up the IIS part again from scratch may solve your issue as I have seen running in a service release and not updating the IIS part can cause some weird issues.

On this issue you may find it worth trying first running the self hosted service and seeing if you get the same issues as it runs out of the actual Jiwa program directory where IIS does not and this would at least narrow down if the problem is only IIS related.

Also list the service release you are using as well as the REST API plugin version so that it can be confirmed that they match.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Sequence contains more than one matching element on endp

Postby sameermoin » Fri Apr 07, 2023 11:22 am

The Jiwa Version is 7.2.1.0 Service Release 13
The REST API plugin version is 7.2.1.32
sameermoin
Regular Contributor
Regular Contributor
 
Posts: 75
Joined: Wed Jun 15, 2022 4:02 am
Topics Solved: 1

Re: Sequence contains more than one matching element on endp

Postby sameermoin » Tue Feb 27, 2024 8:08 am

Encountering the same issue, but this time with the JiwaAPISelfHost service, I've checked the endpoints, and they appear to be unique. I'm using Rest API Plugin Version 7.2.1.52. After adding the following code snippet to the Configuration Method in the REST API plugin:

Code: Select all
AppHost.ServiceExceptionHandlers.Add((httpReq, request, exception) =>
{
WriteLog("Exception Occurred: " + exception.StackTrace, System.Diagnostics.EventLogEntryType.Error);
return null;
});

AppHost.UncaughtExceptionHandlers.Add((req, res, operationName, ex) =>
{
WriteLog("Exception Occurred: " + ex.Message, System.Diagnostics.EventLogEntryType.Error);
});


I'm receiving the following exception stack trace when hitting any endpoint. The noticeable thing is that when we restart the service, it starts working. However, after some time, we encounter the same exception when accessing any endpoint.

Code: Select all
Error CodeExceptionMessagePlugin '' caused an exception 'Sequence contains more than one matching element'Stack Traceat JiwaFinancials.Jiwa.JiwaApplication.Manager.HandleApplicationManagerPluginExceptions() at JiwaFinancials.Jiwa.JiwaApplication.Manager._Lambda$__379-26() at JiwaFinancials.Jiwa.JiwaApplication.StartupLog.Add(String Description, Action CallbackMethod) at JiwaFinancials.Jiwa.JiwaApplication.Manager.Logon(String ServerName, String DatabaseName, AuthenticationModes AuthenticationMode, String JiwaUserName, String JiwaPassword, Boolean IsAPIKey) at JiwaFinancials.Jiwa.JiwaApplication.Manager.Logon(String ServerName, String DatabaseName, String APIKey) at JiwaFinancials.Jiwa.JiwaServiceModel.JiwaApiKeyAuthProvider.Authenticate(IServiceBase authService, IAuthSession session, Authenticate request) in c:\ProgramData\Jiwa Financials\Jiwa 7\7.2.1\SYSTEM\Plugins\apiuser\Compile\REST API\REST API.cs:line 3261 at ServiceStack.Auth.AuthenticateService.Authenticate(Authenticate request, String provider, IAuthSession session, IAuthProvider oAuthConfig) at ServiceStack.Auth.AuthenticateService.Post(Authenticate request) at JiwaFinancials.Jiwa.JiwaServiceModel.JiwaApiKeyAuthProvider.PreAuthenticateWithApiKey(IRequest req, IResponse res, v_APIKey apiKey) in c:\ProgramData\Jiwa Financials\Jiwa 7\7.2.1\SYSTEM\Plugins\apiuser\Compile\REST API\REST API.cs:line 3391 at JiwaFinancials.Jiwa.JiwaServiceModel.JiwaApiKeyAuthProvider.PreAuthenticate(IRequest req, IResponse res) in c:\ProgramData\Jiwa Financials\Jiwa 7\7.2.1\SYSTEM\Plugins\apiuser\Compile\REST API\REST API.cs:line 3334 at ServiceStack.AuthenticateAttribute.PreAuthenticate(IRequest req, IEnumerable`1 authProviders) at ServiceStack.AuthenticateAttribute.<ExecuteAsync>d__12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ServiceStack.ServiceStackHost.<ApplyRequestFiltersSingleAsync>d__317.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ServiceStack.ServiceStackHost.<ApplyRequestFiltersAsync>d__316.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ServiceStack.Host.RestHandler.<ProcessRequestAsync>d__14.MoveNext()


Additionally, I am unable to attach the images in the attachment. I'm also getting an error saying, 'The uploaded file is empty.
sameermoin
Regular Contributor
Regular Contributor
 
Posts: 75
Joined: Wed Jun 15, 2022 4:02 am
Topics Solved: 1

Re: Sequence contains more than one matching element on endp

Postby Nina@Opal » Tue Feb 27, 2024 11:21 am

Just further to this issue seems to occur when a user opens a sales order for picking in ASPluris. Up until that time everything worked perfectly.

BACKGROUND
1. REST API service was running without issues on SR13, REST API v7.2.1.32, REST API - ASPluris v1.12
2. Client was upgraded to SR17 REST API v7.2.1.52, REST API - ASPluris v1.2. At this point we started getting errors with the API.
3. When we restart the API service our API calls are successful. Once a user logs into ASPluris, go to Dispatch and pick an order the API fails. ASPluris continues to work without any issues but our custom integration fails.
4. From the event viewer we know when a user has connected to a sales order because multiple Jiwa7 error occur. I cannot add an image to this post so have added the following error from the event view which is appearing on the standard Jiwa pantry list plugin.

Code: Select all
The description for Event ID 0 from source Jiwa 7 cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

[JiwaApplication, Version=7.2.1.0, Culture=neutral, PublicKeyToken=e30ce81e37f29c8c], [JiwaFinancials.Jiwa.JiwaApplication.Manager].[Logon]Plugin 'Pantry List' encountered an exception when compiling or loading during logon. Exception Message: 'System.InvalidOperationException: ExecuteReader: Connection property has not been initialized.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at JiwaFinancials.Jiwa.JiwaApplication.Plugin.Reference.ResolveReference()'

the message resource is present but the message is not found in the string/message table
Nina@Opal
I'm new here
I'm new here
 
Posts: 5
Joined: Wed Sep 22, 2021 8:31 am

Re: Sequence contains more than one matching element on endp

Postby SBarnes » Tue Feb 27, 2024 12:04 pm

This could possibly be your problem there is a change between SR13 and SR17 in how to get the manager it should now be done like this

Code: Select all
 using (JiwaFinancials.Jiwa.JiwaApplication.Manager manager = Request.GetManager())
 {
}


as opposed to previously as

Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Manager manager = this.GetManager();


This is documented under SR15s release notes https://jiwa.atlassian.net/wiki/spaces/ ... Release+15 under potential breaking changes.

You should also make sure you are using the api plugin that will be in JiwaApi.zip in the program directory after the SR is installed.

You may also want to check that you have an assembly resolver hooked up in any custom plugins that are for the rest api.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Sequence contains more than one matching element on endp

Postby Nina@Opal » Tue Feb 27, 2024 2:28 pm

We were aware of the breaking changes with SR15 so accommodated for that.
The REST API plugin implemented was from the JiwaAPI.zip folder for SR17.
And yes we have hooked in the assembly resolver to our plugin.
Nina@Opal
I'm new here
I'm new here
 
Posts: 5
Joined: Wed Sep 22, 2021 8:31 am

PreviousNext

Return to REST API

Who is online

Users browsing this forum: No registered users and 6 guests