开发者

annotated ManagedBean in Richfaces?

I'm new to richfaces and I want to support a bean class using annotation instead of xml configuration [just like JSF 2.0] I'm using richfaces 4.0 and included all required jars in my build path. but when I tried to import javax.faces.bean.*; it through an no package found error. if I include 开发者_Python百科the core JSF2.0 jar from mojarra it compiles fine but when expoted as an war file the tomcat v7 raising an error and my project fail to execute.

any help please.

P.S. without any beans, the project works well


if I include the core JSF2.0 jar from mojarra it compiles fine

That's right. Tomcat doesn't ship with any JSF libraries out the box. RichFaces4 also doesn't ship with any particular JSF implementation. You need to have jsf-api.jar and jsf-impl.jar in /WEB-INF/lib folder.


but when expoted as an war file the tomcat v7 raising an error and my project fail to execute.

You need to ensure that your /WEB-INF/faces-config.xml is declared conform JSF 2.0 spec.

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0"
>
    <!-- Your config here (if any) -->
</faces-config>

You also need to ensure that your /WEB-INF/web.xml is declared conform Servlet 3.0 spec or at least Servlet 2.5 spec.

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0"
>
    <!-- Your config here (if any) -->
</web-app>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