Cant start process with systemctl

altaaro2 years ago

I saw a couple of topics with same problem but none of the workarounds worked for me. Im running raspbian on Raspberry Pi 3B
When i try to start a service with systemctl i got an error

pi@raspberrypi:/opt/traccar $ java -version
openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Debian-1deb11u1, mixed mode)
pi@raspberrypi:/opt/traccar $ lsb_release --all
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye
pi@raspberrypi:/opt/traccar $ sudo systemctl start traccar
pi@raspberrypi:/opt/traccar $ sudo systemctl status traccar
● traccar.service - traccar
     Loaded: loaded (/etc/systemd/system/traccar.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2023-02-17 16:10:12 GMT; 7s ago
    Process: 17344 ExecStart=/opt/traccar/jre/bin/java -jar tracker-server.jar conf/traccar.xml (code=exited, status=203/EXEC)
   Main PID: 17344 (code=exited, status=203/EXEC)
        CPU: 8ms

Feb 17 16:10:12 raspberrypi systemd[1]: traccar.service: Failed with result 'exit-code'.
pi@raspberrypi:/opt/traccar $

While i run a Traccar manually it works like a charm. Got any ideas what's wrong?

Anton Tananaev2 years ago

Is there anything in Traccar logs?

altaaro2 years ago

No, directory is empty. I checked on fresh instalation

Anton Tananaev2 years ago

Can you show us how you run it manually and what's the output?

altaaro2 years ago
pi@raspberrypi:/opt/traccar $ sudo java -jar tracker-server.jar conf/traccar.xml
Running Changeset: changelog-4.0-clean::changelog-4.0-clean::author
Running Changeset: changelog-4.0-clean::changelog-4.0-clean-common::author
Running Changeset: changelog-3.3::changelog-3.3::author
Running Changeset: changelog-3.5::changelog-3.5::author
Running Changeset: changelog-3.6::changelog-3.6::author
Running Changeset: changelog-3.7::changelog-3.7::author
Running Changeset: changelog-3.7::changelog-3.7-notmssql::author
Running Changeset: changelog-3.8::changelog-3.8::author
Running Changeset: changelog-3.9::changelog-3.9::author
Running Changeset: changelog-3.10::changelog-3.10::author
Running Changeset: changelog-3.10::changelog-3.10-notmssql::author
Running Changeset: changelog-3.10::changelog-3.10-mssql::author
Running Changeset: changelog-3.10::changelog-3.7-mssql::author
Running Changeset: changelog-3.11::changelog-3.11::author
Running Changeset: changelog-3.12::changelog-3.12::author
Running Changeset: changelog-3.12::changelog-3.12-notmssql::author
Running Changeset: changelog-3.12::changelog-3.12-pgsql::author
Running Changeset: changelog-3.14::changelog-3.14::author
Running Changeset: changelog-3.15::changelog-3.15::author
Running Changeset: changelog-3.16::changelog-3.16::author
Running Changeset: changelog-3.17::changelog-3.3-admin::author
Running Changeset: changelog-3.17::changelog-3.17::author
Running Changeset: changelog-4.0::changelog-4.0-pre::author
Running Changeset: changelog-4.0::changelog-4.0-common::author
Running Changeset: changelog-4.0::changelog-4.0-pg::author
Running Changeset: changelog-4.0::changelog-4.0::author
Running Changeset: changelog-4.0::changelog-4.0-renaming::author
Running Changeset: changelog-4.1::changelog-4.1-mssql::author
Running Changeset: changelog-4.7::changelog-4.7::author
Running Changeset: changelog-4.9::changelog-4.9::author
Running Changeset: changelog-4.10::changelog-4.10::author
Running Changeset: changelog-4.11::changelog-4.11::author
Running Changeset: changelog-4.13::changelog-4.13::author
Running Changeset: changelog-4.15::changelog-4.15::author
Running Changeset: changelog-5.0::changelog-5.0::author
Running Changeset: changelog-5.1::changelog-5.1::author
Running Changeset: changelog-5.2::changelog-5.2::author
Running Changeset: changelog-5.3::changelog-5.3::author
Running Changeset: changelog-5.4::changelog-5.4::author
Running Changeset: changelog-5.5::changelog-5.5::author
Running Changeset: changelog-5.6::changelog-5.6::author

And now while I enter my http://192.168.1.40:8082/ i got a registration prompt so I guess it works.
Don't know exactly how to post a screenshot

Anton Tananaev2 years ago

I see the difference. You're not using the same java. Have you tried the one that comes with Traccar?

/opt/traccar/jre/bin/java -jar tracker-server.jar conf/traccar.xml
altaaro2 years ago

On fresh Raspbian there was no installed java at all and i couldn't run the thing, so i thought I need to install the latest version. I'll check in a minute and post a feedback.

altaaro2 years ago

Am I doing something wrong or it's the proper error log?

pi@raspberrypi:/ $ sudo java -classpath /opt/traccar/jre/bin/java -jar /opt/traccar/tracker-server.jar  /opt/traccar/conf/traccar.xml
2023-02-17 16:54:19 ERROR: Main method error - ./conf/default.xml (No such file or directory) - FileNotFoundException (... < Config:51 < <gener:-1 < *:-1 < ... < Main:120 < ...)
Exception in thread "main" java.lang.RuntimeException: com.google.inject.CreationException: Unable to create injector, see the following errors:

1) [Guice/ErrorInjectingConstructor]: FileNotFoundException: ./conf/default.xml (No such file or directory)
  at Config.<init>(Config.java:42)
  at MainModule.configure(MainModule.java:109)
  while locating Config

