(这似乎与https://stackoverflow.com/questions/5862085/weblogic10-3-ignores-postconsturt-method重复,但细节很少,没有得到回答)。
我有一个这样的 ManagedBean:
public class TestBean {
private String greeting = "Hello, World!";
public TestBean() {
}
public String getGreeting() {
System.out.println( "getGreeting called, returning " + this.greeting );
return greeting;
}
public void setGreeting( String message ) {
this.greeting = message;
}
@PostConstruct
public void prepareSomething() {
System.out.println( "\n\nPostConstruct called.\n\n" );
this.greeting += " (PostConstruct was called)";
}
}
在我的 xhtml 中,我只有Bean Message: #{TestBean.greeting}
. 但是,在访问页面时,该方法没有被调用,我得到的是
Bean Message: Hello, World!
而不是预期的
Bean Message: Hello, World! (PostConstruct was called)
getGreeting()
控制台确实显示来自该方法 的 sysout ,但不显示来自prepareSomething()
:
INFO: Added Library from: zip:/data/java/wl1034/user_projects/domains/wlrep1034/autodeploy/PCTest.ear/PCTest.war/WEB-INF/lib/jsf-facelets.jar!/META-INF/jstl-fn.taglib.xml
getGreeting called, returning Hello, World!
2011-05-12 10:36:11,720 DEBUG org.richfaces.skin.SkinFactoryImpl - Create new Skin instance for name DEFAULT
更多信息:我正在使用 JSF 1.2(使用来自 Weblogic 10.3.4 的 jar MW_HOME/common/deployable-libs/jsf-1.2.war!/WEB-INF/lib
)、Facelets 1.1.14、RichFaces 3.3.2。我有以下罐子WEB-INF/lib
:
commons-beanutils-1.7.0.jar
commons-digester-1.8.jar
commons-logging-1.1.1.jar
glassfish.jsf_1.0.0.0_1-2-15.jar
glassfish.jstl_1.2.0.1.jar
javax.jsf_1.1.0.0_1-2.jar
jsf-facelets.jar
log4j-1.2.16.jar
richfaces-api-3.3.2.SR1.jar
richfaces-impl-3.3.2.SR1.jar
richfaces-ui-3.3.2.SR1.jar
SimpleJSF.jar
wls.jsf.di.jar
我也尝试过放置/移除annotations-api.jar
,同样的症状。
如有必要,我可能会发布其他文件。