Deploy WAR file to Tomcat 8.5 and got PersistenceException

1,176 views
Skip to first unread message

James REN

unread,
Nov 4, 2016, 3:26:39 PM11/4/16
to HAPI FHIR

Dear all,


I have build a hapi-fhir-jpaserver with MySQL locally (based on your hapi-fhir-jpaserver-example fromhttps://github.com/jamesagnew/hapi-fhir/tree/master/hapi-fhir-jpaserver-example). I can successfully run the server by using command mvn jetty:run ; however, after I deployed the WAR file to Apache Tomcat/8.5.5, the server cannot be started and I got the following error in the log file:

04-Nov-2016 15:17:31.881 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ca.uhn.fhir.jpa.demo.FhirServerConfig: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: HAPI_PU] Unable to build Hibernate SessionFactory

Please see localhost_2016-11-04.txt for the complete log. Thank you.


Best,
Ren

Kevin Mayfield

unread,
Nov 4, 2016, 4:13:39 PM11/4/16
to James REN, HAPI FHIR
Your fault is further down the log. It's a problem with your lucene directory. It can create the target folder (within tomcat folders), change it to point to another location or change permissions?

	... 42 more
Caused by: org.hibernate.search.exception.SearchException: Unable to create index directory: target/lucenefiles for index ca.uhn.fhir.jpa.entity.ResourceTable
	at 


Sent from my iPhone
--
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/8d27f58e-bbdc-4eeb-afe5-7a6f1f82f7f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James REN

unread,
Nov 4, 2016, 5:54:18 PM11/4/16
to HAPI FHIR, rqg...@gmail.com
I did not see that. Nice catch! Thanks a lot!

ansuman.bes...@gmail.com

unread,
Nov 30, 2016, 2:34:01 AM11/30/16
to HAPI FHIR, rqg...@gmail.com
Hii, 

I am facing the same issue ; but how to exactly fix this issue. 
Caused by: org.hibernate.search.exception.SearchException: Unable to create index directory: target/lucenefiles for index ca.uhn.fhir.jpa.entity.TermConcept

Kevin Mayfield

unread,
Nov 30, 2016, 3:21:33 AM11/30/16
to ansuman.bes...@gmail.com, HAPI FHIR, James REN
You need to alter your JPA config. Mine is in a file called FhirServerConfigStu3 - it will have a properties section like this

private Properties jpaProperties() {
Properties extraProperties = new Properties();
extraProperties.put("hibernate.dialect",  env.getProperty("hibernate.dialect"));
//extraProperties.put("hibernate.dialect", org.hibernate.dialect.SQLServerDialect.class.getName());
extraProperties.put("hibernate.format_sql", "true");
extraProperties.put("hibernate.show_sql", env.getProperty("hibernate.show_sql"));
extraProperties.put("hibernate.hbm2ddl.auto", "update");
extraProperties.put("hibernate.jdbc.batch_size", "20");
extraProperties.put("hibernate.cache.use_query_cache", "false");
extraProperties.put("hibernate.cache.use_second_level_cache", "false");
extraProperties.put("hibernate.cache.use_structured_entries", "false");
extraProperties.put("hibernate.cache.use_minimal_puts", "false");
extraProperties.put("hibernate.search.default.directory_provider", "filesystem");
// needed to set properties of this directory sudo chmod -R 777 .
extraProperties.put("hibernate.search.default.indexBase", "/Development/lucene/stu3/indexes");
extraProperties.put("hibernate.search.lucene_version", "LUCENE_CURRENT");
//extraProperties.put("hibernate.connection.driver.class",
// env.getProperty("jdbc.Driver"));

return extraProperties;
}

You either need to change the folder location or change the permissions of this folder.


--
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+unsubscribe@googlegroups.com.

To post to this group, send email to hapi...@googlegroups.com.

ansuman.bes...@gmail.com

unread,
Nov 30, 2016, 4:42:57 AM11/30/16
to HAPI FHIR, ansuman.bes...@gmail.com, rqg...@gmail.com
Do I have to create a directory like root/Development/lucene/stu3/indexes manually and add the properties

Kevin Mayfield

unread,
Nov 30, 2016, 5:54:31 AM11/30/16
to ansuman.bes...@gmail.com, HAPI FHIR, James REN
If you've used the git hub version. It's this file you'd need to alter on your version


Where you place the lucene index is upto you.

Alternatively you can change the permissions of the directory 

On 30 November 2016 at 09:42, <ansuman.bes...@gmail.com> wrote:
Do I have to create a directory like root/Development/lucene/stu3/indexes manually and add the properties

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.

ansuman.bes...@gmail.com

unread,
Nov 30, 2016, 6:10:36 AM11/30/16
to HAPI FHIR, ansuman.bes...@gmail.com, rqg...@gmail.com
extraProperties.put("hibernate.search.default.indexBase", "target/lucenefiles");

This is what i have originally from hapi-fhir jpa server example; how i could give access to it
 sudo chmod -R 777 target/lucenefiles
It is showing that no directory exists

ansuman.bes...@gmail.com

unread,
Nov 30, 2016, 6:48:04 AM11/30/16
to HAPI FHIR, ansuman.bes...@gmail.com, rqg...@gmail.com
And when I change the directory it is throwing this error

Caused by: org.hibernate.search.exception.SearchException: Unable to initialize index: ca.uhn.fhir.jpa.entity.TermConcept: /root/lucene/indexes is a file.
but this root/lucene/indexes is a directory
 

James Agnew

unread,
Nov 30, 2016, 6:55:07 AM11/30/16
to ansuman.bes...@gmail.com, HAPI FHIR, James REN
Try deleting the indexes directory, but ensuring that the parent directory exists and is writeable by your tomcat user.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.

ansuman.bes...@gmail.com

unread,
Nov 30, 2016, 7:52:34 AM11/30/16
to HAPI FHIR
It's working after setting the path like 

extraProperties.put("hibernate.search.default.indexBase", "/var/lib/tomcat7/webapps/hapi-fhir-jpaserver-example/indexes");



Reply all
Reply to author
Forward
0 new messages