jetty / jetty.docker

jetty docker
https://eclipse.dev/jetty
Other
19 stars 18 forks source link

Jetty 12 docker war not booting #200

Closed ifujiwara-github closed 7 months ago

ifujiwara-github commented 7 months ago

I am facing issue and the war is not starting , the app is migrated spring boot:3.1.3→3.2.4 jakarta:5.0.0→6.0.0

Its working locally but not working with docker.

Dockerfile

FROM maven:3.8.5-openjdk-17-slim AS builder

WORKDIR /app
COPY pom.xml .
COPY src ./src

ARG _ENV=dev
RUN sed -i "s/spring\.profiles\.active=dev/spring.profiles.active=${_ENV}/g" ./src/main/resources/application.properties

RUN mvn clean package -Dapplication-id=${_PROJECT_ID}

FROM jetty:12.0.7-jre17-alpine

COPY --from=builder /app/target/test.war /var/lib/jetty/webapps/root.war

EXPOSE 8080

docker run log

/opt/java/openjdk/bin/java -Djava.io.tmpdir=/tmp/jetty -Djetty.home=/usr/local/jetty -Djetty.base=/var/lib/jetty -Djava.io.tmpdir=/tmp/jetty --class-path /var/lib/jetty/resources:/usr/local/jetty/lib/logging/slf4j-api-2.0.9.jar:/usr/local/jetty/lib/logging/jetty-slf4j-impl-12.0.7.jar:/usr/local/jetty/lib/jetty-http-12.0.7.jar:/usr/local/jetty/lib/jetty-server-12.0.7.jar:/usr/local/jetty/lib/jetty-xml-12.0.7.jar:/usr/local/jetty/lib/jetty-util-12.0.7.jar:/usr/local/jetty/lib/jetty-io-12.0.7.jar org.eclipse.jetty.xml.XmlConfiguration java.io.tmpdir=/tmp/jetty java.version=17.0.10 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.,file:///usr/local/jetty/lib/logging/,org.slf4j. runtime.feature.alpn=true slf4j.version=2.0.9 /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-http.xml
2024-04-08 17:00:35.415:INFO :oejs.Server:main: jetty-12.0.7; built: 2024-02-29T21:19:41.771Z; git: c89aca8fd34083befd79f328a3b8b6ffff04347e; jvm 17.0.10+7
2024-04-08 17:00:35.494:INFO :oejs.AbstractConnector:main: Started ServerConnector@6adeadcf{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2024-04-08 17:00:35.516:INFO :oejs.Server:main: Started oejs.Server@58fdd99{STARTING}[12.0.7,sto=5000] @710m

Browser Untitled

I am expecting the java/spring boot based jar will boot strap and show message like

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m              [2m (v3.2.4)[0;39m
...
...
...
{"message":"Started xxxApplication in 5.129 seconds (process running for 7.342)"}
lachlan-roberts commented 7 months ago

Likely you just need to enable the Jetty EE10 Modules

Jetty 12 supports EE8, EE9 and EE10 so certain modules are no longer enabled by default. So can you try adding a line like this into your dockerfile

RUN java -jar "$JETTY_HOME/start.jar" --add-modules=ee10-webapp,ee10-deploy,ee10-jsp,ee10-jstl
ifujiwara-github commented 7 months ago

Thanks.Booting success, other error occurred. Is there a problem with servlet configuration?

2024-04-09 03:52:43.272:WARN :oejew.WebAppContext:main: Failed startup of context oeje10w.WebAppContext@493dfb8e{root,/,b=file:///tmp/jetty-0_0_0_0-8080-root_war-_-any-16711043961830662755/webapp/,a=STOPPED,h=oeje10s.SessionHandler@acdcf71{STOPPED}}{/var/lib/jetty/webapps/root.war}
java.lang.IllegalStateException: No Jetty ServletContextHandler, Jetty WebSocket SCI unavailable
        at org.eclipse.jetty.ee10.servlet.ServletContextHandler.getServletContextHandler(ServletContextHandler.java:171)
        at org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletContainerInitializer.onStartup(JettyWebSocketServletContainerInitializer.java:99)
        at org.eclipse.jetty.ee10.servlet.ServletContainerInitializerHolder.doStart(ServletContainerInitializerHolder.java:155)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
        at org.eclipse.jetty.ee10.servlet.ServletContextHandler$ServletContainerInitializerStarter.doStart(ServletContextHandler.java:3042)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
        at org.eclipse.jetty.ee10.servlet.ServletContextHandler.startContext(ServletContextHandler.java:1290)
        at org.eclipse.jetty.ee10.webapp.WebAppContext.startContext(WebAppContext.java:1223)
        at org.eclipse.jetty.ee10.servlet.ServletContextHandler.lambda$doStart$0(ServletContextHandler.java:1043)
        at org.eclipse.jetty.server.handler.ContextHandler$ScopedContext.call(ContextHandler.java:1151)
        at org.eclipse.jetty.ee10.servlet.ServletContextHandler.doStart(ServletContextHandler.java:1040)
        at org.eclipse.jetty.ee10.webapp.WebAppContext.doStart(WebAppContext.java:496)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
        at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:40)
        at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:183)
        at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:522)
        at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:162)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider.pathAdded(ScanningAppProvider.java:293)
        at org.eclipse.jetty.deploy.providers.ContextProvider.pathAdded(ContextProvider.java:520)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.pathAdded(ScanningAppProvider.java:69)
        at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:902)
        at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:868)
        at org.eclipse.jetty.util.Scanner.scan(Scanner.java:775)
        at org.eclipse.jetty.util.Scanner.startScanning(Scanner.java:664)
        at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:636)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:120)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:264)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
        at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:592)
        at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:263)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
        at org.eclipse.jetty.server.Server.start(Server.java:622)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:120)
        at org.eclipse.jetty.server.Handler$Abstract.doStart(Handler.java:468)
        at org.eclipse.jetty.server.Server.doStart(Server.java:563)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:2033)
2024-04-09 03:52:43.274:INFO :oejs.DefaultSessionIdManager:main: Session workerName=node0
2024-04-09 03:52:43.304:INFO :oejs.AbstractConnector:main: Started ServerConnector@48eb9836{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2024-04-09 03:52:43.317:INFO :oejs.Server:main: Started oejs.Server@dd8ba08{STARTING}[12.0.7,sto=5000] @6223ms

pom.xml


<properties>
...
<jakarta-servlet.version>6.0.0</jakarta-servlet.version>
</properties>
    <dependency>
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>
lachlan-roberts commented 7 months ago

Not completely sure why this one is happening.

Did you enable the ee10-websocket-jetty module? If not you should do that, but I then not sure why you are already reaching the JettyWebSocketServletContainerInitializer. Maybe you have included the Jetty WebSocket jars in you application?

ifujiwara-github commented 7 months ago

I haven't included Jetty WebSocket jars in my app ,but I added the module and it was resolved. thanks you.