0

I am trying to run my webapp with Tomcat 7 but i am getting this exception:

GRAVE: Excepción arrancando filtro wicket.filter java.lang.IllegalStateException: bean of type [org.apache.wicket.protocol.http.WebApplication] not found at org.apache.wicket.spring.SpringWebApplicationFactory.createApplication(SpringWebApplicationFactory.java:160) at org.apache.wicket.spring.SpringWebApplicationFactory.createApplication(SpringWebApplicationFactory.java:139) at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:308) at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:286) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4841) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5535) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

This is my web.xml:

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<display-name>Archetype Created Web Application</display-name>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>       
        classpath:*/META-INF/persistence-context.xml,
        classpath:*/META-INF/service-context.xml,
        classpath:*/META-INF/web-context.xml
    </param-value>
</context-param>

<context-param>
    <param-name>configuration</param-name>
    <param-value>development</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<filter>
    <filter-name>wicket.filter</filter-name>
    <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
    <init-param>
        <param-name>applicationFactoryClassName</param-name>
        <param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>wicket.filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
</filter-mapping>

<session-config>
    <session-timeout>7200</session-timeout>
</session-config>

The only class that use WebApplication is my class MounterURL:

public class MounterURL {

private WebApplication webApplication;

public MounterURL(final WebApplication webApplication) {
    this.webApplication = webApplication;
}

/**
 * @param mountPath
 *            Mount path (not empty)
 * @param pageClass
 *            Class of mounted page (not null)
 * @param parameters
 *            The parameter names (not null)
 */
public void mount(final String mountPath,final Class<? extends WebPage> pageClass, final String... parameters) {
    webApplication.mountPage(mountPath, pageClass);
}

This class is used by MyApplication :

public class MyApplication extends AuthenticatedWebApplication{

private MounterURL aMounterURL;

private GeneralService generalService;

@Override
protected Class<? extends AbstractAuthenticatedWebSession> getWebSessionClass() {
     return WebSession.class;
}

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

public String getContextPath() {
    return this.getServletContext().getContextPath();
}

@Override
public void init() {
    **aMounterURL = new MounterURL(this);**

    this.getComponentInstantiationListeners().add(new SpringComponentInjector(this));

    this.mountUrl("home", Home.class, "");
}

private void mountUrl(final String mountPath, final Class<? extends WebPage> pageClass, final String... parameters) {
    aMounterURL.mount(mountPath, pageClass, parameters);
}

This class is created in web.context.xml

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">

<bean id="wicketApplication" class="home.MyApplication">
    <property name="generalService" ref="services.general"></property>
</bean>

Thanks!

1 Answer 1

2

It seems that you missing a bean of the type WebApplication. Did you extend Wickets WebApplication class and added it as a bean. e.g with @Configuration?

5
  • The only class i have is public class MyApplication extends AuthenticatedWebApplication
    – evilkorona
    Dec 7, 2015 at 22:02
  • You have to add it to the Spring context as a bean if you want to use applicationFactoryClassName=SpringWebApplicationFactory.
    – martin-g
    Dec 7, 2015 at 22:06
  • it is already added <bean id="wicketApplication" class="home.MyApplication"> <property name="generalService" ref="services.general"></property> </bean> in web-context.xml and web.xml calls it
    – evilkorona
    Dec 7, 2015 at 22:10
  • I tried this <init-param> <param-name>applicationFactoryClassName</param-name> <param-value>home.MyApplication</param-value> </init-param> but is the same
    – evilkorona
    Dec 7, 2015 at 22:17
  • If you don't want to waste you time with configuration problems of spring and wicket you should look at: goo.gl/sy2G62
    – meleagros
    Dec 8, 2015 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.