traccar.service not starting with Mozilla LSB

chris d6 years ago

I experience a strange behavior: When I enable Mozilla geolocation in traccar.xml

        <entry key='geolocation.enable'>true</entry>
        <entry key='geolocation.type'>mozilla</entry>
        <entry key='geolocation.key'>test</entry>

traccar.service fails to start:

 systemctl status traccar.service
● traccar.service - traccar
   Loaded: loaded (/etc/systemd/system/traccar.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/traccar.service.d
           └─run-as-user.conf
   Active: failed (Result: exit-code) since Fri 2019-02-22 13:24:59 CET; 12min ago
  Process: 4182 ExecStart=/opt/traccar/jre/bin/java -jar tracker-server.jar conf/traccar.xml (code=exited, status=1/FAILURE)
 Main PID: 4182 (code=exited, status=1/FAILURE)

Feb 22 13:24:59 alinux traccar[4182]: Exception in thread "main" java.lang.RuntimeException: java.lang.NullPointerException
Feb 22 13:24:59 alinux traccar[4182]:         at org.traccar.Main.run(Main.java:152)
Feb 22 13:24:59 alinux traccar[4182]:         at org.traccar.Main.main(Main.java:104)
Feb 22 13:24:59 alinux traccar[4182]: Caused by: java.lang.NullPointerException
Feb 22 13:24:59 alinux traccar[4182]:         at org.traccar.helper.Log.setupDefaultLogger(Log.java:165)
Feb 22 13:24:59 alinux traccar[4182]:         at org.traccar.Context.init(Context.java:368)
Feb 22 13:24:59 alinux traccar[4182]:         at org.traccar.Main.run(Main.java:110)
Feb 22 13:24:59 alinux traccar[4182]:         ... 1 more
Feb 22 13:24:59 alinux systemd[1]: traccar.service: Main process exited, code=exited, status=1/FAILURE
Feb 22 13:24:59 alinux systemd[1]: traccar.service: Failed with result 'exit-code'.

setting geolocation.enable to false does not change the situation, I have to comment out the geolocation.type statement, and it runs again

 systemctl status traccar.service
● traccar.service - traccar
   Loaded: loaded (/etc/systemd/system/traccar.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/traccar.service.d
           └─run-as-user.conf
   Active: active (running) since Fri 2019-02-22 13:41:56 CET; 2min 17s ago
 Main PID: 4432 (java)
    Tasks: 80 (limit: 4915)
   CGroup: /system.slice/traccar.service
           └─4432 /opt/traccar/jre/bin/java -jar tracker-server.jar conf/traccar.xml

Feb 22 13:41:56 alinux systemd[1]: Started traccar.
Feb 22 13:42:00 alinux traccar[4432]: WARNING: An illegal reflective access operation has occurred
Feb 22 13:42:00 alinux traccar[4432]: WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/opt/traccar/lib/guice-4.2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
Feb 22 13:42:00 alinux traccar[4432]: WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
Feb 22 13:42:00 alinux traccar[4432]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
Feb 22 13:42:00 alinux traccar[4432]: WARNING: All illegal access operations will be denied in a future release

Using opencellid the server starts without problems. I have traccar-linux-64-4.3 installed on Ubuntu 18.04.02 LTS. Is there anybody experiencing the same problem, or does somebody know how to solve the problem?

Anton Tananaev6 years ago

Looks like you broke something else in the config.

chris d6 years ago

Anton, I agree with you. But I cannot figure out what it could be. This is my working traccar.xml (private data replaced with XXX)

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>

<properties>

    <entry key='config.default'>./conf/default.xml</entry>

    <!--

    This is the main configuration file. All your configuration parameters should be placed in this file.

    Default configuration parameters are located in the "default.xml" file. You should not modify it to avoid issues
    with upgrading to a new version. Parameters in the main config file override values in the default file. Do not
    remove "config.default" parameter from this file unless you know what you are doing.

    For list of available parameters see following page: https://www.traccar.org/configuration-file/

    -->

        <entry key='geocoder.enable'>true</entry>
        <entry key='geocoder.format'>%r %h, %p %t, %c</entry>
        <entry key='geocoder.ignorePositions'>true</entry>
        <entry key='geocoder.reuseDistance'>10</entry>
        <entry key='geocoder.cacheSize'>20000</entry>
        <entry key='geocoder.type'>nominatim</entry>
        <entry key='geocoder.ignorePositions'>false</entry>
        <entry key='geocoder.url'>http://eu1.locationiq.com/v1/reverse.php</entry>
        <entry key='geocoder.key'>XXX</entry>

        <entry key='geolocation.enable'>true</entry>
<!--
        <entry key='geolocation.type'>mozilla</entry>
        <entry key='geolocation.key'>test</entry>
-->
        <entry key='geolocation.type'>opencellid</entry>
        <entry key='geolocation.key'>XXX</entry>

        <entry key='geolocation.mcc'>262</entry>
        <entry key='geolocation.mnc'>3</entry>
        <entry key='geolocation.processInvalidPositions'>true</entry>

        <entry key='processing.copyAttributes.enable'>false</entry>
        <entry key='processing.copyAttributes'>alarm,blocked,rssi,ignition</entry>

    <entry key='database.driver'>org.h2.Driver</entry>
    <entry key='database.url'>jdbc:h2:./data/database</entry>
    <entry key='database.user'>XXX</entry>
    <entry key='database.password'>XXX</entry>

</properties>

With this version the service starts. If I remove the comment for the two mozilla lines and comment the two following lines for opencellid the service does not start anymore. I have no idea where the config breaks. The config is very basic and only changing these two lines makes the problem.

Do you have a recommendation how to track down the error?

Ernesto Vallejo6 years ago

I just added mozilla to my 4.3 configuration and went thru without problems.
I do not have all configurations as you do, but maybe, and I'm saying just maybe, could it be a combination of mozilla key and some other key?

chris d6 years ago

I will try to strip it from all other optional configurations (which work fine without mozilla) and see what will happen.

chris d6 years ago

I found the problem: My opencellid API key contains the symbols " -- " (double-hyphen). I was not aware that double-hyphen is not allowed within XML comments.
That's kind of an annoying convention imho.

Anywas, thanks Anton, thanks Ernesto!

Ernesto Vallejo6 years ago

Good to know it ... I'm not sure if there's a way you can regenerate your API key that will come out without a double hyphen. Is there? Regards.

Macan6 years ago

Hey , you have same two lines of this code in your xml file : <entry key='geocoder.ignorePositions'>false</entry> and one is "true" and second one is "false" , delete one, maybe that can help.

chris d6 years ago

@Ernesto Vallejo: The double-hyphen is only a problem within commented sections. If the key is in use, everything's fine.
@ Macan: Thanks for spotting this. It is not related to the problem, which was solved anyways according to my last post.