我正在嘗試使用通用樹支持bean來工作。我有一個名爲ACLTree的泛型類,然後是它的一個實現。 在我的JSF文檔中,我嘗試訪問每個#{mybackingbean.property}的值。 但我得到一個ELException:使用EL訪問繼承屬性/方法時出錯
javax.el.ELException: /modules/useradmin/acl.xhtml @30,55 value="#{ACOTree.root}": java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class de.xy.jsf.beans.ACLTree with modifiers "public"
我不是很熟悉泛型和反射API的概念,所以也許這是根本不可能的。
堆棧跟蹤:
javax.faces.FacesException: javax.el.ELException: /modules/useradmin/rights.xhtml @30,55 value="#{ACOTree.root}": java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class de.xy.jsf.beans.ACLTree with modifiers "public"
at javax.faces.component.UIData.getValue(UIData.java:580)
at org.ajax4jsf.component.UIDataAdaptorBase.getValue(UIDataAdaptorBase.java:1647)
at org.richfaces.component.UITree.createDataModel(UITree.java:679)
at org.ajax4jsf.component.UIDataAdaptorBase.getExtendedDataModel(UIDataAdaptorBase.java:621)
at org.ajax4jsf.component.UIDataAdaptorBase.setRowKey(UIDataAdaptorBase.java:339)
at org.richfaces.renderkit.TreeRendererBase.writeContent(TreeRendererBase.java:688)
at org.richfaces.renderkit.TreeRendererBase.encodeChildren(TreeRendererBase.java:629)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:827)
at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:200)
at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:195)
at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:827)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:233)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:270)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:827)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:883)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:827)
at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:279)
at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
at org.richfaces.renderkit.TabRendererBase.encodeChildren(TabRendererBase.java:149)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:827)
at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:266)
at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:261)
at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:827)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:883)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:889)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:578)
at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at cz.softeu.rewriter.RewriterFilter.doFilter(RewriterFilter.java:144)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:636)
Caused by: javax.el.ELException: /modules/useradmin/rights.xhtml @30,55 value="#{ACOTree.root}": java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class de.christianvette.boombox.jsf.beans.ACLTree with modifiers "public"
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
at javax.faces.component.UIData.getValue(UIData.java:577)
... 75 more
Caused by: java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class de.xy.jsf.beans.ACLTree with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:95)
at java.lang.reflect.Method.invoke(Method.java:607)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:58)
at com.sun.el.parser.AstValue.getValue(Unknown Source)
at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
... 76 more
泛型類:
abstract class ACLTree<T>{
private static final Logger log = Logger.getLogger(ACLTree.class);
public TreeNodeImpl<NodeData> root = null;
public TreeNodeImpl<NodeData> nodes = new TreeNodeImpl<NodeData>();
public ACLTree() {
log.debug("constructor of generic class");
}
public TreeNodeImpl<NodeData> getNodes() {
return nodes;
}
public void setNodes(TreeNodeImpl<NodeData> nodes) {
this.nodes = nodes;
}
public TreeNodeImpl<NodeData> getRoot() {
log.debug("Entering getRoot()");
if(root == null) buildTree();
return root;
}
public void setRoot(TreeNodeImpl root) {
this.root = root;
}
public TreeNodeImpl createTreeNode(ACLObject item) {
}
abstract Collection<T> getData();
}
實現:
public class ACOTree extends ACLTree<ACO>{
@Override
public Collection<ACO> getData() {
return AclManagerImpl.getInstance().getAllACOs();
}
}
什麼是ACOTree定義爲?它試圖訪問的財產是否有吸氣? (即'root') – casablanca 2010-07-18 23:38:28
ACOTree擴展了名爲ACLTree的泛型類,因此getter和setter在泛型類中定義(公共),並且只在ACOTree中繼承。 – Chris 2010-07-18 23:51:22
您正在使用哪種EL實現/版本?或者,如果您沒有使用特定版本,您使用的是哪個servletcontainer impl/version?如果您還不知道,只需更新您的問題以包含完整的堆棧跟蹤。 – BalusC 2010-07-19 01:07:35