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

Http1FieldPreEncoder not loaded, throws ArrayIndexOutOfBoundsException, prevent initialization #2853

Closed
va1erian opened this issue Aug 23, 2018 · 6 comments
Assignees

Comments

@va1erian
Copy link

Hello,
We are deploying Jetty v9.4.11 on an OSGI environnment. Every once in a while, it appears the Service Loader call in PreEncodedHttpField does not return the HTTP 1.1 impl of PreEncodedHttpField (see the second log line) which make code fails with an ArrayIndexOutOfBoundsException and prevent the initialization of the server.

<2018.08.20 22:24:28 920 +0530><org.eclipse.jetty.util.component.AbstractLifeCycle:185> starting o.e.j.s.ServletContextHandler@21fa176c{HTTP Service,/,null,UNAVAILABLE}
<2018.08.20 22:24:28 966 +0530><org.eclipse.jetty.http.PreEncodedHttpField:64> HttpField encoders loaded: [org.eclipse.jetty.http2.hpack.HpackFieldPreEncoder@46efc595]
<2018.08.20 22:24:28 967 +0530><org.eclipse.jetty.util.component.AbstractLifeCycle:213> FAILED o.e.j.s.ServletContextHandler@21fa176c{HTTP Service,/,null,STARTING}: java.lang.ExceptionInInitializerError
        at org.eclipse.jetty.http.MimeTypes$Type.<init>(MimeTypes.java:103)
        at org.eclipse.jetty.http.MimeTypes$Type.<clinit>(MimeTypes.java:58)
        at org.eclipse.jetty.http.MimeTypes.<clinit>(MimeTypes.java:191)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:832)
        at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:287)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
        at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:252)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)
        at org.eclipse.jetty.server.Server.start(Server.java:419)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:108)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
        at org.eclipse.jetty.server.Server.doStart(Server.java:386)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at com.xxx.as.agent.web.container.Container.start(Container.java:329)
        at com.xxx.as.agent.web.container.Container.access$300(Container.java:67)
        at com.xxx.as.agent.web.container.Container$4.run(Container.java:235)
        at com.xxx.as.service.concurrent.impl.Helper.runTask(Helper.java:57)
        at com.xxx.as.service.concurrent.impl.ThreadQueueExecutor.lambda$execute$6(ThreadQueueExecutor.java:212)
        at com.xxx.as.service.concurrent.impl.ThreadQueue.runTask(ThreadQueue.java:132)
        at com.xxx.as.service.concurrent.impl.ThreadQueue.run(ThreadQueue.java:112)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
        at org.eclipse.jetty.http.PreEncodedHttpField.<clinit>(PreEncodedHttpField.java:71)
        ... 29 more

I really don't know why this happens as Http1FieldPreEncoder is already in the same bundle and the META-INF/services spi config file is here. However I believe this case should be handled better. My suggestion for a fix would be identical to the one mentioned in #1325 and add the elements in the array at the correct index using the index static method.

@joakime
Copy link
Contributor

joakime commented Aug 23, 2018

Might be related to Issue #1325 or #2048 or #262

@joakime
Copy link
Contributor

joakime commented Sep 10, 2018

Issues #1290 and #705 also seem to apply to this issue.

@joakime
Copy link
Contributor

joakime commented Sep 10, 2018

@janbartel any thoughts?

@janbartel
Copy link
Contributor

janbartel commented Sep 10, 2018

@va1erian if you say the problem is intermittent, it sounds like you may have more than one version of the bundle deployed - are you sure you don't have any older jetty bundles deployed?

Also, please enable debug logging for PreEncodedHttpField class, as it will print out all the encoders it found.

@janbartel janbartel self-assigned this Sep 11, 2018
@janbartel
Copy link
Contributor

@va1erian ?

@va1erian
Copy link
Author

va1erian commented Oct 4, 2018

Hello, sorry this issue completely slipped out of my mind. You're absolutely right, we had a fragment bundle that we used to fix an obscure OSGi issued that ended up causing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants