Naked metal gate / tomcat HelloWorld example

I am new to the wicket and would like to deploy a simple well-known helloworld from wicket examples, but without IDE, ant or maven. What I've done:

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">

    <display-name>Wicket Examples</display-name>
    <filter>
        <filter-name>HelloWorldApplication</filter-name>
        <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
          <param-name>applicationClassName</param-name>
          <param-value>HelloWorldApplication</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>HelloWorldApplication</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

HelloWorld.html:

<html>
  <body>
    <span wicket:id="message">Message goes here!</span>
  </body>
</html>

HelloWorld.java:

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;

public class HelloWorld extends WebPage
{
  public HelloWorld()
  {
    add(new Label("message", "Hello World!"));
  }
}

HelloWorldApplication.java:

import org.apache.wicket.protocol.http.WebApplication;

public class HelloWorldApplication extends WebApplication
{
    public Class getHomePage()
    {
        return HelloWorld.class;
    }
}

Wicket HelloWorld.war:

WEB-INF/
WEB-INF/web.xml
WEB-INF/classes/
WEB-INF/classes/HelloWorldApplication.class
WEB-INF/classes/HelloWorld.class
WEB-INF/classes/HelloWorld.html
WEB-INF/lib/
WEB-INF/lib/wicket-1.4.15.jar
WEB-INF/lib/slf4j-api.jar

I'm not sure if I need slf4j-api.jar for this simple example

When deployed to tomcat, http: // localhost: 8080 / wicket-HelloWorld / gives:

The requested resource () is unavailable

What am I doing wrong?

+3
source share
2 answers

I was able to make it work:

1.- I added slf4j-jdk14.jar. The Manning Wicket in Chapter 15 bonus action was incorrect. It only reports add slf4j-api.jar

2.- wicket-1.4.15.jar WEB-INF/lib. catalina.properties shared.loader $CATALINA_BASE/lib ; , - .

, javac. , - , -. Maven

+1

, . :

$ mvn archetype:generate

wicket-archetype-quickstart (189 ), 1.4.15...

$ mvn tomcat:run

http://localhost:8080/wicket, .

$ mvn package
$ cd target/wicket-1.0-SNAPSHOT/WEB-INF/lib

:

  • log4j-1.2.14.jar
  • SLF4J--1.5.8.jar
  • SLF4J-log4j12-1.5.8.jar
  • 1.4.15.jar

:

$ cd src/main
$ tree

:

.
|-- java
|   `-- com
|       `-- blogspot
|           `-- nurkiewicz
|               |-- HomePage.html
|               |-- HomePage.java
|               `-- WicketApplication.java
|-- resources
|   `-- log4j.properties
`-- webapp
    `-- WEB-INF
        `-- web.xml

, maven (, - ), . .

0

Source: https://habr.com/ru/post/1793680/


All Articles