JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Application Server » JBoss  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to topicthreaded modego to previous topicgo to next topic
話題被移動
該話題已被移動 - koji , 2007-12-14 11:35
如果您尚不清楚該話題被移動的原因,請參考論壇規則以及本版公告或者聯系本版版主。
本主題所含的標籤
無標籤
作者 JSF在JBoss4.2.2 GA上部署出现java.lang.ClassCastException [精華]
hahalyf





發文: 9
積分: 0
於 2007-12-13 16:51 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我写了一个简单的JSF应用,代码如下:
web.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="WebApp_ID">
  <display-name>myjsf</display-name>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>
    javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

faces-config.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?xml version="1.0" encoding="UTF-8"?><?xml version="1.0"?> 
 <!DOCTYPE faces-config PUBLIC 
 "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN" 
 "http://java.sun.com/dtd/web-facesconfig_1_0.dtd"> 
 
 <faces-config> 
    <navigation-rule> 
        <from-view-id>/pages/index.jsp</from-view-id> 
        <navigation-case> 
            <from-outcome>login</from-outcome> 
            <to-view-id>/pages/welcome.jsp</to-view-id> 
        </navigation-case> 
    </navigation-rule> 
        
    <managed-bean> 
        <managed-bean-name>user</managed-bean-name> 
         <managed-bean-class> 
             f.jsf.UserBean 
         </managed-bean-class> 
        <managed-bean-scope>session</managed-bean-scope> 
    </managed-bean> 
 </faces-config> 

pages/index.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<%@ taglib uri="/WEB-INF/jsf_core.tld" prefix="f"%>
<%@ taglib uri="/WEB-INF/html_basic.tld" prefix="h"%>
<%@ page contentType="text/html;charset=GB2312"%>
<html>
<head>
<title>第一个JSF程序</title>
</head>
<body>
<f:view>
  <h:form>
    <h3>请输入您的名称</h3>
      名称:<h:inputText value="#{user.name}" />
    <p><h:commandButton value="送出" action="login" />
  </h:form>
</f:view>
</body>
</html>

pages/welcome.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<%@ taglib uri="/WEB-INF/jsf_core.tld" prefix="f"%>
<%@ taglib uri="/WEB-INF/html_basic.tld" prefix="h"%>
<%@ page contentType="text/html;charset=GB2312"%>
<html>
<head>
<title>第一个JSF程序</title>
</head>
<body>
<f:view>
  <h:outputText value="#{user.name}" />您好!
      <h3>欢迎使用JavaServer Faces!</h3>
</f:view>
</body>
</html>

f.jsf.UserBean.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package f.jsf;
 
public class UserBean {
  private String name;
 
  public String getName() {
    return name;
  }
 
  public void setName(String name) {
    this.name = name;
  }
 
}


目录结构如下图:


我将这个应用打包成war格式,然后部署到%JBoss_Home%\server\default\deploy目录下,然后启动JBoss(run -c default),在启动时产生了如下异常:
2007-12-13 14:30:26,963 ERROR [STDERR] java.lang.ClassCastException: com.sun.faces.lifecycle.LifecycleFactoryImpl
2007-12-13 14:30:26,973 ERROR [STDERR] at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:805)
2007-12-13 14:30:26,973 ERROR [STDERR] at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:486)
2007-12-13 14:30:26,973 ERROR [STDERR] at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:381)
2007-12-13 14:30:26,973 ERROR [STDERR] at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJSFConfigureListener.java:69)
......................

我用的jsf版本是1.1,jdk版本是5.

谁能知道怎么回事?帮我找一下线索,我弄了一天了也不知所以然,谢谢。

有线索的朋友可以联系我 Gtalk:hahalyf@gmail.com QQ:75773126 Msn:imyf_liang@hotmail.com(不经常上) 谢谢!!


hahalyf edited on 2007-12-14 11:12
reply to postreply to post
作者 Re:JSF在JBoss4.2.2 GA上部署出现java.lang.ClassCastException [Re:hahalyf]
hahalyf





發文: 9
積分: 0
於 2007-12-14 11:14 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在JBoss4.0上部署正常,是不是JBoss4.2自带了JSF实现了呢?而它自生带的这个实现和Sun的实现冲突呢?

如果是这样,应该怎么解决呢?

也就是说在JBoss4.2上如何应用JSF呢?


reply to postreply to post
作者 Re:JSF在JBoss4.2.2 GA上部署出现java.lang.ClassCastException [Re:hahalyf]
koji

秒速5センチメートル

站長

發文: 8415
積分: 19
於 2007-12-14 11:35 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
jboss-4.2.2.GA\server\default\deploy\jboss-web.deployer\jsf-libs

他自帶的應該是sun的jsf 1.2
我是沒自己拿掉過
你看是要用它的
不然把這邊的代換看看?

koji


reply to postreply to post
JCConf Taiwan 2015 開始售票了!!
Facebook上的TWJUG社團,歡迎加入
作者 Re:JSF在JBoss4.2.2 GA上部署出现java.lang.ClassCastException [Re:hahalyf]
hahalyf





發文: 9
積分: 0
於 2007-12-14 14:38 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
嗯,我是用了JBoss4.2自带的。上面的那个问题没了,但是出现了下面的异常:
org.apache.jasper.JasperException: Unable to convert string "#{user.name}" to class "javax.el.ValueExpression" for attribute "value": Property Editor not registered with the PropertyEditorManager
  org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:887)
  org.apache.jsp.index_jsp._jspx_meth_h_005finputText_005f0(index_jsp.java:194)
  org.apache.jsp.index_jsp._jspx_meth_h_005fform_005f0(index_jsp.java:158)
  org.apache.jsp.index_jsp._jspx_meth_f_005fview_005f0(index_jsp.java:116)
  org.apache.jsp.index_jsp._jspService(index_jsp.java:76)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:408)
  com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:442)
  com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
  com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
  com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
  com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
  javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
  org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

我感觉是EL表达式的问题,但是问题怎么办呢?


reply to postreply to post
作者 Re:JSF在JBoss4.2.2 GA上部署出现java.lang.ClassCastException [Re:hahalyf]
hahalyf





發文: 9
積分: 0
於 2007-12-14 15:14 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
找到问题了,后来的这个问题是因为我使用了JBoss4.2的jsf1.2实现,但是tld文件还是使用1.1的。

搞定了,呵呵呵。

谢谢站长!!!


reply to postreply to post
» JWorld@TW »  Application Server » JBoss

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8