Index issues running jpa-server example with Elasticsearch 5.6.11

119 views
Skip to first unread message

kar...@doc.ai

unread,
Sep 9, 2018, 11:27:46 PM9/9/18
to HAPI FHIR
Hello,

I am trying to use the jpa-server example from https://github.com/jamesagnew/hapi-fhir/tree/master/hapi-fhir-jpaserver-example with Elasticsearch. 

I have set up in docker-compose as such:

version: '3.3'

services:
  elasticsearch:
    build: 
      context: .
      dockerfile: Dockerfile.elasticsearch
    environment:
      - "xpack.security.enabled=false"
    ports:
        - 9201:9200

  fhir:
    build: hapi-fhir-server
    links:
      - elasticsearch
    ports:
      - 8080:8080


The elasticsearch has the plugin installed:



WORKDIR /usr/share/elasticsearch

RUN bin/elasticsearch-plugin install analysis-phonetic

USER elasticsearch


I followed the instructions in the README and setup the Dockerfile for the server to do the following:

FROM maven:3.5-jdk-9-slim as base
USER root:root

ENV MAVEN_VERSION 3.5.4
ENV MAVEN_HOME /usr/lib/mvn
ENV PATH $MAVEN_HOME/bin:$PATH
  tar -zxvf apache-maven-$MAVEN_VERSION-bin.tar.gz && \
  rm apache-maven-$MAVEN_VERSION-bin.tar.gz && \
  mv apache-maven-$MAVEN_VERSION /usr/lib/mvn
  

WORKDIR /build
COPY pom.xml .
RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml dependency:resolve-plugins dependency:resolve 
COPY . .
RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml clean package
RUN mvn jetty:run
EXPOSE 8080



I updated the web.xml file to have 

<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>ca.uhn.fhir.jpa.demo.elasticsearch.FhirServerConfig</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

However I still seem to be having issues with the analyzers:

Caused by:
org.hibernate.search.exception.SearchException: HSEARCH400007: Elasticsearch request failed.|Request: PUT /ca.uhn.fhir.jpa.entity.resourcetable/ca.uhn.fhir.jpa.entity.ResourceTable/_mapping with parameters {}|Response: 400 'Bad Request' with body |{|  "error": {|    "root_cause": [|      {|        "type": "mapper_parsing_exception",|        "reason": "analyzer [standardAnalyzer] not found for field [myContentText]"|      }|    ],|    "type": "mapper_parsing_exception",|    "reason": "analyzer [standardAnalyzer] not found for field [myContentText]"|  },|  "status": 400|}|

What am I missing?? 

kar...@doc.ai

unread,
Sep 10, 2018, 2:34:02 PM9/10/18
to HAPI FHIR
After more investigations it looks like it is an issue with the entityManagerFactory bean:

WARN  o.s.w.c.s.AnnotationConfigWebApplicationContext [AbstractApplicationContext.java:558] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ca.uhn.fhir.jpa.demo.elasticsearch.FhirServerConfig: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: HAPI_PU] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.search.exception.SearchException: HSEARCH400020: Could not create mapping for entity type ca.uhn.fhir.jpa.entity.ResourceTable

Which is where the jpaProperties() runs the mapping manager

extraProperties.put(ElasticsearchEnvironment.ANALYSIS_DEFINITION_PROVIDER, ElasticsearchMappingProvider.class.getName());


Could it be because the Hibernate-search package was updated to 5.10.1-Final is there a way I can force the version to 5.6 as it seems to be what is in the docs. 

James Agnew

unread,
Sep 10, 2018, 2:50:52 PM9/10/18
to kar...@doc.ai, HAPI FHIR
Are you in a position to try the latest 3.5.0-SNAPSHOT build? We're now using 5.10.1 in that version.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/9bf32bd8-d343-455a-9ad0-bb8a46a1d8b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kartik Thakore

unread,
Sep 10, 2018, 2:52:40 PM9/10/18
to james...@gmail.com, hapi...@googlegroups.com
Hi James!

Thanks for the reply!

I was just using the git master. I just subtree'd the folder into my project. I can try using that version. How do I do that? 


For more options, visit https://groups.google.com/d/optout.


--

doc.ai is a blockchain based AI platform that enables deep learning computations on quantified biology to develop predictive analytics and personal health insights.

