Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The jetty docker image leaks slf4j impl to the webapp #8622

Closed
vmassol opened this issue Sep 27, 2022 · 4 comments
Closed

The jetty docker image leaks slf4j impl to the webapp #8622

vmassol opened this issue Sep 27, 2022 · 4 comments
Labels
Bug For general bugs on Jetty side

Comments

@vmassol
Copy link

vmassol commented Sep 27, 2022

Jetty version(s)
10.0.12

Description
XWiki has a webapp that contains slf4j and we've upgraded to version 2.0.0. This is causing a failure to start the official jetty docker image (tag 10-jdk11), with the following error (see https://jira.xwiki.org/browse/XWIKI-20131 too):

2022-09-27 11:24:28.402:WARN :oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@20b2475a{XWiki,/xwiki,[file:///Users/vmassol/Desktop/jetty/jetty-base/webapps/xwiki/, ...}
java.util.ServiceConfigurationError: org.slf4j.spi.SLF4JServiceProvider: Provider org.eclipse.jetty.logging.JettyLoggingServiceProvider not found
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:589)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1212)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1221)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1265)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1300)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1385)
	at org.slf4j.LoggerFactory.findServiceProviders(LoggerFactory.java:104)
	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:147)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:139)
	at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:421)
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:407)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:356)
	at org.xwiki.container.servlet.XWikiServletContextListener.<clinit>(XWikiServletContextListener.java:50)

We are able to start the jetty from the standard jetty zip withoot any problem when using java -jar $JETTY_HOME/start.jar.

The issue is that the docker image runs docker-entrypoint.sh which calls generate-jetty-start.sh and which generates a jetty.start file which, when executed causes the failure to deploy the xwiki webapp with the stacktrace from above.

FYI the generated jetty.start is:

/opt/java/openjdk/bin/java -Djetty.home=/usr/local/jetty -Djetty.base=/var/lib/jetty --class-path /var/lib/jetty/resources:/usr/local/jetty/lib/logging/slf4j-api-2.0.0.jar:/usr/local/jetty/lib/logging/jetty-slf4j-impl-10.0.12.jar:/usr/local/jetty/lib/jetty-servlet-api-4.0.6.jar:/usr/local/jetty/lib/jetty-http-10.0.12.jar:/usr/local/jetty/lib/jetty-server-10.0.12.jar:/usr/local/jetty/lib/jetty-xml-10.0.12.jar:/usr/local/jetty/lib/jetty-util-10.0.12.jar:/usr/local/jetty/lib/jetty-io-10.0.12.jar:/usr/local/jetty/lib/jetty-jndi-10.0.12.jar:/usr/local/jetty/lib/jetty-security-10.0.12.jar:/usr/local/jetty/lib/jetty-servlet-10.0.12.jar:/usr/local/jetty/lib/jetty-webapp-10.0.12.jar:/usr/local/jetty/lib/jetty-plus-10.0.12.jar:/usr/local/jetty/lib/jakarta.transaction-api-1.3.3.jar:/usr/local/jetty/lib/jetty-annotations-10.0.12.jar:/usr/local/jetty/lib/annotations/asm-9.3.jar:/usr/local/jetty/lib/annotations/asm-analysis-9.3.jar:/usr/local/jetty/lib/annotations/asm-commons-9.3.jar:/usr/local/jetty/lib/annotations/asm-tree-9.3.jar:/usr/local/jetty/lib/annotations/jakarta.annotation-api-1.3.5.jar:/usr/local/jetty/lib/apache-jsp/org.eclipse.jdt.ecj-3.26.0.jar:/usr/local/jetty/lib/apache-jsp/org.eclipse.jetty.apache-jsp-10.0.12.jar:/usr/local/jetty/lib/apache-jsp/org.mortbay.jasper.apache-el-9.0.52.jar:/usr/local/jetty/lib/apache-jsp/org.mortbay.jasper.apache-jsp-9.0.52.jar:/usr/local/jetty/lib/apache-jstl/org.apache.taglibs.taglibs-standard-impl-1.2.5.jar:/usr/local/jetty/lib/apache-jstl/org.apache.taglibs.taglibs-standard-spec-1.2.5.jar:/usr/local/jetty/lib/jetty-client-10.0.12.jar:/usr/local/jetty/lib/jetty-alpn-client-10.0.12.jar:/usr/local/jetty/lib/jetty-deploy-10.0.12.jar:/usr/local/jetty/lib/websocket/websocket-core-common-10.0.12.jar:/usr/local/jetty/lib/websocket/websocket-core-client-10.0.12.jar:/usr/local/jetty/lib/websocket/websocket-core-server-10.0.12.jar:/usr/local/jetty/lib/websocket/websocket-servlet-10.0.12.jar:/usr/local/jetty/lib/websocket/jetty-javax-websocket-api-1.1.2.jar:/usr/local/jetty/lib/websocket/websocket-javax-client-10.0.12.jar:/usr/local/jetty/lib/websocket/websocket-javax-common-10.0.12.jar:/usr/local/jetty/lib/websocket/websocket-javax-server-10.0.12.jar:/usr/local/jetty/lib/websocket/websocket-jetty-api-10.0.12.jar:/usr/local/jetty/lib/websocket/websocket-jetty-common-10.0.12.jar:/usr/local/jetty/lib/websocket/websocket-jetty-server-10.0.12.jar org.eclipse.jetty.xml.XmlConfiguration java.version=11.0.16.1 java.version.major=11 java.version.micro=16 java.version.minor=0 java.version.platform=11 jetty.base=/var/lib/jetty jetty.base.uri=file:///var/lib/jetty jetty.home=/usr/local/jetty jetty.home.uri=file:///usr/local/jetty jetty.webapp.addServerClasses=org.eclipse.jetty.logging.,${jetty.home.uri}/lib/logging/,org.slf4j. runtime.feature.alpn=true slf4j.version=2.0.0 /usr/local/jetty/etc/jetty-bytebufferpool.xml /usr/local/jetty/etc/jetty-threadpool.xml /usr/local/jetty/etc/jetty.xml /usr/local/jetty/etc/jetty-webapp.xml /usr/local/jetty/etc/jetty-deploy.xml /usr/local/jetty/etc/jetty-http.xml

