Do you have feedback on our new interface?
Do you have feedback on our new interface? Let us know HERE
Highlighted
mehedirony Trusted Contributor.
Trusted Contributor.
216 views

CM9.2 doesn't respond to any API calls after hosting in IIS in a REST API wrapper

Jump to solution

Hi Guys,

I have a CM9.2 application to insert data in CM9.2. The CM9.2 APIs are called through a RESTful Web API application.

Everything is working fine in the development environment. I have used Postman to perform GET and POST operations where the POST operation involves the methods to talk to CM9.2. However, when I hosted the application in local IIS, the following line is throwing an error straight away.

Database cm9Db = new Database();

The error message is: Object reference not set to an instance of an object.

I feel like something must be happening at the authentication level, but could not figure out how to resolve. Anonymous authentication is enabled in IIS.

Machine info:

OS: Windows 7 Professional.

IIS version: 7.5.

Application type: ASP.NET Web API.

Development IDE: Visual Studio 2017.

Any help would be much appreciated.

0 Likes
1 Solution

Accepted Solutions
mehedirony Trusted Contributor.
Trusted Contributor.

Re: CM9.2 doesn't respond to any API calls after hosting in IIS in a REST API wrapper

Jump to solution

Thank you Jan.

Along with your solution, David's reply from the following thread gave me the other option to solve this.

https://community.softwaregrp.com/t5/Content-Manager-User-Discussions/tsjApi-dll-error-when-loading-NetSDK/m-p/245003

I needed to enable 32-bit applications in IIS.

0 Likes
4 Replies
mehedirony Trusted Contributor.
Trusted Contributor.

Re: CM9.2 doesn't respond to any API calls after hosting in IIS in a REST API wrapper

Jump to solution

Some further stack trace if that might help:

 

{
"Message": "An error has occurred.",
"ExceptionMessage": "The type initializer for 'HP.HPTRIM.SDK.trimPINVOKE' threw an exception.",
"ExceptionType": "System.TypeInitializationException",
"StackTrace": " at HP.HPTRIM.SDK.trimPINVOKE.new_Database()\r\n at HP.HPTRIM.SDK.Database..ctor()\r\n at CARS_CM92_REST.Controllers.DefaultController.Get() in D:\\CARS\\CARS_CM9.2\\CARS_CM92_REST\\Controllers\\DefaultController.cs:line 14\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "The type initializer for 'SWIGExceptionHelper' threw an exception.",
"ExceptionType": "System.TypeInitializationException",
"StackTrace": " at HP.HPTRIM.SDK.trimPINVOKE.SWIGExceptionHelper..ctor()\r\n at HP.HPTRIM.SDK.trimPINVOKE..cctor()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "HP.HPTRIM.SDK.dll - Unable to load tsjApi.dll. Additional information follows.\nTrimApplication.TrimBinariesLoadPath: <not set>\nTrying assembly directory. Search path: C:\\Windows\\assembly\\GAC_MSIL\\HP.HPTRIM.SDK\\8.2.0.0__93ab772ef8ad9a2e\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\Windows\\assembly\\GAC_MSIL\\HP.HPTRIM.SDK\\8.2.0.0__93ab772ef8ad9a2e\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\Windows\\assembly\\GAC_MSIL\\HP.HPTRIM.SDK\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\Windows\\assembly\\GAC_MSIL\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\Windows\\assembly\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\Windows\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\tsjApi.dll . File does not exist.\nTrying PATH entries. Search path: C:\\Program Files (x86)\\Hewlett Packard Enterprise\\Content Manager\\tsjApi.dll . Error: %1 is not a valid Win32 application\nNote: This error is most likely due to an x86/x64 architecture mismatch.\n",
"ExceptionType": "System.Exception",
"StackTrace": " at ModuleInitializer.LoadNativeDlls()\r\n at ModuleInitializer.Initialize()\r\n at HP.HPTRIM.SDK.TrimApplicationBase.Initialize()\r\n at HP.HPTRIM.SDK.trimPINVOKE.SWIGExceptionHelper..cctor()"
}
}
}

0 Likes
mehedirony Trusted Contributor.
Trusted Contributor.

Re: CM9.2 doesn't respond to any API calls after hosting in IIS in a REST API wrapper

Jump to solution

After I used the following line

TrimApplicationBase.Initialize();

The stack trace is like the following:

{
"Message": "An error has occurred.",
"ExceptionMessage": "HP.HPTRIM.SDK.dll - Unable to load tsjApi.dll. Additional information follows.\nTrimApplication.TrimBinariesLoadPath: <not set>\nTrying assembly directory. Search path: C:\\Windows\\assembly\\GAC_MSIL\\HP.HPTRIM.SDK\\8.2.0.0__93ab772ef8ad9a2e\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\Windows\\assembly\\GAC_MSIL\\HP.HPTRIM.SDK\\8.2.0.0__93ab772ef8ad9a2e\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\Windows\\assembly\\GAC_MSIL\\HP.HPTRIM.SDK\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\Windows\\assembly\\GAC_MSIL\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\Windows\\assembly\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\Windows\\tsjApi.dll . File does not exist.\nTrying parent directories of assembly directory. Search path: C:\\tsjApi.dll . File does not exist.\nTrying PATH entries. Search path: C:\\Program Files (x86)\\Hewlett Packard Enterprise\\Content Manager\\tsjApi.dll . Error: %1 is not a valid Win32 application\nNote: This error is most likely due to an x86/x64 architecture mismatch.\n",
"ExceptionType": "System.Exception",
"StackTrace": " at ModuleInitializer.LoadNativeDlls()\r\n at ModuleInitializer.Initialize()\r\n at HP.HPTRIM.SDK.TrimApplicationBase.Initialize()\r\n at CARS_CM92_REST.Controllers.DefaultController.Get() in D:\\CARS\\CARS_CM9.2\\CARS_CM92_REST\\Controllers\\DefaultController.cs:line 14\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}

0 Likes
JanMartin Outstanding Contributor.
Outstanding Contributor.

Re: CM9.2 doesn't respond to any API calls after hosting in IIS in a REST API wrapper

Jump to solution

Make sure your build is targeting a specific bit-ness (e.g. x64 instead of Any CPU) and you are referencing the right bit-ness TRIM dlls

See here for how to resolve the DLL reference properly: https://github.com/HPECM/Community/tree/master/Samples/SDK/CSharp/SDKLocationResolver

mehedirony Trusted Contributor.
Trusted Contributor.

Re: CM9.2 doesn't respond to any API calls after hosting in IIS in a REST API wrapper

Jump to solution

Thank you Jan.

Along with your solution, David's reply from the following thread gave me the other option to solve this.

https://community.softwaregrp.com/t5/Content-Manager-User-Discussions/tsjApi-dll-error-when-loading-NetSDK/m-p/245003

I needed to enable 32-bit applications in IIS.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.