4

I'm trying to implement Hibernate Search on my aws application. As usual, everything works great on localhost, but when upload to aws, I receive the following error:

org.hibernate.search.SearchException: Unable to create index directory: 
/usr/lucene/indexes for index com.myproject.domain.User

My Hibernate Search config:

<prop key="hibernate.search.default.directory_provider">filesystem</prop>
<prop key="hibernate.search.default.indexBase">/usr/lucene/indexes</prop>

I'm using EC2 + elastic beanstalk, linux with tomcat 7. I have windows on my local machine.

Should I create a directory named "/usr/lucene/indexes" on EC2 manually? Thanks.

raonirenosto
  • 1,507
  • 5
  • 19
  • 30

3 Answers3

6

Could it be that the app does not have the right permissions to create the base directory? Maybe best to create the base directory and give it the right permissions. AFAIK, Hibernate Search will try to create the full path though. If it is not a permission thing it would help to see the full stacktrace.

Hardy
  • 18,659
  • 3
  • 49
  • 65
  • I am not sure but doesn't Beanstalk create multiple EC2 instances in the background.If this is the case on which instance would you create the directory and how would you sync between filesystems on different machines – Abhishek Ranjan Apr 29 '15 at 19:45
  • No beanstalk does not create multiple instances. It creates only one. If you try to stop manually , it will re start automatically and it appears that it is creating multiple instances – vsingh Nov 30 '19 at 13:09
1

I had similar issues. Reason is tomcat does not have permission to create directories. If you look at eb activity log in beanstalk, directories are created and then tomcat is given permission.

  ++ /opt/elasticbeanstalk/bin/get-config container -k tomcat_version
  + TOMCAT_VERSION=8.5
  + '[' 8.5 == 8.5 ']'
  + TOMCAT_VERSION=8
  + TOMCAT_NAME=tomcat8
  + [[ -n true ]]
  + rm -rf /var/log/tomcat8
  + mkdir -p /var/log/tomcat8
  + chown -R tomcat:tomcat /var/log/tomcat8
  + /opt/elasticbeanstalk/bin/log-conf -ntomcat8 '-l/var/log/tomcat8/*'

So you should create a directory example var/myindex and give permissions

sudo chown tomcat:tomcat /var/myindex

In your code, change the path in persistence.xml to be this new path.

As a shortcut, if you try to comment out the index line, application will still try to create a directory and will still fail.

vsingh
  • 6,365
  • 3
  • 53
  • 57
0

FOR A WINDOWS USER

Give the permission to write on the folder where the server wants to create the required directory.

In my case, the server wants to create a folder in C:\Program Files\Java\jdk1.8.0_191 so I gave the permission to write for this folder.

P.S.: it might be a bad solution as its writing in the JAVA_HOME

Asad Shakeel
  • 1,949
  • 1
  • 23
  • 29