Related:

To reproduce:

  • Download the XWiki WAR and explode it into a directory (let's call it XWIKIDIR)
  • Run docker to start the jetty container with XWiki: docker run -v XWIKIDIR:/var/lib/jetty/webapps/xwiki -p 8080:8080 jetty:10-jdk11

Thanks for any help on this!

@vmassol vmassol added the Bug For general bugs on Jetty side label Sep 27, 2022
@vmassol
Copy link
Author

vmassol commented Sep 27, 2022

Is there a way to call the docker image and override the entry point/command properly to skip the jetty.start usage? I've tried the following (which ends up working, not sure why but no more slf4j error deploying the xwiki webapp :)) but it generates some warnings:

docker run -v /Users/vmassol/dev/xwiki/xwiki-platform/xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-jetty-hsqldb/target/xwiki-platform-distribution-flavor-jetty-hsqldb-14.8-SNAPSHOT/webapps/xwiki:/var/lib/jetty/webapps/xwiki -v /Users/vmassol/dev/xwiki/xwiki-platform/xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-jetty-hsqldb/target/xwiki-platform-distribution-flavor-jetty-hsqldb-14.8-SNAPSHOT/data:/var/lib/jetty/xwiki-data -p 8080:8080 jetty:10-jdk11 /opt/java/openjdk/bin/java -jar /usr/local/jetty/start.jar -Dxwiki.data.dir=/var/lib/jetty/xwiki-data

Thanks

@lachlan-roberts
Copy link
Contributor

Your link to the WAR to reproduce gives a 404 response, so I could not reproduce.
I tried with 14.8 and 14.8-rc-1 and I did not get any error with these.

Btw the jetty docker images are maintained at https://github.com/eclipse/jetty.docker and not in this repository.

@vmassol
Copy link
Author

vmassol commented Sep 30, 2022

@lachlan-roberts Thanks for trying to reproduce. My bad for pointing to a snapshot that got removed, sorry about that. You cannot reproduce with 14.8 because we've had to revert the upgrade to slf4j 2.0.0 as the build wasn't passing (because of this issue).

However you should be able to reproduce with 14.8-rc-1, that's weird. I've just tried it and I do get the error:

  • cd /tmp
  • wget http://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-distribution-war/14.8-rc-1/xwiki-platform-distribution-war-14.8-rc-1.war
  • mkdir xwiki; cf xwiki
  • jar xvf ../xwiki-platform-distribution-war-14.8-rc-1.war
  • docker run -v /tmp/xwiki:/var/lib/jetty/webapps/xwiki -p 8080:8080 jetty:10-jdk11

Generates for me:

vmassol /tmp/xwiki $ docker run -v /tmp/xwiki:/var/lib/jetty/webapps/xwiki -p 8080:8080 jetty:10-jdk11
2022-09-30 05:18:31.547:INFO :oejs.Server:main: jetty-10.0.12; built: 2022-09-14T01:54:40.076Z; git: 408d0139887e27a57b54ed52e2d92a36731a7e88; jvm 11.0.16.1+1
2022-09-30 05:18:31.579:INFO :oejdp.ScanningAppProvider:main: Deployment monitor [file:///var/lib/jetty/webapps/]
2022-09-30 05:18:36.455:WARN :oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@24aed80c{XWiki,/xwiki,[...{/var/lib/jetty/webapps/xwiki}
java.util.ServiceConfigurationError: org.slf4j.spi.SLF4JServiceProvider: Provider org.eclipse.jetty.logging.JettyLoggingServiceProvider not found
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:589)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1212)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1221)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1265)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1300)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1385)
	at org.slf4j.LoggerFactory.findServiceProviders(LoggerFactory.java:104)
	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:147)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:139)
	at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:421)
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:407)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:356)
	at org.xwiki.container.servlet.XWikiServletContextListener.<clinit>(XWikiServletContextListener.java:50)
...

Btw the jetty docker images are maintained at https://github.com/eclipse/jetty.docker and not in this repository.

Should I open an issue there instead and close this one?

Thanks a lot!

@vmassol
Copy link
Author

vmassol commented Sep 30, 2022

Should I open an issue there instead and close this one?

I guess the answer is yes so I've now created jetty/jetty.docker#118

@vmassol vmassol closed this as completed Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

2 participants