Learn more:
  https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR

1 error

======================
Full classname legend:
======================
Config:                "org.traccar.config.Config"
FileNotFoundException: "java.io.FileNotFoundException"
MainModule:            "org.traccar.MainModule"
========================
End of classname legend:
========================

        at org.traccar.Main.run(Main.java:154)
        at org.traccar.Main.main(Main.java:114)
Caused by: com.google.inject.CreationException: Unable to create injector, see the following errors:

1) [Guice/ErrorInjectingConstructor]: FileNotFoundException: ./conf/default.xml (No such file or directory)
  at Config.<init>(Config.java:42)
  at MainModule.configure(MainModule.java:109)
  while locating Config

Learn more:
  https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR

1 error

======================
Full classname legend:
======================
Config:                "org.traccar.config.Config"
FileNotFoundException: "java.io.FileNotFoundException"
MainModule:            "org.traccar.MainModule"
========================
End of classname legend:
========================

        at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:576)
        at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:190)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:113)
        at com.google.inject.Guice.createInjector(Guice.java:87)
        at com.google.inject.Guice.createInjector(Guice.java:69)
        at com.google.inject.Guice.createInjector(Guice.java:59)
        at org.traccar.Main.run(Main.java:120)
        ... 1 more
Caused by: java.io.FileNotFoundException: ./conf/default.xml (No such file or directory)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
        at org.traccar.config.Config.<init>(Config.java:51)
        at org.traccar.config.Config$$FastClassByGuice$$7208237.GUICE$TRAMPOLINE(<generated>)
        at org.traccar.config.Config$$FastClassByGuice$$7208237.apply(<generated>)
        at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:82)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:300)
        at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
        at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:169)
        at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
        at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:213)
        at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:186)
        ... 6 more
Anton Tananaev2 years ago

You're running it from the wrong folder.

altaaro2 years ago

Now it's working again but i need to close the java with CTRL+C

pi@raspberrypi:/opt/traccar $ sudo java -classpath /opt/traccar/jre/bin/java -jar /opt/traccar/tracker-server.jar  /opt/traccar/conf/traccar.xml

Should i change something in /etc/systemd/system/traccar.service file?

Anton Tananaev2 years ago

What are you doing with the classpath there? The command was correct, but you ran it from the wrong folder. Why did you change the command?

altaaro2 years ago

Im using

sudo java -classpath /opt/traccar/jre/bin/java -jar /opt/traccar/tracker-server.jar  /opt/traccar/conf/traccar.xml

it to run java from different path than system knows.

I can't run

/opt/traccar/jre/bin/java -jar tracker-server.jar conf/traccar.xml

Command isn't working for any folders.

Anton Tananaev2 years ago

Can you please show the output of the right command from the right folder.

altaaro2 years ago
pi@raspberrypi:/opt/traccar $ sudo /opt/traccar/jre/bin/java -jar tracker-server.jar conf/traccar.xml
sudo: unable to execute /opt/traccar/jre/bin/java: No such file or directory

Is it right folder now?

Anton Tananaev2 years ago

Yes. This probably indicates that the architecture is not compatible. What is your OS architecture and what Traccar package are you using?