JBoss 6 上的 JSF 1.2 和 EL 表达式未得到解析
我已经用这个头撞墙几个小时了,我不知道为什么会发生这种情况...
最近我们开始从 JBoss 4.2.3 迁移到 JBoss 6 Final。我们正在使用 JSF 1.2。我已经成功地使应用程序适应新的 JBoss(主要是通过从 WEB-INF/lib 中删除一些 JAR 并稍微调整一下 web.xml)并且应用程序启动良好。
问题是有些 EL 表达式没有得到解析,而另一些则得到解析。我还在日志中收到 0 个异常或警告。
我有一个名为“mapContext”的 bean,它是在 JSF xml 配置文件之一中定义的。它正在被创建得很好。在我的 JSF 页面上,我有:
<h:inputHidden id="mapContextId" value="#{mapContext.webContextId}" />
在呈现的页面中,它变成:
<input id="mapForm:mapContextId" type="hidden" name="mapForm:mapContextId" value="#{mapContext.webContextId}" />
如您所见,JSF 标记呈现得很好,但 EL 没有被解释。
server.log 中没有任何日志表明存在任何问题。
JSF 1.2、JSTL 1.2、Jboss 6、JDK 6。
Web.xml:
<context-param>
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
<param-value>Mojarra-1.2</param-value>
</context-param>
任何帮助将不胜感激!
更多细节:
我已经仔细检查了我的代码和配置。另外,我还向我正在使用的自定义变量解析器添加了一些日志记录,以查看 JSF 使用了哪些 bean。结果很奇怪。
首先,我用不同的输出增强了我的 JSF 页面,它现在看起来像这样:
<h:inputHidden id="mapContextId1" value="#{mapContext}" />
<h:inputHidden id="mapContextId2" value="#{selectionPointSymbol.width}" />
<h:inputHidden id="mapContextId" value="#{mapContext.webContextId}" />
<h:inputHidden id="mapContextId3" value="#{selectionPointSymbol4.width}" />
并呈现为:
<input type="hidden" name="mapForm" value="mapForm" />
<input id="mapForm:mapContextId1" type="hidden" name="mapForm:mapContextId1" value="#{mapContext}" />
<input id="mapForm:mapContextId2" type="hidden" name="mapForm:mapContextId2" value="#{selectionPointSymbol.width}" />
<input id="mapForm:mapContextId" type="hidden" name="mapForm:mapContextId" value="#{mapContext.webContextId}" />
<input id="mapForm:mapContextId3" type="hidden" name="mapForm:mapContextId3" value="#{selectionPointSymbol4.width}" />
我检查了日志,我可以看到 mapContext 正在通过非标准 JSF 标签很好地解析:(
12:27:24,911 ERROR [mb.ags.adf.resolvers.AGSUserResolver] AGSUserResolver asked to resolve: mapContext
12:27:24,911 ERROR [mb.ags.adf.resolvers.AGSUserResolver] AGSUserResolver delegated to: com.sun.faces.el.ChainAwareVariableResolver@ab4f3c and resulted with: mb.ags.adf.map.MbWebContext@20
12:27:24,927 ERROR [mb.ags.adf.resolvers.AGSUserResolver] AGSUserResolver asked to resolve: mapContext
12:27:24,927 ERROR [mb.ags.adf.resolvers.AGSUserResolver] AGSUserResolver delegated to: com.sun.faces.el.ChainAwareVariableResolver@ab4f3c and resulted with: mb.ags.adf.map.MbWebContext@20
很多它们在日志中)。
但是没有关于:selectionPointSymbol或selectionPointSymbol4(根本没有定义这样的bean!)的单个日志,它们仅在标准标签中使用。
服务器日志中仍然没有错误或警告:(
更多详细信息:简单测试。JSF
页面:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page buffer="96kb" autoFlush="true" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<f:view>
<f:loadBundle basename="mb.ags.res.AGSClient" var="msg"/>
<html>
<head>
<title>*********</title>
<link rel="stylesheet" title="base" href="/gis/css/base-style.css" type="text/css" media="screen" />
<style type="text/css">
body { overflow:auto; }
</style>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="loading_table_container" style="position:absolute; text-align:center; left:0; top:0; width:100%; height:100%; z-index:20000; background-color:white;">
<table id="loading" style="z-index:20001;" height="100%" width="100%">
<tr>
<td align="center" valign="middle" style="font-size: 12px">
<img src="/gis/images/loading_big.gif" alt="Loading..." align="absmiddle"/><br/><br/>
<h:outputText value="#{msg.welcome_page_map_client_loading}"/>
<h:outputText id="mapContextId2" value="#{selectionPointSymbol.width}" />
</td>
</tr>
</table>
</div>
<script>
var url = "<%= redirectUrl %>";
var refresh = "<meta http-equiv=\"refresh\" content=\"1000; URL=" + url + "\" />";
document.writeln(refresh);
</script>
</body>
</html>
</f:view>
呈现为:
<html>
<head>
<title>GIS</title>
<link rel="stylesheet" title="base" href="/gis/css/base-style.css" type="text/css" media="screen" />
<style type="text/css">
body { overflow:auto; }
</style>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" language="javascript" src="/gis/js/prototype.js"></script>
<script type="text/javascript" language="javascript" src="/gis/js/scriptaculous/scriptaculous.js?load=effects"></script>
<script type="text/javascript" language="javascript" src="/gis/js/ext/ext-prototype-adapter.js"></script>
<script type="text/javascript" language="javascript" src="/gis/js/ext/ext-all.js"></script>
<script type="text/javascript" language="javascript" src="/gis/js/mb_errors.js"></script>
<script type="text/javascript" language="Javascript" src="/gis/js/esri_core.js"></script>
<script type="text/javascript" language="Javascript" src="/gis/js/mapviewer.js"></script>
<script type="text/javascript" language="javascript" src="/gis/js/ExternalClient.js"></script>
<script type="text/javascript" language="Javascript" src="/gis/js/index_init.js"></script>
</head>
<body>
<div id="loading_table_container" style="position:absolute; text-align:center; left:0; top:0; width:100%; height:100%; z-index:20000; background-color:white;">
<table id="loading" style="z-index:20001;" height="100%" width="100%">
<tr>
<td align="center" valign="middle" style="font-size: 12px">
<img src="/gis/images/loading_big.gif" alt="Loading..." align="absmiddle"/><br/><br/>
#{msg.welcome_page_map_client_loading}<span id="mapContextId2">#{selectionPointSymbol.width}</span>
</td>
</tr>
</table>
</div>
<script>
var url = "/gis/mapviewer.jsf?msid=1000005&uid=1&cid=1&mapContextId=1";
var refresh = "<meta http-equiv=\"refresh\" content=\"1000; URL=" + url + "\" />";
document.writeln(refresh);
</script>
</body>
</html>
仍然不知道发生了什么,因为没有日志表明任何问题。
I have been hitting my head against the wall with this one for few hours already and I dont have a clue why this is happening...
Recently we have began process of moving from JBoss 4.2.3 to JBoss 6 Final. We are using JSF 1.2. I have sucessfully adapted application to new JBoss (mostly by removing some JARs from WEB-INF/lib and tunning web.xml a bit) and app starts nicely.
The problem is that some EL expressions are not being resolved, while others do. I also get 0 exceptions or warnings in the logs.
I have a bean called "mapContext" which is defined in one of the JSF xml config files. It is being created just fine. On my JSF page I have:
<h:inputHidden id="mapContextId" value="#{mapContext.webContextId}" />
and in the rendered page it becomes:
<input id="mapForm:mapContextId" type="hidden" name="mapForm:mapContextId" value="#{mapContext.webContextId}" />
As you can see, JSF tag is rendered just fine, but EL is not interpreted.
There are no logs in the server.log indicating any problems.
JSF 1.2, JSTL 1.2, Jboss 6, JDK 6.
Web.xml:
<context-param>
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
<param-value>Mojarra-1.2</param-value>
</context-param>
Any help would be greatly appreciated!
More details:
Well I have doublechecked my code and configuration. Also I have added some logging to the Custom Variable Resolver I am using, to see what beans are used by JSF. Results are weird.
First of all I have enhanced my JSF page with different outputs, and it now looks like this:
<h:inputHidden id="mapContextId1" value="#{mapContext}" />
<h:inputHidden id="mapContextId2" value="#{selectionPointSymbol.width}" />
<h:inputHidden id="mapContextId" value="#{mapContext.webContextId}" />
<h:inputHidden id="mapContextId3" value="#{selectionPointSymbol4.width}" />
and is rendered as:
<input type="hidden" name="mapForm" value="mapForm" />
<input id="mapForm:mapContextId1" type="hidden" name="mapForm:mapContextId1" value="#{mapContext}" />
<input id="mapForm:mapContextId2" type="hidden" name="mapForm:mapContextId2" value="#{selectionPointSymbol.width}" />
<input id="mapForm:mapContextId" type="hidden" name="mapForm:mapContextId" value="#{mapContext.webContextId}" />
<input id="mapForm:mapContextId3" type="hidden" name="mapForm:mapContextId3" value="#{selectionPointSymbol4.width}" />
I checked the logs and I can see that mapContext is being resolved just fine by non-standard JSF tags:
12:27:24,911 ERROR [mb.ags.adf.resolvers.AGSUserResolver] AGSUserResolver asked to resolve: mapContext
12:27:24,911 ERROR [mb.ags.adf.resolvers.AGSUserResolver] AGSUserResolver delegated to: com.sun.faces.el.ChainAwareVariableResolver@ab4f3c and resulted with: mb.ags.adf.map.MbWebContext@20
12:27:24,927 ERROR [mb.ags.adf.resolvers.AGSUserResolver] AGSUserResolver asked to resolve: mapContext
12:27:24,927 ERROR [mb.ags.adf.resolvers.AGSUserResolver] AGSUserResolver delegated to: com.sun.faces.el.ChainAwareVariableResolver@ab4f3c and resulted with: mb.ags.adf.map.MbWebContext@20
(lots of them in the logs).
But there is no single log about: selectionPointSymbol or selectionPointSymbol4 (no such bean defined at all!), which are only used in standard tags.
Still no errors or warnings in the server log :(
More details: simple test.
JSF page:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page buffer="96kb" autoFlush="true" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<f:view>
<f:loadBundle basename="mb.ags.res.AGSClient" var="msg"/>
<html>
<head>
<title>*********</title>
<link rel="stylesheet" title="base" href="/gis/css/base-style.css" type="text/css" media="screen" />
<style type="text/css">
body { overflow:auto; }
</style>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="loading_table_container" style="position:absolute; text-align:center; left:0; top:0; width:100%; height:100%; z-index:20000; background-color:white;">
<table id="loading" style="z-index:20001;" height="100%" width="100%">
<tr>
<td align="center" valign="middle" style="font-size: 12px">
<img src="/gis/images/loading_big.gif" alt="Loading..." align="absmiddle"/><br/><br/>
<h:outputText value="#{msg.welcome_page_map_client_loading}"/>
<h:outputText id="mapContextId2" value="#{selectionPointSymbol.width}" />
</td>
</tr>
</table>
</div>
<script>
var url = "<%= redirectUrl %>";
var refresh = "<meta http-equiv=\"refresh\" content=\"1000; URL=" + url + "\" />";
document.writeln(refresh);
</script>
</body>
</html>
</f:view>
is rendered as:
<html>
<head>
<title>GIS</title>
<link rel="stylesheet" title="base" href="/gis/css/base-style.css" type="text/css" media="screen" />
<style type="text/css">
body { overflow:auto; }
</style>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" language="javascript" src="/gis/js/prototype.js"></script>
<script type="text/javascript" language="javascript" src="/gis/js/scriptaculous/scriptaculous.js?load=effects"></script>
<script type="text/javascript" language="javascript" src="/gis/js/ext/ext-prototype-adapter.js"></script>
<script type="text/javascript" language="javascript" src="/gis/js/ext/ext-all.js"></script>
<script type="text/javascript" language="javascript" src="/gis/js/mb_errors.js"></script>
<script type="text/javascript" language="Javascript" src="/gis/js/esri_core.js"></script>
<script type="text/javascript" language="Javascript" src="/gis/js/mapviewer.js"></script>
<script type="text/javascript" language="javascript" src="/gis/js/ExternalClient.js"></script>
<script type="text/javascript" language="Javascript" src="/gis/js/index_init.js"></script>
</head>
<body>
<div id="loading_table_container" style="position:absolute; text-align:center; left:0; top:0; width:100%; height:100%; z-index:20000; background-color:white;">
<table id="loading" style="z-index:20001;" height="100%" width="100%">
<tr>
<td align="center" valign="middle" style="font-size: 12px">
<img src="/gis/images/loading_big.gif" alt="Loading..." align="absmiddle"/><br/><br/>
#{msg.welcome_page_map_client_loading}<span id="mapContextId2">#{selectionPointSymbol.width}</span>
</td>
</tr>
</table>
</div>
<script>
var url = "/gis/mapviewer.jsf?msid=1000005&uid=1&cid=1&mapContextId=1";
var refresh = "<meta http-equiv=\"refresh\" content=\"1000; URL=" + url + "\" />";
document.writeln(refresh);
</script>
</body>
</html>
Still no clue what is happening, as there are no logs indicating any problems.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保以下事项:
/WEB-INF/lib
中没有 servletcontainer 特定的库,例如el-*.jar
。web.xml
声明符合 Servlet 3.0 规范(JBoss 6 支持)。web.xml
不包含com.sun.faces.expressionFactory
的上下文参数,该参数指向不同的(显然不存在的)EL 实现。Ensure of the following things:
el-*.jar
in/WEB-INF/lib
.web.xml
is declared conform Servlet 3.0 specification (as JBoss 6 supports).web.xml
does not contain a context param ofcom.sun.faces.expressionFactory
which points to a different (and apparently non-existing) EL implementation.如果 EL 代码段中未定义
mapContext
,JSF 会默默地返回空白字符串。您绝对确定 mapContext 已正确配置吗?在迁移过程中很容易错过。
JSF silently returns the blank string if
mapContext
is not defined in your EL snippet.Are you absolutely certain that mapContext is properly configured? It is very easy to miss in a migration process.