当ManagedBean包在JAR中并由EAR提供时,JSF@PostConstruct不会触发
我知道这个问题在中得到了回答,但在我的例子中,JAR(拥有ManagedBean)和WAR(通过将视图解析为JAR中的资源来调用ManagedBean)被打包在一个EAR中 我正在使用: Weblogic 12c版本 JSF JSF_2.0.0.0_2-1-20.jar(weblogic提供) JAR在正确的位置包含faces-config.xml,如下所示:当ManagedBean包在JAR中并由EAR提供时,JSF@PostConstruct不会触发,jsf,weblogic,Jsf,Weblogic,我知道这个问题在中得到了回答,但在我的例子中,JAR(拥有ManagedBean)和WAR(通过将视图解析为JAR中的资源来调用ManagedBean)被打包在一个EAR中 我正在使用: Weblogic 12c版本 JSF JSF_2.0.0.0_2-1-20.jar(weblogic提供) JAR在正确的位置包含faces-config.xml,如下所示: 0 Mon May 14 12:20:08 CST 2018 META-INF/ 125 Mon May 14 12:2
0 Mon May 14 12:20:08 CST 2018 META-INF/
125 Mon May 14 12:20:06 CST 2018 META-INF/MANIFEST.MF
0 Mon May 14 12:20:06 CST 2018 META-INF/resources/
0 Mon May 14 12:20:06 CST 2018 gt/
0 Mon May 14 12:20:06 CST 2018 gt/com/
0 Mon May 14 12:20:06 CST 2018 gt/com/leta/
0 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/
0 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/errorhandlers/
0 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/pojos/
0 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/utilities/
4460 Mon May 14 12:20:06 CST 2018 META-INF/resources/menu.xhtml
4403 Mon May 14 12:20:06 CST 2018 META-INF/resources/login.xhtml
338 Mon May 14 12:20:06 CST 2018 META-INF/faces-config.xml
922 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/errorhandlers/CustomExceptionHandlerFactorySisleta.class
4381 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/errorhandlers/CustomExceptionHandlerSisLeta.class
15480 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/utilities/FunctionsSecurity.class
1146 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/utilities/FaceletsResourceResolver.class
13435 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/utilities/Menu.class
4158 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/utilities/FilterApp.class
2746 Mon May 14 12:20:06 CST 2018 gt/com/leta/security/utilities/SessionListener.class
0 Mon May 14 12:20:08 CST 2018 META-INF/maven/
0 Mon May 14 12:20:08 CST 2018 META-INF/maven/gt.com.leta/
0 Mon May 14 12:20:08 CST 2018 META-INF/maven/gt.com.leta/Security/
5030 Mon May 14 10:57:24 CST 2018 META-INF/maven/gt.com.leta/Security/pom.xml
105 Mon May 14 12:20:08 CST 2018 META-INF/maven/gt.com.leta/Security/pom.properties
ManagedBean是这样的:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gt.com.late.security.;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import org.primefaces.context.RequestContext;
import org.primefaces.model.menu.DefaultMenuItem;
import org.primefaces.model.menu.DefaultMenuModel;
import org.primefaces.model.menu.DefaultSubMenu;
/**
*
* @author
*/
@ManagedBean(name="menu", eager = true)
@SessionScoped
public class Menu {
private String ...
private String ....
/**
* Creates a new instance of Menu
*/
public Menu() {
}
@PostConstruct
public void init(){
/*
This does'nt trigger
*/
}
}
WAR使用FaceletsResourceResolver从同一个JAR获取视图,这非常好用
<context-param>
<param-name>facelets.RESOURCE_RESOLVER</param-name>
<param-value>com.example.FaceletsResourceResolver</param-value>
</context-param>
facelets.RESOURCE\u解析器
com.example.FaceletsResourceResolver
如果我想把它放在耳朵里,处理这种模式有什么不同吗?可能是@Kukeltje的复制品我看到Weld的行为可能与weblogic相同,但我不知道如何确认它。你能建议我怎么做吗?(顺便说一句,很抱歉迟到了)。很抱歉,我没有weblogic,也没有任何尝试运行它的动机