2018-05-25 プライバシーポリシーを改訂いたしました。

Wicketを使っているときによくあるエラーとして次のようなものがある

WicketMessage: Unable to find component with id 'hello' in [Page class = HelloWorld, id = 0, version = 0]. This means that you declared wicket:id=hello in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.
[markup = file:/***/***/NetBeansProjects/Test/build/web/WEB-INF/classes/HelloWorld.html

これはHTMLのwicket:idに対応するコンポーネントがJavaで追加されていないときに発生する。次のようにコンポーネントを作成したはいいが、追加をしてない場合などである

<html>
  <head>
    <title>Hello World!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <span wicket:id="hello">Hello World!</span>
 </body>
</html>
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;

public class HelloWorld extends WebPage{
    public HelloWorld(){
        Label label = new Label("hello", "Hello World!");
    }
}

逆にHTMLにwicket:idがないのにコンポーネントを追加した場合は下記のように例外が発生する

WicketMessage: The component(s) below failed to render. A common problem is that you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered).

1. [Component id = hello, page = HelloWorld, path = 6:hello.Label, isVisible = true, isVersioned = true]

Root cause:

org.apache.wicket.WicketRuntimeException: The component(s) below failed to render. A common problem is that you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered).

1. [Component id = hello, page = HelloWorld, path = 6:hello.Label, isVisible = true, isVersioned = true]

at org.apache.wicket.Page.checkRendering(Page.java:1116)
at org.apache.wicket.Page.renderPage(Page.java:914)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:231)
at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:104)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1172)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1243)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1331)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:363)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)