TcSession getting failed

0
Hi Team, I am working on integrating Teamcenter data with a third-party application using Mendix. I created services and utilized the POST operation to send data. In the microflow, I implemented a 'saved search query' to fetch the item ID from Teamcenter. However, when testing the setup through Swagger, I am getting a 'TCSession error.'In variable TcSession shows empty.   Error: integrity constraint violation: foreign key no parent ; "frn_tcconnector$teamcentersession_system$sessionid" table: "tcconnector$teamcentersession" value: 32651097299755679 stacktrace: Failed to commit    at TcConnector.UpdateSession (Change : 'Change 'TcSession' (TeamcenterSession)')    at TcConnector.RetrieveTcSessionBasedOnConfigName (SubMicroflow : 'UpdateSession')    at PL_Indent.SavedQuerySearch_R5PLIndentFormRevision_2 (SubMicroflow : 'RetrieveTcSessionBasedOnConfigName')    at PL_Indent.R5PLRequestFormRevision_SavedQueryR5PLIndenttFormRevision_2 (SubMicroflow : 'SavedQuerySearch_R5PLIndentFormRevision_2')    at PL_Indent.DS_R5PLIndentFormRevisionSearchCriteria_GetR5PLIndenttFormRevision_2 (SubMicroflow : 'R5PLRequestFormRevision_SavedQueryR5PLIndenttFormRevision_2') Advanced stacktrace:    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:83) Caused by:Failed to commit    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:83) Caused by:com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.basis.connectionbus.ConnectionBusException: Exception occurred while inserting data. (SQL State: 23503, Error Code: -177) Detail Message: org.hsqldb.HsqlException: integrity constraint violation: foreign key no parent ; "frn_tcconnector$teamcentersession_system$sessionid" table: "tcconnector$teamcentersession" value: 32651097299755679    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:83) Caused by:com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.basis.connectionbus.ConnectionBusException: Exception occurred while inserting data. (SQL State: 23503, Error Code: -177) Detail Message: org.hsqldb.HsqlException: integrity constraint violation: foreign key no parent ; "frn_tcconnector$teamcentersession_system$sessionid" table: "tcconnector$teamcentersession" value: 32651097299755679    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:83) Caused by:com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.basis.connectionbus.ConnectionBusException: Exception occurred while inserting data. (SQL State: 23503, Error Code: -177) Detail Message: org.hsqldb.HsqlException: integrity constraint violation: foreign key no parent ; "frn_tcconnector$teamcentersession_system$sessionid" table: "tcconnector$teamcentersession" value: 32651097299755679    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:83) Caused by:com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.basis.connectionbus.ConnectionBusException: Exception occurred while inserting data. (SQL State: 23503, Error Code: -177) Detail Message: org.hsqldb.HsqlException: integrity constraint violation: foreign key no parent ; "frn_tcconnector$teamcentersession_system$sessionid" table: "tcconnector$teamcentersession" value: 32651097299755679    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:83) Caused by:com.mendix.basis.connectionbus.ConnectionBusException: Exception occurred while inserting data. (SQL State: 23503, Error Code: -177) Detail Message: org.hsqldb.HsqlException: integrity constraint violation: foreign key no parent ; "frn_tcconnector$teamcentersession_system$sessionid" table: "tcconnector$teamcentersession" value: 32651097299755679    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:83) Caused by:Exception occurred while inserting data. (SQL State: 23503, Error Code: -177) Detail Message: org.hsqldb.HsqlException: integrity constraint violation: foreign key no parent ; "frn_tcconnector$teamcentersession_system$sessionid" table: "tcconnector$teamcentersession" value: 32651097299755679    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:83) Caused by:integrity constraint violation: foreign key no parent ; "frn_tcconnector$teamcentersession_system$sessionid" table: "tcconnector$teamcentersession" value: 32651097299755679    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:83) Caused by:integrity constraint violation: foreign key no parent ; "frn_tcconnector$teamcentersession_system$sessionid" table: "tcconnector$teamcentersession" value: 32651097299755679    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:83)      
asked
1 answers
1

Hi  Priyadharshini k,

 

The root cause is that the TcSession variable is either empty or not saving properly when used in microflows like UpdateSession or in save search queries. This usually happens when the session doesn’t exist in the database, hasn’t been committed yet, or has expired.

To fix this, make sure the session retrieval logic (like in RetrieveTcSessionBasedOnConfigName) checks if a valid session exists. If it doesn't, a new session is create using LoginToTeamcenter, then committed before moving forward.

It also helps to add logs to verify if the session is actually being retrieved. The key fix was always committing the TeamcenterSession before using it in any operation that depends on database relationships. This resolved the integrity constraint error and made the integration work smoothly.

 

Thanks 

Reemali

answered