I’m not getting my wicket application running

Asked

Viewed 51 times

0

I would like to know how to solve this problem, to acquire more knowledge I am doing a small application.

<html>
<head>
</head>
<body>
    <h1>Wicket + Spring integration example</h1>
    <label wicket:id="msg"></label>
</body>
</html>

Java:

package br.com.ordem.servico.servicosautomotivos;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
import org.apache.wicket.spring.injection.annot.SpringBean;


public class SimplePage extends WebPage{

    @SpringBean
    private HelloService helloService;

    public SimplePage(PageParameters parameters) {
        Label label = new Label("msg", new Model<String>(helloService.getHelloWorldMsg()));
        this.add(label);
    }
}

    package br.com.ordem.servico.servicosautomotivos;

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

public class WicketApplication extends WebApplication{

    @Override
    public Class<? extends Page> getHomePage() {
        return SimplePage.class;
    }

}

Unexpected Runtimeexception

Wicketmessage: Can’t instantiate page using constructor public br.com.order.servico.servicosautomotivos.Simplepage(org.apache.wicket.Pageparameters) and argument

Root cause:

java.lang.Nullpointerexception at br.com.ordem.servico.servicosautomotivos.SimplePage.(Simplepage.java:16) at sun.reflect.Nativeconstructoraccessorimpl.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.apache.wicket.session.Defaultpagefactory.createPage(Defaultpagefactory.java:188) at org.apache.wicket.session.Defaultpagefactory.newPage(Defaultpagefactory.java:65) at org.apache.wicket.request.target.component.Bookmarkablepagerequesttarget.newPage(Bookmarkablepagerequesttarget.java:298) at org.apache.wicket.request.target.component.Bookmarkablepagerequesttarget.getPage(Bookmarkablepagerequesttarget.java:320) at org.apache.wicket.request.target.component.Bookmarkablepagerequesttarget.processEvents(Bookmarkablepagerequesttarget.java:234) at org.apache.wicket.request.Abstractrequestcycleprocessor.processEvents(Abstractrequestcycleprocessor.java:92) at org.apache.wicket.RequestCycle.processEventsAndRespond(Requestcycle.java:1250) at org.apache.wicket.RequestCycle.step(Requestcycle.java:1329) at org.apache.wicket.RequestCycle.Steps(Requestcycle.java:1436) at org.apache.wicket.RequestCycle.request(Requestcycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(Wicketfilter.java:486) at org.apache.wicket.protocol.http.WicketFilter.doFilter(Wicketfilter.java:319) at org.eclipse.Jetty.servlet.Servlethandler$Cachedchain.doFilter(Servlethandler.java:1668) at org.eclipse.Jetty.servlet.Servlethandler.doHandle(Servlethandler.java:581) at org.eclipse.Jetty.server.Handler.ScopedHandler.Handle(Scopedhandler.java:143) at org.eclipse.Jetty.security.Securityhandler.Handle(Securityhandler.java:548) at org.eclipse.Jetty.server.Session.SessionHandler.doHandle(Sessionhandler.java:226) at org.eclipse.Jetty.server.Handler.ContextHandler.doHandle(Contexthandler.java:1158) at org.eclipse.Jetty.servlet.Servlethandler.doScope(Servlethandler.java:511) at org.eclipse.Jetty.server.Session.SessionHandler.doScope(Sessionhandler.java:185) at org.eclipse.Jetty.server.Handler.ContextHandler.doScope(Contexthandler.java:1090) at org.eclipse.Jetty.server.Handler.ScopedHandler.Handle(Scopedhandler.java:141) at org.eclipse.Jetty.server.Handler.ContextHandlerCollection.Handle(Contexthandlercollection.java:213) at org.eclipse.Jetty.server.Handler.HandlerCollection.Handle(Handlercollection.java:109) at org.eclipse.Jetty.server.Handler.HandlerWrapper.Handle(Handlerwrapper.java:119) at org.eclipse.Jetty.server.Server.Handle(Server.java:517) at org.eclipse.Jetty.server.Httpchannel.Handle(Httpchannel.java:308) at org.eclipse.Jetty.server.Httpconnection.onFillable(Httpconnection.java:242) at org.eclipse.Jetty.io.Abstractconnection$Readcallback.succeeded(Abstractconnection.java:273) at org.eclipse.Jetty.io.Fillinterest.fillable(Fillinterest.java:95) at org.eclipse.Jetty.io.Selectchannelendpoint$2.run(Selectchannelendpoint.java:75) at org.eclipse.Jetty.util.thread.strategy.Executeproduceconsume.produceAndRun(Executeproduceconsume.java:213) at org.eclipse.Jetty.util.thread.strategy.Executeproduceconsume.run(Executeproduceconsume.java:147) at org.eclipse.Jetty.util.thread.QuedThreadPool.runJob(Queuedthreadpool.java:654) at org.eclipse.Jetty.util.thread.Queuedthreadpool$3.run(Queuedthreadpool.java:572) at java.lang.Thread.run(Unknown Source)

Complete stack:

org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor public br.com.ordem.servico.servicosautomotivos.SimplePage(org.apache.wicket.PageParameters) and argument at org.apache.wicket.session.Defaultpagefactory.createPage(Defaultpagefactory.java:212) at org.apache.wicket.session.Defaultpagefactory.newPage(Defaultpagefactory.java:65) at org.apache.wicket.request.target.component.Bookmarkablepagerequesttarget.newPage(Bookmarkablepagerequesttarget.java:298) at org.apache.wicket.request.target.component.Bookmarkablepagerequesttarget.getPage(Bookmarkablepagerequesttarget.java:320) at org.apache.wicket.request.target.component.Bookmarkablepagerequesttarget.processEvents(Bookmarkablepagerequesttarget.java:234) at org.apache.wicket.request.Abstractrequestcycleprocessor.processEvents(Abstractrequestcycleprocessor.java:92) at org.apache.wicket.RequestCycle.processEventsAndRespond(Requestcycle.java:1250) at org.apache.wicket.RequestCycle.step(Requestcycle.java:1329) at org.apache.wicket.RequestCycle.Steps(Requestcycle.java:1436) at org.apache.wicket.RequestCycle.request(Requestcycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(Wicketfilter.java:486)

java.lang.reflect.Invocationtargetexception at sun.reflect.Nativeconstructoraccessorimpl.newInstance0(Native Method) at sun.reflect.Nativeconstructoraccessorimpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.apache.wicket.session.Defaultpagefactory.createPage(Defaultpagefactory.java:188) at org.apache.wicket.session.Defaultpagefactory.newPage(Defaultpagefactory.java:65) at org.apache.wicket.request.target.component.Bookmarkablepagerequesttarget.newPage(Bookmarkablepagerequesttarget.java:298) at org.apache.wicket.request.target.component.Bookmarkablepagerequesttarget.getPage(Bookmarkablepagerequesttarget.java:320) at org.apache.wicket.request.target.component.Bookmarkablepagerequesttarget.processEvents(Bookmarkablepagerequesttarget.java:234) at org.apache.wicket.request.Abstractrequestcycleprocessor.processEvents(Abstractrequestcycleprocessor.java:92) at org.apache.wicket.RequestCycle.processEventsAndRespond(Requestcycle.java:1250) at org.apache.wicket.RequestCycle.step(Requestcycle.java:1329) at org.apache.wicket.RequestCycle.Steps(Requestcycle.java:1436) at org.apache.wicket.RequestCycle.request(Requestcycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(Wicketfilter.java:486)

display page view

  • Copy the generated and posted error log and text and not image format please.

2 answers

0

I believe that the Simplepage class needs a default constructor, as in the example below:


import org.apache.wicket.protocol.http.WebApplication;
public class HelloWorldApplication extends WebApplication {
    public HelloWorldApplication() {
    }
    /**
     * @see org.apache.wicket.Application#getHomePage()
     */
    @Override
    public Class getHomePage() {
        return HelloWorld.class;
    }
}

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

Example of Hello World in Wicket

  • I still have the same problem!

  • Your Label has get and set?

  • user5515 am using wicket label, I believe you have yes!

  • What’s in Helloservice? This label could be added on the screen like this: add(new Label("msg", "Hello World!"));

0

The problem you’re having is java.lang.Nullpointerexception on line 16, which I’m pretty sure is caused by dependency injection.

  @SpringBean
  private HelloService helloService;

That your service is probably returning null and this is causing null Pointer.

To know what is causing the problem in addiction injection you need to pass information about your Helloservice.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.