-- 
The information contained in this e-mail is for the exclusive use of the intended recipient(s) and may be confidential, proprietary, and/or legally privileged.  Inadvertent disclosure of this message does not constitute a waiver of any privilege.  If you receive this message in error, please do not directly or indirectly use, print, copy, forward, or disclose any part of this message.  Please also delete this e-mail and all copies and notify the sender.  Thank you.

kar...@doc.ai

unread,
Sep 10, 2018, 2:58:02 PM9/10/18
to HAPI FHIR
Oh one more thing below is my pom. I am now trying to force the version of Hibernate-Search. (I copied over the ca.uhn.fhir.jpa.search.ElasticsearchMappingProvider.java file). 

<modelVersion>4.0.0</modelVersion>

<!-- 
Note: HAPI projects use the "hapi-fhir" POM as their base to provide easy management. 
You do not need to use this in your own projects, so the "parent" tag and it's 
contents below may be removed 
if you are using this file as a basis for your own project. 
-->
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>hapi-fhir-jpaserver-example</artifactId>
<packaging>war</packaging>

<name>HAPI FHIR JPA Server - Example</name>

<repositories>
<repository>
<id>oss-snapshots</id>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-api</artifactId>
<version>${jetty_version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<version>${jetty_version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.5</version>
</dependency>
<!--
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.9</version>
</dependency>
-->

<!-- This dependency includes the core HAPI-FHIR classes -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>${project.version}</version>
</dependency>

<!-- At least one "structures" JAR must also be included -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>${project.version}</version>
</dependency>

<!-- This dependency includes the JPA server itself, which is packaged separately from the rest of HAPI FHIR -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-elasticsearch</artifactId>
<version>5.9.2.Final</version>
</dependency>

<!-- <dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-elasticsearch</artifactId>
<version>${project.version}</version>
</dependency> -->

<!-- This dependency is used for the "FHIR Tester" web app overlay -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>${project.version}</version>
<classifier>classes</classifier>
<scope>provided</scope>
</dependency>

<!-- HAPI-FHIR uses Logback for logging support. The logback library is included automatically by Maven as a part of the hapi-fhir-base dependency, but you also need to include a logging library. Logback 
is used here, but log4j would also be fine. -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>

<!-- Needed for JEE/Servlet support -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- If you are using HAPI narrative generation, you will need to include Thymeleaf as well. Otherwise the following can be omitted. -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
</dependency>

<!-- Used for CORS support -->
<dependency>
<groupId>org.ebaysf.web</groupId>
<artifactId>cors-filter</artifactId>
<exclusions>
<exclusion>
<artifactId>servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
</exclusions>
</dependency>

<!-- Spring Web is used to deploy the server to a web container. -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>

<!-- You may not need this if you are deploying to an application server which provides database connection pools itself. -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
</dependency>

<!-- This example uses Derby embedded database. If you are using another database such as Mysql or Oracle, you may omit the following dependencies and replace them with an appropriate database client 
dependency for your database platform. -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbynet</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
</dependency>

<!-- The following dependencies are only needed for automated unit tests, you do not neccesarily need them to run the example. -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.helger</groupId>
<artifactId>ph-schematron</artifactId>
<exclusions>
<exclusion>
<artifactId>Saxon-HE</artifactId>
<groupId>net.sf.saxon</groupId>
</exclusion>
</exclusions>
</dependency>

<!-- 
For some reason JavaDoc crashed during site generation unless we have this dependency
-->
<dependency>
    <groupId>javax.interceptor</groupId>
    <artifactId>javax.interceptor-api</artifactId>
    <scope>provided</scope>
</dependency>

</dependencies>

<build>

<!-- Tells Maven to name the generated WAR file as hapi-fhir-jpaserver-example.war -->
<finalName>hapi-fhir-jpaserver-example</finalName>

<!-- The following is not required for the application to build, but allows you to test it by issuing "mvn jetty:run" from the command line. -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webApp>
<contextPath>/hapi-fhir-jpaserver-example</contextPath>
<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
</webApp>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<!-- Tell Maven which Java source version you want to use -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

<!-- The configuration here tells the WAR plugin to include the FHIR Tester overlay. You can omit it if you are not using that feature. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Build-Time>${maven.build.timestamp}</Build-Time>
</manifestEntries>
</archive>
<overlays>
<overlay>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
</overlay>
</overlays>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>

<!-- This plugin is just a part of the HAPI internal build process, you do not need to incude it in your own projects -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>

<!-- This is to run the integration tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>


Kartik Thakore

unread,
Sep 10, 2018, 3:25:01 PM9/10/18
to HAPI FHIR
That worked!! 

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages