Singleton WildFly 12 Wicket 7.10-为什么只有第一个线程可以访问应用程序?
每个请求都尝试创建新的单例实例,但由于使用Application.get()而失败,并出现错误:Singleton WildFly 12 Wicket 7.10-为什么只有第一个线程可以访问应用程序?,singleton,wicket-7,application-scope,wildfly-12,Singleton,Wicket 7,Application Scope,Wildfly 12,每个请求都尝试创建新的单例实例,但由于使用Application.get()而失败,并出现错误: There is no application attached to current thread default 同样的代码也适用于WildFly 8.2和Wicket 6.20。因此,有两个问题: 每个请求处理程序线程的行为就像它在自己的JVM中运行一样,不与其他线程共享静态字段 创建初始请求处理程序线程之后的每个请求处理程序线程都没有附加应用程序 最简单的例子: package com.e
There is no application attached to current thread default
同样的代码也适用于WildFly 8.2和Wicket 6.20。因此,有两个问题:
package com.example.web;
public class SiteConstants
{
public static final String CONTEXT_PATH = WebApp.get().getServletcontext().getContextPath() + "/";
}
主页使用
SiteConstants.CONTEXT_PATH
首页的第一个请求是有效的。第二个调用加载到另一个线程中,并在上失败
WebApp.get().getServletcontext().getContextPath() + "/";
因为WebApp.get()抛出
您应该在回复评论中提供此行为的最小示例,添加最小示例。
org.apache.wicket.WicketRuntimeException: There is no application attached to current thread default task-1