Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type null does not support undeclared extentions #299

am202 opened this Issue Feb 19, 2016 · 1 comment


None yet
2 participants
Copy link

am202 commented Feb 19, 2016

I'm working on a Location matching project, similar to what's described in the "Patient Matching using an MPI" section here:

Here's a simple provider that always returns the same Location:

public final class LocationProvider implements IResourceProvider {
    public final Class<Location> getResourceType() {
        return Location.class;

    public Bundle getMatches(final @RequiredParam(name = Location.SP_NAME) StringParam name, final @Count Integer count) {
        final Bundle bundle = new Bundle();
        final Location location = new Location();
        location.setId(new IdDt(1));
        location.setName("Sample Clinic");
        final Entry entry = new Entry();
        final EntrySearch search = new EntrySearch();
        search.setScore(new BigDecimal(0.8));
        search.addUndeclaredExtension(new ExtensionDt(false, "", new CodeDt("probable")));
        return bundle;

Here's a response:

<Bundle xmlns=""><id value="f61f6ddc-95e8-4ef9-a4cd-17c79bbb74f3"></id><meta><lastUpdated value="2016-02-19T12:04:02.616-05:00"></lastUpdated></meta><type value="searchset"></type><link><relation value="self"></relation><url value="http://localhost:8081/hapi-fhir/fhir/Location?name=Sample+Clinic&amp;_query=match"></url></link><entry><resource><Location xmlns=""><id value="1"></id><name value="Sample Clinic"></name></Location></resource><search><extension url=""><valueCode value="probable"></valueCode></extension><score value="0.8000000000000000444089209850062616169452667236328125"></score></search></entry></Bundle>SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

I tried running this code to invoke it:

    public interface LocationClient extends IRestfulClient {
        public List<Location> getMatches(final @RequiredParam(name = Location.SP_NAME) StringParam name, final @Count Integer count);

    private void run(final String url) {
        final FhirContext ctx = FhirContext.forDstu2();
        final LocationClient client = ctx.newRestfulClient(LocationClient.class, url);
        client.getMatches(new StringParam("Sample Clinic"), Integer.valueOf("5"));

I get this error:

Exception in thread "main" ca.uhn.fhir.parser.DataFormatException: DataFormatException at [Line number = 1
Column number = 562
System Id = null
Public Id = null
Location Uri= null
CharacterOffset = 561
]: Type null does not support undeclared extentions, and found an extension with URL:
    at ca.uhn.fhir.parser.XmlParser.doXmlLoop(
    at ca.uhn.fhir.parser.XmlParser.parseBundle(
    at ca.uhn.fhir.parser.XmlParser.parseBundle(
    at $Proxy12.getMatches(Unknown Source)
    at org.regenstrief.registry.fhir.RegistryFhirClient.run0(
    at org.regenstrief.registry.fhir.RegistryFhirClient.main(
Caused by: ca.uhn.fhir.parser.DataFormatException: Type null does not support undeclared extentions, and found an extension with URL:
    at ca.uhn.fhir.parser.ParserState$BaseState.enteringNewElementExtension(
    at ca.uhn.fhir.parser.ParserState.enteringNewElementExtension(
    at ca.uhn.fhir.parser.XmlParser.doXmlLoop(
    ... 11 more

My response looks valid to me. It also looks consistent with the sample response.

Do you see anything wrong with the response? Is something wrong with my server code?

The "Type null does not support" error seems strange to me. It's like it finds the extension but loses track of which element contains the extension, causing it to say "Type null".

I tried running a response through FhirContext.forDstu2().newXmlParser().parseResource manually, and that worked with no error. So maybe there's something slightly different about how the RESTful client parses it.

I'm using HAPI FHIR 1.4.


This comment has been minimized.

Copy link

jamesagnew commented Feb 29, 2016

Hi @am202 - I had a look at this and you're right, extensions in that position seem to cause an issue with the client.

I'm checking in a fix now, so this should work as of the next 1.5-SNAPSHOT build. Are you in a position to use snapshots?

One other thing to note though, you'll probably want to adjust your search method to return Bundle instead of List<Location> so that you can actually get to the extensions. The following method signature works for me as of 1.5:

        @Search(queryName = "match", type=Location.class)
        public Bundle getMatchesReturnBundle(final @RequiredParam(name = Location.SP_NAME) StringParam name, final @Count Integer count);

jamesagnew added a commit that referenced this issue Feb 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.