Synology Docker SAXParseException error

rxunique3 years ago

I'm following the instruction below to install traccar on Synology DSM via Docker, and run into Main method error - - SAXParseException

https://motorradtouren.de/coding-stuff/traccar/synology-docker-install-traccar-server/

-- DSM 7.1.1-42962 Update 2
-- MariaDB via synology package 10.3.32-1040
-- phpMyAdmin via synology package 4.9.7-1032
-- php7.4 via synology package
-- traccar/traccar:alpine

With docker container
-- the option "use the same network as docker host" is checked
-- mounted logs folder to /opt/traccar/logs
-- mounted traccar.xml to /opt/traccar/conf/traccar.xml

Above setup would cause Main method error - - SAXParseException
-- Tried to mount the conf folder to /opt/traccar/conf , same error
-- Tried to mount the traccar.xml and default.xml as individual files, same error
-- Tried to not mount any xml, only the logs folder, docker started successfully

my traccar.xml below

<?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='database.driver'>com.mysql.cj.jdbc.Driver</entry>
    <entry key='database.url'>jdbc:mysql://localhost:3307/traccar?serverTimezone=UTC&amp;useSSL=false&amp;allowMultiQueries=true&amp;autoReconnect=true&amp;useUnicode=yes&amp;characterEncoding=UTF-8&amp;sessionVariables=sql_mode=''</entry>
    <entry key='database.user'>traccar</entry>
    <entry key='database.password'>xxxxxxx</entry>


</properties>
Anton Tananaev3 years ago

The error means you have a problem with your config file. Along with the error, it should give you the location of the problem.

rxunique3 years ago

The error from docker, unfortunately DSM docker does not out put log in an easy copy paste format

2022-10-24 20:11:17 ERROR: Main method error -  - SAXParseException (... < Config:46 < <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]: RuntimeException: Configuration file is not a valid XML document
  at Config.<init>(Config.java:42)
  at MainModule.configure(MainModule.java:101)
  while locating Config
Learn more:
  https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR
1 error

======================
Full classname legend:
======================
Config:           "org.traccar.config.Config"
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]: RuntimeException: Configuration file is not a valid XML document
  at Config.<init>(Config.java:42)
  at MainModule.configure(MainModule.java:101)
  while locating Config
Learn more:
  https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR
1 error
======================
Full classname legend:
======================
Config:           "org.traccar.config.Config"
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.lang.RuntimeException: Configuration file is not a valid XML document
    at org.traccar.config.Config.<init>(Config.java:64)
    at org.traccar.config.Config$$FastClassByGuice$$7005243.GUICE$TRAMPOLINE(<generated>)
    at org.traccar.config.Config$$FastClassByGuice$$7005243.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
Caused by: java.util.InvalidPropertiesFormatException: jdk.internal.org.xml.sax.SAXParseException; 
    at java.base/jdk.internal.util.xml.PropertiesDefaultHandler.load(PropertiesDefaultHandler.java:85)
    at java.base/java.util.Properties.loadFromXML(Properties.java:986)
    at org.traccar.config.Config.<init>(Config.java:46)
    ... 17 more
Caused by: jdk.internal.org.xml.sax.SAXParseException; 
    at java.base/jdk.internal.util.xml.impl.ParserSAX.panic(ParserSAX.java:652)
    at java.base/jdk.internal.util.xml.impl.Parser.ent(Parser.java:1917)
rxunique3 years ago

Hi Anton, thanks for speedy reply, you beat me to it. I was half way editing to post the error log.

Yes, I figured its something to do traccar.xml file, and saw similar post about, but I wasn't able to translate the error log to pin point which part of traccar.xml I got wrong

Anton Tananaev3 years ago

Have you tried any tools to validate your XML?

rxunique3 years ago

I copied from https://github.com/traccar/traccar/blob/master/setup/traccar.xml so I wasn't expecting any format errors, but just checked on https://codebeautify.org/xmlvalidator and https://www.w3schools.com/xml/xml_validator.asp both was reporting valid

Anton Tananaev3 years ago

I see that you're using MySQL, so you clearly didn't just copy it. You changed it.

Anton Tananaev3 years ago

Send us the file to check.

rxunique3 years ago

Hi Anton, thank you for the help. I found the cause. As it turns out the phpMyAdmin require special character for password but XML can't have & in the password field. When I did the validation check, I used the password blanked out version