Valid CDI scopes for Singleton EJBs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This is legal | |
@Singleton | |
@Startup | |
@ApplicationScoped | |
public class Singleton1 { | |
@PostConstruct | |
public void init(){ | |
System.out.println(Singleton1.class.getName() + " constructed successfully on "+ new Date().toString()); | |
} | |
} | |
//CDI container will not be happy seeing this | |
@Singleton | |
@Startup | |
@RequestScoped | |
public class Singleton1 { | |
@PostConstruct | |
public void init(){ | |
System.out.println(Singleton1.class.getName() + " constructed successfully on "+ new Date().toString()); | |
} | |
} | |
Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-000083: Scope interface javax.enterprise.context.RequestScoped is not allowed on singleton enterprise beans for class cdi.ejb.integration.Singleton1. Only @Dependent and @ApplicationScoped is allowed on singleton session beans. | |
at org.jboss.weld.bean.SessionBean.checkScopeAllowed(SessionBean.java:125) | |
at org.jboss.weld.bean.SessionBean.internalInitialize(SessionBean.java:101) | |
at org.jboss.weld.bean.RIBean.initialize(RIBean.java:66) | |
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$5.doWork(ConcurrentBeanDeployer.java:118) | |
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$5.doWork(ConcurrentBeanDeployer.java:115) | |
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:59) | |
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:52) | |
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_25] | |
... 3 more |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment