【发布时间】:2015-05-01 03:40:08
【问题描述】:
我有这样的依赖:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.10</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.10</version>
</dependency>
和托管bean:
@ManagedBean(eager = true)
@ApplicationScoped
public class AppBean implements Serializable{
private List<SelectItem> someEntitySI = null;
@PostConstruct
public void init(){
try {
someEntitySI = new ArrayList<SelectItem>();
List<SomeEntity> types = Factory.getInstance().getSomeEntityDAO().getAllSomeEntities();
for(SomeEntity type : types) {
someEntitySI .add(new SelectItem(someEntity.getId(), someEntity.getName()));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
当我在调用 @PostConstruct 的 Tomcat 上部署它时,但是当我在 Glassfish(v4.1) 上部署相同的代码时,@PostConstruct 不起作用。为什么会这样?
【问题讨论】:
-
人不是读心术。您需要指定“它有效”的含义并描述导致您得出“无效”结论的结果。
标签: tomcat jsf-2 glassfish-4 java-ee-7