You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tika.apache.org by pgnd <pg...@dev-mail.net> on 2026/08/22 18:21:05 UTC

tika-server 4.0.0 won't start with comments in tika-config.json (ConfigMerger mapper lacks ALLOW_COMMENTS)

i'm working on a 1st-install of tika v4, migrating config from v3

i'm building locally from source, release tag, on a fedora 44 box, w/ OpenJDK 25

build's fine.  install's fine.  server's up --
-- as long as i've removed all comments from my JSON config.

4.0.x Configuration page

	https://tika.apache.org/docs/4.0.x/configuration/index.html

says "// and /* */ comments are allowed"

here, tika-server 4.0.0 refuses to start on any config containing a // comment.
position doesn't seem to matter.

e.g.,

	systemctl stop tika4-server.service
	grep comment /usr/local/etc/tika4/tika4-server-config-custom.json -A6 -B6
		(empty)
	systemctl start tika4-server.service
	systemctl show tika4-server.service -p MainPID -p Result -p ExecMainStatus --no-pager
		MainPID=51627
		Result=success
		ExecMainStatus=0
	systemctl stop tika4-server.service
	sed -i '3i\    // probe: comment on a middle line' /usr/local/etc/tika4/tika4-server-config-custom.json
	grep comment /usr/local/etc/tika4/tika4-server-config-custom.json -A6 -B6
		{
		"parsers": [
			// probe: comment on a middle line
			{
			"empty-parser": {
				"_mime-include": [
				"audio/*",
				"video/*",
				"message/rfc822",
	rm -f /var/log/tika4/tika.log
	systemctl start tika4-server.service
	sleep 8
	systemctl show tika4-server.service -p MainPID -p Result -p ExecMainStatus --no-pager
		MainPID=0
		Result=exit-code
		ExecMainStatus=255
	cat /var/log/tika4/tika.log
		2026-08-22 13:55:46 INFO  o.a.t.s.c.TikaServerProcess [main] Starting Apache Tika 4.0.0 server
		2026-08-22 13:55:46 INFO  o.a.t.s.c.TikaServerProcess [main] Using custom config: /usr/local/etc/tika4/tika4-server-config-custom.json
		2026-08-22 13:55:46 INFO  o.a.t.s.c.TikaServerProcess [main] Created input temp directory: /tmp/tika-server-input-13152530168810983841
		2026-08-22 13:55:46 INFO  o.a.t.s.c.TikaServerProcess [main] Configuring __tika-server with basePath=/tmp/tika-server-input-13152530168810983841
		2026-08-22 13:55:46 ERROR o.a.t.s.c.TikaServerProcess [main] Can't start:
		com.fasterxml.jackson.core.JsonParseException: Unexpected character ('/' (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)
		at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 5]
				at com.fasterxml.jackson.core.JsonParser._constructReadException(JsonParser.java:2675)
				at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:743)
				at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipComment(UTF8StreamJsonParser.java:3331)
				at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWSOrEnd2(UTF8StreamJsonParser.java:3211)
				at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWSOrEnd(UTF8StreamJsonParser.java:3187)
				at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:716)
				at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer._deserializeContainerNoRecursion(JsonNodeDeserializer.java:608)
				at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:99)
				at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:24)
				at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
				at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:5094)
				at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3382)
				at org.apache.tika.pipes.core.config.ConfigMerger.mergeOrCreate(ConfigMerger.java:98)
				at org.apache.tika.server.core.TikaServerProcess.createServerConfig(TikaServerProcess.java:743)
				at org.apache.tika.server.core.TikaServerProcess.initPipesParsingHelper(TikaServerProcess.java:636)
				at org.apache.tika.server.core.TikaServerProcess.initServer(TikaServerProcess.java:240)
				at org.apache.tika.server.core.TikaServerProcess.main(TikaServerProcess.java:139)
				at org.apache.tika.server.core.TikaServerCli.main(TikaServerCli.java:55)


deleting the comment line & restart brings the server back up

digging a bit, there are two different ObjectMappers in play, and only one of them has comments turned on.

tika-serialization has TikaObjectMapperFactory, which sets JsonParser.Feature.ALLOW_COMMENTS = true.
that's the one the docs describe.

tika-pipes-core has ConfigMerger.mergeOrCreate, which doesn't use that factory.
it constructs its own new ObjectMapper(), sets one SerializationFeature on it, then calls readTree(File) on that.
required ALLOW_COMMENTS is never set on it, so its parser rejects the '/'.
the parser never gets far enough to know whether it's "//" or "/* */"
both fail at the same character for the same reason.

that second mapper is the one in the stack trace above, @ ConfigMerger.java:98.
and in tika-server startup it reads the config file first, at TikaServerProcess.createServerConfig, so startup aborts there, before TikaObjectMapperFactory's mapper ever gets the file.

so the doc is right about the loader, and the server still won't start.

should ConfigMerger.mergeOrCreate be getting its ObjectMapper from TikaObjectMapperFactory?

Re: tika-server 4.0.0 won't start with comments in tika-config.json (ConfigMerger mapper lacks ALLOW_COMMENTS)

Posted by Tim Allison <ta...@apache.org>.
Sorry about that. Sounds right; will look when I'm back to a keyboard.
Thank you for the report!

https://issues.apache.org/jira/browse/TIKA-4834

On Sat, Aug 22, 2026 at 2:21 PM pgnd <pg...@dev-mail.net> wrote:
>
> i'm working on a 1st-install of tika v4, migrating config from v3
>
> i'm building locally from source, release tag, on a fedora 44 box, w/ OpenJDK 25
>
> build's fine.  install's fine.  server's up --
> -- as long as i've removed all comments from my JSON config.
>
> 4.0.x Configuration page
>
>         https://tika.apache.org/docs/4.0.x/configuration/index.html
>
> says "// and /* */ comments are allowed"
>
> here, tika-server 4.0.0 refuses to start on any config containing a // comment.
> position doesn't seem to matter.
>
> e.g.,
>
>         systemctl stop tika4-server.service
>         grep comment /usr/local/etc/tika4/tika4-server-config-custom.json -A6 -B6
>                 (empty)
>         systemctl start tika4-server.service
>         systemctl show tika4-server.service -p MainPID -p Result -p ExecMainStatus --no-pager
>                 MainPID=51627
>                 Result=success
>                 ExecMainStatus=0
>         systemctl stop tika4-server.service
>         sed -i '3i\    // probe: comment on a middle line' /usr/local/etc/tika4/tika4-server-config-custom.json
>         grep comment /usr/local/etc/tika4/tika4-server-config-custom.json -A6 -B6
>                 {
>                 "parsers": [
>                         // probe: comment on a middle line
>                         {
>                         "empty-parser": {
>                                 "_mime-include": [
>                                 "audio/*",
>                                 "video/*",
>                                 "message/rfc822",
>         rm -f /var/log/tika4/tika.log
>         systemctl start tika4-server.service
>         sleep 8
>         systemctl show tika4-server.service -p MainPID -p Result -p ExecMainStatus --no-pager
>                 MainPID=0
>                 Result=exit-code
>                 ExecMainStatus=255
>         cat /var/log/tika4/tika.log
>                 2026-08-22 13:55:46 INFO  o.a.t.s.c.TikaServerProcess [main] Starting Apache Tika 4.0.0 server
>                 2026-08-22 13:55:46 INFO  o.a.t.s.c.TikaServerProcess [main] Using custom config: /usr/local/etc/tika4/tika4-server-config-custom.json
>                 2026-08-22 13:55:46 INFO  o.a.t.s.c.TikaServerProcess [main] Created input temp directory: /tmp/tika-server-input-13152530168810983841
>                 2026-08-22 13:55:46 INFO  o.a.t.s.c.TikaServerProcess [main] Configuring __tika-server with basePath=/tmp/tika-server-input-13152530168810983841
>                 2026-08-22 13:55:46 ERROR o.a.t.s.c.TikaServerProcess [main] Can't start:
>                 com.fasterxml.jackson.core.JsonParseException: Unexpected character ('/' (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)
>                 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 5]
>                                 at com.fasterxml.jackson.core.JsonParser._constructReadException(JsonParser.java:2675)
>                                 at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:743)
>                                 at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipComment(UTF8StreamJsonParser.java:3331)
>                                 at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWSOrEnd2(UTF8StreamJsonParser.java:3211)
>                                 at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWSOrEnd(UTF8StreamJsonParser.java:3187)
>                                 at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:716)
>                                 at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer._deserializeContainerNoRecursion(JsonNodeDeserializer.java:608)
>                                 at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:99)
>                                 at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:24)
>                                 at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
>                                 at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:5094)
>                                 at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3382)
>                                 at org.apache.tika.pipes.core.config.ConfigMerger.mergeOrCreate(ConfigMerger.java:98)
>                                 at org.apache.tika.server.core.TikaServerProcess.createServerConfig(TikaServerProcess.java:743)
>                                 at org.apache.tika.server.core.TikaServerProcess.initPipesParsingHelper(TikaServerProcess.java:636)
>                                 at org.apache.tika.server.core.TikaServerProcess.initServer(TikaServerProcess.java:240)
>                                 at org.apache.tika.server.core.TikaServerProcess.main(TikaServerProcess.java:139)
>                                 at org.apache.tika.server.core.TikaServerCli.main(TikaServerCli.java:55)
>
>
> deleting the comment line & restart brings the server back up
>
> digging a bit, there are two different ObjectMappers in play, and only one of them has comments turned on.
>
> tika-serialization has TikaObjectMapperFactory, which sets JsonParser.Feature.ALLOW_COMMENTS = true.
> that's the one the docs describe.
>
> tika-pipes-core has ConfigMerger.mergeOrCreate, which doesn't use that factory.
> it constructs its own new ObjectMapper(), sets one SerializationFeature on it, then calls readTree(File) on that.
> required ALLOW_COMMENTS is never set on it, so its parser rejects the '/'.
> the parser never gets far enough to know whether it's "//" or "/* */"
> both fail at the same character for the same reason.
>
> that second mapper is the one in the stack trace above, @ ConfigMerger.java:98.
> and in tika-server startup it reads the config file first, at TikaServerProcess.createServerConfig, so startup aborts there, before TikaObjectMapperFactory's mapper ever gets the file.
>
> so the doc is right about the loader, and the server still won't start.
>
> should ConfigMerger.mergeOrCreate be getting its ObjectMapper from TikaObjectMapperFactory?