SessionBean 实例 LoggerFactory.getLogger 上的 StackOverFlowError
StackOverFlowError on instance LoggerFactory.getLogger on a SessionBean
环境:
- Jboss 7.2
- Java11
我在 LoggerFactory.getLogger 的实例上得到 java.lang.WhosebugError,但我不知道为什么会这样。
它得到 org.jboss.logmanner 而不是 org.slf4j,听起来对吗?
错误日志
08:50:58,787 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-1) Error Rendering View[/principal.xhtml]: javax.enterprise.inject.CreationException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.base/java.lang.Class.newInstance(Class.java:584)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
at java.base/java.security.AccessController.doPrivileged(Native Method)
...
Caused by: java.lang.WhosebugError
at java.base/java.lang.StackStreamFactory$AbstractStackWalker.callStackWalk(Native Method)
at java.base/java.lang.StackStreamFactory$AbstractStackWalker.beginStackWalk(StackStreamFactory.java:370)
at java.base/java.lang.StackStreamFactory$AbstractStackWalker.walk(StackStreamFactory.java:243)
at java.base/java.lang.StackWalker.walk(StackWalker.java:498)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.JDKSpecific.findCallingClasses(JDKSpecific.java:72)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.ClassLoaderLogContextSelector.run(ClassLoaderLogContextSelector.java:93)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.ClassLoaderLogContextSelector.run(ClassLoaderLogContextSelector.java:91)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.ClassLoaderLogContextSelector.getLogContext(ClassLoaderLogContextSelector.java:121)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.ThreadLocalLogContextSelector.getLogContext(ThreadLocalLogContextSelector.java:55)
at org.jboss.as.logging@6.0.11.Final-redhat-00001//org.jboss.as.logging.logmanager.WildFlyLogContextSelectorImpl.getLogContext(WildFlyLogContextSelectorImpl.java:56)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.LogContext.getLogContext(LogContext.java:301)
at org.slf4j.impl@1.0.3.GA-redhat-2//org.slf4j.impl.Slf4jLoggerFactory.getLogger(Slf4jLoggerFactory.java:37)
at org.slf4j@1.7.22.redhat-2//org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:366)
at org.slf4j@1.7.22.redhat-2//org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:391)
at deployment.accfor2.ear.accfor-back.war//es.caib.accfor.presentation.back.security.SecurityBean.<init>(SecurityBean.java:34)
at jdk.internal.reflect.GeneratedConstructorAccessor124.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
...
at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.cdi.ManagedPropertyProducer.evaluateExpressionGet(ManagedPropertyProducer.java:111)
at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.cdi.ManagedPropertyProducer.lambda$new[=11=](ManagedPropertyProducer.java:83)
at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.cdi.CdiProducer.create(CdiProducer.java:128)
at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.cdi.ManagedPropertyProducer.create(ManagedPropertyProducer.java:61)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.contexts.unbound.DependentContextImpl.get(DependentContextImpl.java:70)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:700)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:800)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.util.Beans.injectBoundFields(Beans.java:336)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:347)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.injection.producer.ResourceInjector.proceed(ResourceInjector.java:69)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:71)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:159)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.util.bean.IsolatedForwardingBean.create(IsolatedForwardingBean.java:45)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.contexts.PassivatingContextWrapper$AbstractPassivatingContextWrapper.get(PassivatingContextWrapper.java:76)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:177)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:700)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.module.web.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
SecurityBean
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
...
@Named
@SessionScoped
public class SecurityBean implements Serializable {
public static final String USER = "user";
protected final Logger log = LoggerFactory.getLogger(getClass()); //Error
...
pom.xml 可能相关的依赖项
...
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-8.0</artifactId>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
...
有效pom.xml
...
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jul-to-slf4j-stub</artifactId>
<version>1.0.1.Final-redhat-3</version>
</dependency>
<dependency>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logmanager</artifactId>
<version>1.0.4.GA-redhat-00001</version>
</dependency>
...
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>1.7.22.redhat-2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<scope>compile</scope>
</dependency>
...
我不知道为什么日志没有显示 jsf bean 的任何问题,但问题是通过注入 @ManagedProperty 相互之间存在循环依赖关系。
所以我唯一要做的就是让他们独立。
SecurityBean
@Named
@SessionScoped
public class SecurityBean {
...
@Inject
@ManagedProperty(value = "#{sessionBean}")
private SessionBean sessionBean;
..
SessionBean
@Named
@SessionScoped
public class SessionBean {
...
@Inject
@ManagedProperty(value = "#{securityBean}")
private SessionBean sessionBean;
...
环境:
- Jboss 7.2
- Java11
我在 LoggerFactory.getLogger 的实例上得到 java.lang.WhosebugError,但我不知道为什么会这样。 它得到 org.jboss.logmanner 而不是 org.slf4j,听起来对吗?
错误日志
08:50:58,787 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-1) Error Rendering View[/principal.xhtml]: javax.enterprise.inject.CreationException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.base/java.lang.Class.newInstance(Class.java:584)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.security.NewInstanceAction.run(NewInstanceAction.java:33)
at java.base/java.security.AccessController.doPrivileged(Native Method)
...
Caused by: java.lang.WhosebugError
at java.base/java.lang.StackStreamFactory$AbstractStackWalker.callStackWalk(Native Method)
at java.base/java.lang.StackStreamFactory$AbstractStackWalker.beginStackWalk(StackStreamFactory.java:370)
at java.base/java.lang.StackStreamFactory$AbstractStackWalker.walk(StackStreamFactory.java:243)
at java.base/java.lang.StackWalker.walk(StackWalker.java:498)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.JDKSpecific.findCallingClasses(JDKSpecific.java:72)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.ClassLoaderLogContextSelector.run(ClassLoaderLogContextSelector.java:93)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.ClassLoaderLogContextSelector.run(ClassLoaderLogContextSelector.java:91)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.ClassLoaderLogContextSelector.getLogContext(ClassLoaderLogContextSelector.java:121)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.ThreadLocalLogContextSelector.getLogContext(ThreadLocalLogContextSelector.java:55)
at org.jboss.as.logging@6.0.11.Final-redhat-00001//org.jboss.as.logging.logmanager.WildFlyLogContextSelectorImpl.getLogContext(WildFlyLogContextSelectorImpl.java:56)
at org.jboss.logmanager@2.1.5.Final-redhat-00001//org.jboss.logmanager.LogContext.getLogContext(LogContext.java:301)
at org.slf4j.impl@1.0.3.GA-redhat-2//org.slf4j.impl.Slf4jLoggerFactory.getLogger(Slf4jLoggerFactory.java:37)
at org.slf4j@1.7.22.redhat-2//org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:366)
at org.slf4j@1.7.22.redhat-2//org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:391)
at deployment.accfor2.ear.accfor-back.war//es.caib.accfor.presentation.back.security.SecurityBean.<init>(SecurityBean.java:34)
at jdk.internal.reflect.GeneratedConstructorAccessor124.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
...
at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.cdi.ManagedPropertyProducer.evaluateExpressionGet(ManagedPropertyProducer.java:111)
at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.cdi.ManagedPropertyProducer.lambda$new[=11=](ManagedPropertyProducer.java:83)
at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.cdi.CdiProducer.create(CdiProducer.java:128)
at com.sun.jsf-impl@2.3.5.SP2-redhat-00001//com.sun.faces.cdi.ManagedPropertyProducer.create(ManagedPropertyProducer.java:61)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.contexts.unbound.DependentContextImpl.get(DependentContextImpl.java:70)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:700)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.manager.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:800)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.util.Beans.injectBoundFields(Beans.java:336)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:347)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.injection.producer.ResourceInjector.proceed(ResourceInjector.java:69)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:71)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:159)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.util.bean.IsolatedForwardingBean.create(IsolatedForwardingBean.java:45)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.contexts.PassivatingContextWrapper$AbstractPassivatingContextWrapper.get(PassivatingContextWrapper.java:76)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.get(ContextualInstanceStrategy.java:177)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:700)
at org.jboss.weld.core@3.0.5.Final-redhat-00001//org.jboss.weld.module.web.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:107)
SecurityBean
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
...
@Named
@SessionScoped
public class SecurityBean implements Serializable {
public static final String USER = "user";
protected final Logger log = LoggerFactory.getLogger(getClass()); //Error
...
pom.xml 可能相关的依赖项
...
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-8.0</artifactId>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
...
有效pom.xml
...
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jul-to-slf4j-stub</artifactId>
<version>1.0.1.Final-redhat-3</version>
</dependency>
<dependency>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logmanager</artifactId>
<version>1.0.4.GA-redhat-00001</version>
</dependency>
...
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>1.7.22.redhat-2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<scope>compile</scope>
</dependency>
...
我不知道为什么日志没有显示 jsf bean 的任何问题,但问题是通过注入 @ManagedProperty 相互之间存在循环依赖关系。 所以我唯一要做的就是让他们独立。
SecurityBean
@Named
@SessionScoped
public class SecurityBean {
...
@Inject
@ManagedProperty(value = "#{sessionBean}")
private SessionBean sessionBean;
..
SessionBean
@Named
@SessionScoped
public class SessionBean {
...
@Inject
@ManagedProperty(value = "#{securityBean}")
private SessionBean sessionBean;
...