UriFragmentUtility 导致 servlet 异常

发布于 2024-12-28 17:19:54 字数 3371 浏览 1 评论 0原文

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

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 函数创建的窗口?我不明白为什么?

As i was following this vaadin: https://vaadin.com/book/-/page/advanced.urifu.html tutorial on how to properly uses the UriFragmentUtility, i ended up creating the object and after trying to add this component to my main window, it fails with the following exception:

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)

Here is how i added the object to my main application class:

//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);

}

In the tutorial it talks about the URI primary part (address + path + optional query parameters), my path is set as /Dugsi_Manager (web.xml) should it not then start after adding the urifu object as https://localhost:8080/Dugsi_Manger#login?

Edit: Added the declaration of the 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;
}

\
** It seems as the UriFragmentUtility object can be added to a standard Vaadin Window but does not work on a window created with my createLoginWindow function? i cannot figure out why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感情旳空白 2025-01-04 17:19:54

该异常是由 CustomComponent 的 addComponent 方法引发的。所以我猜 CustomComponent 是一个窗口的内容。要解决此问题,请将 UriFragmentUtility 直接添加到 CustomComponent 的组合根布局,而不是

window.addComponent(urifu);

The exception is thrown by CustomComponent's addComponent method. So I guess CustomComponent is the content of a window. To fix the problem, add your UriFragmentUtility directly to the layout that's CustomComponent's composition root instead of

window.addComponent(urifu);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文