0

Running Wildfly 9.0.2 on Ubuntu 16.04 I switched to systemd, after having used Ubuntu 14.04 LTS. I snagged the scripts for Wildfly 10 (contrib). I have a persistence.xml with

        <property name="hibernate.search.default.directory_provider" value="filesystem"/>
        <property name="hibernate.search.default.indexBase" value="/var/lucene/indexes"/>

Now, running with old init.d scripts, or starting with standalone.sh, the indexing work, but when starting with the systemd-script, and systemctl, lucene prefers to use / as indexBase, and hence it can't write to the index.

Caused by: org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager

Caused by: org.hibernate.search.SearchException: Cannot write into index directory: /. for index

I really can't see any relevant differences, the actual commands used to start wildfly seem to vary only in that systemd adds -c standalone.xml -b 0.0.0.0, and also the process started by systemd seems to use the symlink i put in /opt/wildfly as JBOSS_HOME while standalone.sh uses the actual installation directory.

Does anyone know how to start wildfly with systemd and still use the indexBase from persistence.xml?

Edit: changing ExecStart in wildfly.service to

ExecStart=/home/wildfly/wildfly-9.0.2.Final/bin/standalone.sh -Dhibernate.search.default.indexBase=/var/lucene/indexes

resolves the problem, but leaves the question; why aren't the value from persistence.xml used? I leave the question open as this resolution do not answer why.

The scripts I have used are delivered in wildfly-10.0.0.Final/docs/contrib/scripts/systemd

First launch.sh which is copied to wildfly's bin catalogue.:

#!/bin/sh

if [ "x$WILDFLY_HOME" = "x" ]; then
    WILDFLY_HOME="/opt/wildfly"
fi

if [[ "$1" == "domain" ]]; then
    $WILDFLY_HOME/bin/domain.sh -c $2 -b $3
else
   $WILDFLY_HOME/bin/standalone.sh -c $2 -b $3
fi

Next wildfly.conf which is copied to /etc/wildfly/wildfly.conf

# The configuration you want to run
WILDFLY_CONFIG=standalone.xml

# The mode you want to run
WILDFLY_MODE=standalone

# The address to bind to
WILDFLY_BIND=0.0.0.0

And finally wildfly.service in /etc/systemd/system/wildfly.service

[Unit]
Description=The WildFly Application Server
After=syslog.target network.target
Before=httpd.service

[Service]
Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
EnvironmentFile=-/etc/wildfly/wildfly.conf
User=wildfly
LimitNOFILE=102642
PIDFile=/var/run/wildfly/wildfly.pid
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG \
$WILDFLY_BIND
StandardOutput=null

[Install]
WantedBy=multi-user.target

Wildfly is installed in /home/wildfly/wildfly-9.0.2.Final and /opt/wildfly is a symlink pointing to the actual installation. Exchanging the link for the actual path in the systemd files seems to make no difference.

When I comment out the stuff in wildfly.conf and edit wildfly.service like this, Lucene works and use the correct directory for index:

# ExecStart=/home/wildfly/wildfly-9.0.2.Final/bin/launch.sh \ 
# $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND
ExecStart=/home/wildfly/wildfly-9.0.2.Final/bin/standalone.sh \
-Dhibernate.search.default.indexBase=/var/lucene/indexes
jon martin solaas
  • 459
  • 1
  • 4
  • 14

0 Answers0