UriFragmentUtility导致servlet异常

时间:2012-01-24 00:38:38

标签: vaadin url-pattern servletexception uri-fragment

当我关注如何正确使用UriFragmentUtility的这个vaadin:https://vaadin.com/book/-/page/advanced.urifu.html教程时,我最终创建了对象,在尝试将此组件添加到我的主窗口后,它失败了以下例外:

SEVERE: Servlet.service() for servlet [Dugsi_Manager Vaadin Application Servlet] in context with path [/Dugsi_Manager] threw exception [java.lang.UnsupportedOperationException] with root cause
java.lang.UnsupportedOperationException
    com.vaadin.ui.CustomComponent.addComponent(CustomComponent.java:218)
    com.vaadin.ui.Panel.addComponent(Panel.java:301)
    com.vaadin.ui.Window.addComponent(Window.java:281)
    org.bixin.dugsi.web.DugsiManagerApplication.init(DugsiManagerApplication.java:44)
    com.vaadin.Application.start(Application.java:554)
    com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1213)
    com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:484)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:359)
    org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:275)
    org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
    org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:344)
    org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:272)
    org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

以下是我将对象添加到主应用程序类的方法:

//Thread Local to create instances of our application
private static ThreadLocal<DugsiManagerApplication> threadLocal = new ThreadLocal<DugsiManagerApplication>();
@Override
public void init() {
    setInstance(this); // immediate access to the app
    //Window homeWindow = createNewWindow();
    Subject currentUser = SecurityUtils.getSubject();
    // Create the URI fragment utility
    Window window = createLoginWindow();    

    setMainWindow(window);
    final UriFragmentUtility urifu = new UriFragmentUtility();
    window.addComponent(urifu);

}

在本教程中,它讨论了URI主要部分(地址+路径+可选查询参数),我的路径设置为/ Dugsi_Manager(web.xml),如果它在添加urifu对象后不再启动https://localhost:8080/Dugsi_Manger#login

编辑:添加了LoginWindow的声明:

public Window createLoginWindow(){
     final Window loginWindow = new LoginWindow();

    //remove the window if closed to avoid memory leaks
    loginWindow.addListener(new CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            if (getMainWindow() != loginWindow) {
                DugsiManagerApplication.this.removeWindow(loginWindow);
            }
        }
    });
    return loginWindow;
}

\ **似乎UriFragmentUtility对象可以添加到标准Vaadin窗口,但不适用于使用createLoginWindow函数创建的窗口?我无法弄清楚为什么?

1 个答案:

答案 0 :(得分:0)

CustomComponent的addComponent方法抛出异常。所以我猜CustomComponent是窗口的内容。要解决此问题,请将UriFragmentUtility直接添加到CustomComponent的组合根而不是

的布局中
window.addComponent(urifu);