I recently had to update a legacy project. The basis is Java with the Spring framework and an embedded Jetty. This is started via Maven. After updating the Jetty to the current version, I noticed that the server could no longer be accessed after booting. After some testing, it was clear that the Jetty version 9.4.3 (9.4.3.v20170317) worked fine, but the version 9.4.4 (9.4.4.v20170414) did not. To narrow down the problem, I looked at the output in the console:
9.4.3:
>> mvn jetty:run
[...]
[INFO] Configuring Jetty for project: Challoday
[INFO] webAppSourceDirectory not set. Trying src/main/webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = /Users/joern/IdeaProjects/challoday/target/classes
[INFO] Configuring Jetty from xml configuration file = /Users/joern/IdeaProjects/challoday/src/main/resources/jetty.xml
[INFO] Configuring Jetty from xml configuration file = /Users/joern/IdeaProjects/challoday/src/main/resources/jetty-http.xml
[INFO] Context path = /
[INFO] Tmp directory = /Users/joern/IdeaProjects/challoday/worky
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = file:///Users/joern/IdeaProjects/challoday/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = /Users/joern/IdeaProjects/challoday/src/main/webapp
[INFO] jetty-9.4.3.v20170317
[INFO] Scanning elapsed time=1342ms
[INFO] 2 Spring WebApplicationInitializers detected on classpath
[INFO] DefaultSessionIdManager workerName=node0
[INFO] No SessionScavenger set, using defaults
[INFO] Scavenging every 600000ms
[INFO] Set web app root system property: 'webapp.root' = [/Users/joern/IdeaProjects/challoday/src/main/webapp]
[INFO] Initializing log4j from [classpath:log4j-development.xml]
[INFO] Initializing Spring root WebApplicationContext
[INFO] Initializing Spring FrameworkServlet 'dispatcher'
[INFO] Started o.e.j.m.p.JettyWebAppContext@7d199c68{/,file:///Users/joern/IdeaProjects/challoday/src/main/webapp/,AVAILABLE}{file:///Users/joern/IdeaProjects/challoday/src/main/webapp/}
[INFO] Started ServerConnector@9cb927e{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started @10994ms
[INFO] Started Jetty Server
9.4.4:
>> mvn jetty:run
[...]
[INFO] Configuring Jetty for project: Challoday
[INFO] webAppSourceDirectory not set. Trying src/main/webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = /Users/joern/IdeaProjects/challoday/target/classes
[INFO] Configuring Jetty from xml configuration file = /Users/joern/IdeaProjects/challoday/src/main/resources/jetty.xml
[INFO] Configuring Jetty from xml configuration file = /Users/joern/IdeaProjects/challoday/src/main/resources/jetty-http.xml
[INFO] Context path = /
[INFO] Tmp directory = /Users/joern/IdeaProjects/challoday/worky
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = file:///Users/joern/IdeaProjects/challoday/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = /Users/joern/IdeaProjects/challoday/src/main/webapp
[INFO] jetty-9.4.4.v20170414
[INFO] Scanning elapsed time=1535ms
[INFO] DefaultSessionIdManager workerName=node0
[INFO] No SessionScavenger set, using defaults
[INFO] Scavenging every 660000ms
[INFO] Started o.e.j.m.p.JettyWebAppContext@4c2fb9dd{/,file:///Users/joern/IdeaProjects/challoday/src/main/webapp/,AVAILABLE}{file:///Users/joern/IdeaProjects/challoday/src/main/webapp/}
[INFO] Started ServerConnector@7fb48179{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started @5672ms
[INFO] Started Jetty Server
As you can see, neither the configurations are loaded nor the beans are initialized.
The next step is to have a look at the changelog of version 9.4.4. There you can find this hint:
1467 Change default for WebAppContext.isConfiguredDiscovered to false
And in the corresponding discussion on GitHub one finds out that this change is exactly what prevents the automatic scanning of the configuration. So you have to adjust the pom.xml
accordingly:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.4.v20170414</version>
<configuration>
<jettyXml>${project.basedir}/src/main/resources/jetty.xml,${project.basedir}/src/main/resources/jetty-http.xml</jettyXml>
<webAppConfig>
<tempDirectory>worky</tempDirectory>
<configurationDiscovered>true</configurationDiscovered>
</webAppConfig>
<stopPort>9998</stopPort>
<stopKey>foo</stopKey>
</configuration>
</plugin>
This change <configurationDiscovered>true</configurationDiscovered>
restores the behavior of the previous versions. The server loads the Spring configuration including the annotations again.
Chatbots are on everyone's lips now. In addition to live chat, where you talk to…
A member of the German parliament had invited to an open discussion round. It was…
Sitting is the new smoking. So they say. Because sitting too much and not enough…
When networks became established in the companies, there was soon a desire to connect to…
The average German internet user has 15 different accounts. Some of them he created because…
The German industry information service Heise.de proclaims the most popular programming language in 2016. The…