hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.03k stars 1.33k forks source link

PUT new ValueSet resource with given ID: No EntityManager available #1594

Open WaldekPac opened 4 years ago

WaldekPac commented 4 years ago

Describe the bug I uses BaseJavaConfigR4 configuration with spring boot and mysql database.

When using hapi fhir put transaction with ValueSet resource then I get HTTP 500 with message:

Error: HTTP 500 : Failed to call access method: org.springframework.dao.InvalidDataAccessApiUsageException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call; nested exception is javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call

To Reproduce PUT ValueSet resource with ID=TestValueSet to Hapifhir Server Example request body: { "resourceType": "ValueSet", "id": "TestValueSet", "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">ValueSet</div>" }, "url": "https://example.com/fhir/ValueSet/TestValueSet", "name": "TestValueSet", "status": "active", "compose": { "include": [ { "system": "https://example.com/fhir/CodeSystem/TestCodeSystem" } ] } }

Expected behavior New ValueSet resource with given ID was stored.

Screenshots

2019-11-19 13_21_29-Results - HAPI FHIR

Environment (please complete the following information):

thanks in advance,

Waldek

WaldekPac commented 4 years ago

Logs from server

Caused by: javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:292) ~[spring-orm-5.1.7.RELEASE.jar:5.1.7.RELEASE] at com.sun.proxy.$Proxy157.persist(Unknown Source) ~[na:na] at ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.updateEntity(BaseHapiFhirDao.java:1025) ~[hapi-fhir-jpaserver-base-4.1.0.jar:na]

furqann commented 4 years ago

Hi, Team

Following error has been happening on server(http://hapi.fhir.org/resource?serverId=home_r4&pretty=true&resource=Patient) since it has come back online. Either you do search, read etc its happening on all operations. Any details?

Warning! Error: HTTP 500 Server Error: Failed to call access method: org.springframework.dao.InvalidDataAccessApiUsageException: Timer already cancelled.; nested exception is java.lang.IllegalStateException: Timer already cancelled.

Thanks!

furqann commented 4 years ago

Hi, Team

Following error has been happening on server(http://hapi.fhir.org/resource?serverId=home_r4&pretty=true&resource=Patient) since it has come back online. Either you do search, read etc its happening on all operations. Any details?

Warning! Error: HTTP 500 Server Error: Failed to call access method: org.springframework.dao.InvalidDataAccessApiUsageException: Timer already cancelled.; nested exception is java.lang.IllegalStateException: Timer already cancelled.

Thanks!

Issue seems to be resolved now. Server is perfectly working. Thanks

WaldekPac commented 4 years ago

This error also occurs in HAPI FHIR version 4.2.0.

To Reproduce

  1. Checkout from github hapifhir in 4.2.0 version or master.

  2. On local machine run SampleJpaRestfulServerApplication from 4.2.0 version.

  3. SET hapi.fhir.version=R4

  4. Send PUT HTTP request to local server:

URL: http://localhost:8080/fhir/ValueSet/TestValueSet

REQUEST HTTP-HEADERS Content-Type: application/json

REQUEST BODY

{
  "resourceType": "ValueSet",
  "id": "TestValueSet",
  "meta": {
    "versionId": "1",
    "lastUpdated": "2020-02-25T11:13:33.664+01:00"
  },
  "text": {
    "status": "generated",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">ValueSet</div>"
  },
  "url": "https://example.com/fhir/ValueSet/TestValueSet",
  "name": "TestValueSet",
  "status": "active",
  "compose": {
    "include": [
      {
        "system": "https://example.com/fhir/CodeSystem/TestCodeSystem"
      }
    ]
  }
}

RESPONSE STSTUS: 500Internal Server Error

RESPONSE BODY:

{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "processing",
      "diagnostics": "Failed to call access method: org.springframework.dao.InvalidDataAccessApiUsageException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call; nested exception is javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call"
    }
  ]
}

This problem was described also on hapi-fhir google groups

https://groups.google.com/forum/#!topic/hapi-fhir/Hm2I3UPACCw

WaldekPac commented 4 years ago

In commit e05ea676 the request works perfectly.

WaldekPac commented 4 years ago

For R4 this problem was introduced in commit revision 27257976.

jamesagnew commented 4 years ago

I'm not able to replicate this on hapi.fhir.org, which suggests this is probably something specific to Spring Boot (see http://hapi.fhir.org/baseR4/ValueSet/TestValueSet )

The boot components are a community contribution and I don't use boot personally so I'm not sure what would be causing it. Patches welcome.

WaldekPac commented 4 years ago

Thank you for your response.

What configuration do you use on the http://hapi.fhir.org/baseR4 server?

jamesagnew commented 4 years ago

The source for the public server is available here: https://github.com/jamesagnew/hapi-fhir/tree/master/hapi-fhir-jpaserver-uhnfhirtest

The recommended way of using the JPA server however is with this project: https://github.com/hapifhir/hapi-fhir-jpaserver-starter

Cheers, James

On Tue, Mar 3, 2020 at 8:46 AM WaldekPac notifications@github.com wrote:

Thank you for your response.

What configuration do you use on the http://hapi.fhir.org/baseR4 server?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jamesagnew/hapi-fhir/issues/1594?email_source=notifications&email_token=AA2N7HIAUHD4F3WT4NQQ4ATRFUC2BA5CNFSM4JPCSXCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENTRGKA#issuecomment-593957672, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2N7HJOBNHU2SQMVU73IUDRFUC2BANCNFSM4JPCSXCA .