启动Web应用程序时出现IllegalStateException - Spring + Wicket

时间:2015-12-07 21:04:18

标签: java spring tomcat wicket

我正在尝试使用Tomcat 7运行我的webapp但是我得到了这个例外:

GRAVE:Excepciónrancandofiltro wicket.filter java.lang.IllegalStateException:找不到类型为[org.apache.wicket.protocol.http.WebApplication]的bean     在org.apache.wicket.spring.SpringWebApplicationFactory.createApplication(SpringWebApplicationFactory.java:160)     在org.apache.wicket.spring.SpringWebApplicationFactory.createApplication(SpringWebApplicationFactory.java:139)     在org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:308)     在org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:286)     在org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)     在org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)     在org.apache.catalina.core.ApplicationFilterConfig。(ApplicationFilterConfig.java:105)     在org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4841)     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5535)     在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)     在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1574)     在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)     在java.lang.Thread.run(未知来源)

这是我的web.xml:

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”     版本= “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>

使用WebApplication的唯一类是我的类MounterURL:

公共课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);
}

MyApplication使用此类:

公共类MyApplication扩展了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);
}

此类在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“&gt;

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

谢谢!

1 个答案:

答案 0 :(得分:2)

您似乎错过了WebApplication类型的bean。您是否扩展了Wickets WebApplication类并将其添加为bean。例如@Configuration?