This is an automated email from the ASF dual-hosted git repository. solomax pushed a commit to branch quickstart-fix in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 4fca66f859159f3781d1c2f67489c1849ddc8aa8 Author: Maxim Solodovnik <[email protected]> AuthorDate: Fri Aug 25 23:37:48 2023 +0700 [WICKET-7070] quickstart should be fixed --- .../src/main/resources/archetype-resources/pom.xml | 19 +++++++++++++- .../archetype-resources/src/test/java/Start.java | 29 +++++++++++++++++++--- .../src/test/jetty/jetty-http.xml | 2 +- .../src/test/jetty/jetty-https.xml | 2 +- .../src/test/jetty/jetty-ssl.xml | 2 +- .../archetype-resources/src/test/jetty/jetty.xml | 2 +- 6 files changed, 48 insertions(+), 8 deletions(-) diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml b/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml index a8488ad9ec..ff7bdfce86 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml @@ -57,6 +57,11 @@ <artifactId>wicket-core</artifactId> <version>${wicket.version}</version> </dependency> + <dependency> + <groupId>org.apache.wicket</groupId> + <artifactId>wicket-native-websocket-javax</artifactId> + <version>${wicket.version}</version> + </dependency> <!-- OPTIONAL DEPENDENCY <dependency> <groupId>org.apache.wicket</groupId> @@ -83,9 +88,15 @@ <!-- JETTY DEPENDENCIES FOR TESTING --> <dependency> <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-webapp</artifactId> + <artifactId>jetty-server</artifactId> + <version>${jetty9.version}</version> <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp</artifactId> <version>${jetty9.version}</version> + <scope>test</scope> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> @@ -93,6 +104,12 @@ <version>${jetty9.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.eclipse.jetty.websocket</groupId> + <artifactId>javax-websocket-server-impl</artifactId> + <version>${jetty9.version}</version> + <scope>test</scope> + </dependency> <!-- uncomment if WebSocket support is needed <dependency> diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/java/Start.java b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/java/Start.java index 37d546a9a8..092175b708 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/java/Start.java +++ b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/java/Start.java @@ -1,9 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ${package}; import java.lang.management.ManagementFactory; import javax.management.MBeanServer; +import org.apache.wicket.protocol.ws.javax.WicketServerEndpointConfig; import org.eclipse.jetty.jmx.MBeanContainer; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; @@ -14,6 +31,8 @@ import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.websocket.jsr356.server.ServerContainer; +import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer; /** * Separate startup class for people that want to run the examples directly. Use parameter @@ -26,7 +45,7 @@ public class Start * * @param args */ - public static void main(String[] args) + public static void main(String[] args) throws Exception { System.setProperty("wicket.configuration", "development"); @@ -43,7 +62,7 @@ public class Start server.addConnector(http); - Resource keystore = Resource.newClassPathResource("/keystore.p12"); + Resource keystore = Resource.newClassPathResource("/keystore"); if (keystore != null && keystore.exists()) { // if a keystore for a SSL certificate is available, start a SSL @@ -53,7 +72,7 @@ public class Start // use this certificate anywhere important as the passwords are // available in the source. - SslContextFactory sslContextFactory = new SslContextFactory(); + SslContextFactory sslContextFactory = new SslContextFactory.Server(); sslContextFactory.setKeyStoreResource(keystore); sslContextFactory.setKeyStorePassword("wicket"); sslContextFactory.setKeyManagerPassword("wicket"); @@ -83,6 +102,10 @@ public class Start // ServerContainer serverContainer = WebSocketServerContainerInitializer.configureContext(bb); // serverContainer.addEndpoint(new WicketServerEndpointConfig()); + // bb.getSessionHandler().setSessionCache(sessionCache); + + ServerContainer serverContainer = WebSocketServerContainerInitializer.initialize(bb); + serverContainer.addEndpoint(new WicketServerEndpointConfig()); // uncomment next line if you want to test with JSESSIONID encoded in the urls // ((AbstractSessionManager) // bb.getSessionHandler().getSessionManager()).setUsingCookies(false); diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-http.xml b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-http.xml index 7b39acb61c..51a50ff71f 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-http.xml +++ b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-http.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"> <!-- ============================================================= --> <!-- Configure the Jetty Server instance with an ID "Server" --> <!-- by adding a HTTP connector. --> diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-https.xml b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-https.xml index 35100e7c5d..c709c55e9c 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-https.xml +++ b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-https.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"> <!-- ============================================================= --> <!-- Configure a HTTPS connector. --> <!-- This configuration must be used in conjunction with jetty.xml --> diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-ssl.xml b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-ssl.xml index f23231bd72..af93d25154 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-ssl.xml +++ b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-ssl.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"> <!-- ============================================================= --> <!-- Configure a TLS (SSL) Context Factory --> <!-- This configuration must be used in conjunction with jetty.xml --> diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty.xml b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty.xml index fca91396f9..c1c8caa7b9 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty.xml +++ b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"> <!-- ============================================================= --> <!-- Configure a HTTP connector. --> <!-- ============================================================= -->
