Seam组件代码如下:
- Java code
import java.util.LinkedHashMap;import java.util.Map;import javax.ejb.Stateless;import org.jboss.seam.ScopeType;import org.jboss.seam.annotations.Create;import org.jboss.seam.annotations.Name;import org.jboss.seam.annotations.Scope;@Stateless@Name("roleSet")@Scope(ScopeType.APPLICATION)public class RoleSetBean implements RoleSet { private final String[] roles = { "系统管理员", "财务", "出纳", "总经理", "项目经理" }; private Map<String, String> roleItems = new LinkedHashMap<String, String>(); @Create public void loadRoleItems() { roleItems.clear(); for (int i = 0; i < roles.length; i++) { roleItems.put(roles[i], roles[i]); } } public Map<String, String> getRoleItems() { return roleItems; }}
发布时报错,错误信息如下:
16:12:55,437 ERROR [[/xhoa]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
java.lang.RuntimeException: Could not create Component: roleSet
at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1178)
at org.jboss.seam.init.Initialization.installComponents(Initialization.java:1094)
at org.jboss.seam.init.Initialization.init(Initialization.java:728)
...
------解决方案--------------------------------------------------------
你把@Scope(ScopeType.APPLICATION)去掉试试看。
我记得stateless session bean总是存在于无状态上下文中,不能放在应用程序上下文中。