Skip to content

Troubleshooting

Common issues and solutions when using FHIR Frog.

Server Connection Issues

Connection Refused

Problem:

Connection refused: http://localhost:8080/fhir

Solutions:

  1. Check server is running:

    curl http://localhost:8080/fhir/metadata
    

  2. Verify URL:

    @FhirServerUrl("http://localhost:8080/fhir")  // Correct
    @FhirServerUrl("http://localhost:8080")       // Missing /fhir
    

  3. Check Testcontainers:

    @DynamicFhirServerUrl
    static String getUrl() {
        return "http://localhost:" + fhirServer.getMappedPort(8080) + "/fhir";
    }
    

Timeout

Problem:

Read timed out after 30000ms

Solutions:

  1. Increase timeout:

    FhirContext ctx = FhirContext.forR4();
    ctx.getRestfulClientFactory().setSocketTimeout(60000);
    

  2. Wait for server readiness:

    @Container
    static GenericContainer<?> server = new GenericContainer<>(...)
        .waitingFor(Wait.forHttp("/fhir/metadata")
            .withStartupTimeout(Duration.ofMinutes(2)));
    

TestScript Errors

Resource Not Found

Problem:

TestScript not found: classpath:fhir/test.json

Solutions:

  1. Check file location:

    src/test/resources/fhir/test.json  ✓
    src/test/resources/test.json       ✗
    

  2. Verify classpath prefix:

    @TestScript("classpath:fhir/test.json")  // Correct
    @TestScript("fhir/test.json")            // Missing classpath:
    

Invalid TestScript

Problem:

Invalid TestScript: Missing required field 'status'

Solution:

{
  "resourceType": "TestScript",
  "status": "draft",  // Required
  "name": "Test"      // Required
}

Variable Extraction Issues

Variable Not Found

Problem:

Variable 'patientId' not found

Solutions:

  1. Extract before using:

    * operation create Patient from patient as response
    * variable patientId = Patient.id from response  // Extract first
    * operation read Patient/${patientId}            // Then use
    

  2. Check sourceId:

    * variable patientId = Patient.id from createResponse  // Must match responseId
    

Empty Variable

Problem:

Variable 'patientId' is empty

Solutions:

  1. Validate extraction:

    * operation create Patient from patient as response
    * assert expression = "Patient.id.exists()"  // Validate first
    * variable patientId = Patient.id from response
    

  2. Check FHIRPath:

    # Correct
    * variable id = Patient.id
    
    # Wrong
    * variable id = Patient.identifier  // Returns array, not string
    

Assertion Failures

Response Code Mismatch

Problem:

Expected: 201, Actual: 400

Solutions:

  1. Check request body:

    * operation create Patient from patient
    * assert responseCode = 400  // If expecting error
    

  2. Validate resource:

    * operation validate Patient from patient
    * assert expression = "OperationOutcome.issue.where(severity='error').empty()"
    

FHIRPath Errors

Problem:

FHIRPath evaluation failed: Unknown function 'contains'

Solutions:

  1. Use correct syntax:

    # Correct
    * assert expression = "Patient.name.family = 'Smith'"
    
    # Wrong
    * assert expression = "Patient.name.family.contains('Smith')"  // Use matches()
    

  2. Check resource type:

    * assert resource = Patient  // Validates resource type first
    * assert expression = "Patient.name.exists()"
    

Fixture Issues

Fixture Not Found

Problem:

Fixture 'patient' not found

Solutions:

  1. Define fixture:

    Fixture: patient from "patient.json"
    
    Test: "Create patient"
      * operation create Patient from patient  // Now available
    

  2. Check file path:

    src/test/resources/fhir/patient.json  ✓
    src/test/resources/patient.json       ✗
    

Invalid Fixture

Problem:

Invalid fixture: Not a valid FHIR resource

Solution:

{
  "resourceType": "Patient",  // Required
  "name": [{"family": "Smith"}]
}

TestPlan Issues

Circular Dependency

Problem:

Circular dependency detected: PlanA -> PlanB -> PlanA

Solution:

Restructure TestPlans to avoid cycles:

# Before (circular)
PlanA depends on PlanB
PlanB depends on PlanA

# After (hierarchical)
PlanA depends on PlanC
PlanB depends on PlanC

TestPlan Not Found

Problem:

TestPlan 'TestPlan/suite' not found

Solutions:

  1. Check reference format:

    @TestPlan("TestPlan/suite")  // Correct
    @TestPlan("suite")            // Missing TestPlan/ prefix
    

  2. Verify TestPlan exists:

    curl http://localhost:8080/fhir/TestPlan/suite
    

Build Issues

Maven Plugin Not Found

Problem:

Plugin 'fhir-frog-maven-plugin' not found

Solution:

Add plugin repository:

<pluginRepositories>
    <pluginRepository>
        <id>gitlab</id>
        <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url>
    </pluginRepository>
</pluginRepositories>

Dependency Conflicts

Problem:

Conflicting HAPI FHIR versions

Solution:

Use dependency management:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>ca.uhn.hapi.fhir</groupId>
            <artifactId>hapi-fhir-bom</artifactId>
            <version>6.4.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Testcontainers Issues

Container Won't Start

Problem:

Container failed to start

Solutions:

  1. Check Docker:

    docker ps
    docker info
    

  2. Increase timeout:

    @Container
    static GenericContainer<?> server = new GenericContainer<>(...)
        .withStartupTimeout(Duration.ofMinutes(5));
    

  3. Check logs:

    System.out.println(fhirServer.getLogs());
    

Port Already in Use

Problem:

Port 8080 is already in use

Solution:

Use dynamic ports:

@Container
static GenericContainer<?> server = new GenericContainer<>(...)
    .withExposedPorts(8080);  // Docker assigns random host port

@DynamicFhirServerUrl
static String getUrl() {
    return "http://localhost:" + server.getMappedPort(8080) + "/fhir";
}

Performance Issues

Slow Tests

Solutions:

  1. Reuse containers:

    @Container
    static GenericContainer<?> server = new GenericContainer<>(...)
        .withReuse(true);
    

  2. Use persistent server:

    ./start-test-server.sh
    mvn test -Dfhir.server.url=http://localhost:8080/fhir
    

  3. Parallel execution:

    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <parallel>classes</parallel>
            <threadCount>4</threadCount>
        </configuration>
    </plugin>
    

Memory Issues

Problem:

OutOfMemoryError: Java heap space

Solutions:

  1. Increase heap:

    export MAVEN_OPTS="-Xmx2g"
    mvn test
    

  2. Limit test scope:

    mvn test -Dtest=PatientTests
    

Getting Help

Debug Mode

Enable verbose logging to see detailed execution:

mvn test -X

Report Issues

Found a bug? Report it on GitLab Issues

Enable Debug Logging

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.4.14</version>
    <scope>test</scope>
</dependency>
<!-- logback-test.xml -->
<configuration>
    <logger name="org.fhirfrog.frog" level="DEBUG"/>
    <logger name="ca.uhn.fhir" level="INFO"/>
</configuration>

Next Steps