1

我使用 Eclipse > Liferay Project > Portlet > JSF 2.x > Primefaces 创建了一个新项目。然后我试图通过遵循这个演示向它添加 Spring Bean 管理。

问题是在部署到 tomcat 7 时,生成的 portlet 会引发异常。

源文件:jndi:/localhost/jsf-test-portlet/WEB-INF/faces-config.xml 原因:类 'org.springframework.web.jsf.el.SpringBeanFacesELResolver' 缺少运行时依赖项:java.lang.NoClassDefFoundError : org/springframework/beans/factory/access/el/SpringBeanELResolver

如果我查看项目“lib”目录,jars 就在适当的位置,在生成的 WAR 中也是如此。所以我不知道问题可能出在哪里。


我的常春藤.xml

<?xml version="1.0"?>
<ivy-module
version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"
>
<info module="portlet_primefaces_tmpl" organisation="com.liferay" />

<dependencies defaultconf="default">
    <dependency name="el-api" org="javax.el" rev="2.2" />
    <dependency name="jboss-el" org="org.jboss.el" rev="2.0.1.GA" />
    <dependency name="jsf-api" org="com.sun.faces" rev="2.1.21" />
    <dependency name="jsf-impl" org="com.sun.faces" rev="2.1.21" />
    <dependency name="liferay-faces-bridge-api" org="com.liferay.faces" rev="3.1.3-ga4" />
    <dependency name="liferay-faces-bridge-impl" org="com.liferay.faces" rev="3.1.3-ga4" />
    <dependency name="liferay-faces-portal" org="com.liferay.faces" rev="3.1.3-ga4" />
    <dependency name="liferay-faces-util" org="com.liferay.faces" rev="3.1.3-ga4" />
    <dependency name="primefaces" org="org.primefaces" rev="3.5" />
    <dependency org="org.springframework" name="spring-core" rev="3.2.1.RELEASE"/>
    <dependency org="org.springframework" name="spring-web" rev="3.2.1.RELEASE" />
</dependencies>

我的 web.xml

<?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_2_5.xsd" version="2.5">

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/portlet-context.xml</param-value>
</context-param>
<context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<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>*.xhtml</url-pattern>
</servlet-mapping>

<!-- Prevent direct access to Facelet view XHTML by the userAgent (browser). -->
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Facelet View XHTML</web-resource-name>
        <url-pattern>*.xhtml</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>nobody</role-name>
    </auth-constraint>
</security-constraint>
<security-role>
    <role-name>nobody</role-name>
</security-role>

我的面孔-config.xml

<?xml version="1.0"?>
<faces-config version="2.1" 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_1.xsd">

<lifecycle>
    <phase-listener>com.liferay.faces.util.lifecycle.DebugPhaseListener</phase-listener>
</lifecycle>
<application>
    <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>

4

1 回答 1

0

从演示中分析 WAR,我意识到其中有 7 个 Spring JARS,我将剩余的依赖项添加到我的ivy.xml文件中,然后是“清理/部署”,现在它正在工作。也许不是所有的 JARS 都是必需的,但这是下一步,删除那些不必要的。

ivy.xml现在看起来像这样:

<?xml version="1.0"?>
<ivy-module
version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"
>

<info module="portlet_primefaces_tmpl" organisation="com.liferay" />

<dependencies defaultconf="default">
    <dependency name="jboss-el" org="org.jboss.el" rev="2.0.1.GA" />
    <dependency name="jsf-api" org="com.sun.faces" rev="2.1.21" />
    <dependency name="jsf-impl" org="com.sun.faces" rev="2.1.21" />
    <dependency name="liferay-faces-bridge-api" org="com.liferay.faces" rev="3.1.3-ga4" />
    <dependency name="liferay-faces-bridge-impl" org="com.liferay.faces" rev="3.1.3-ga4" />
    <dependency name="liferay-faces-portal" org="com.liferay.faces" rev="3.1.3-ga4" />
    <dependency name="liferay-faces-util" org="com.liferay.faces" rev="3.1.3-ga4" />
    <dependency name="primefaces" org="org.primefaces" rev="3.5" />
    <!-- Spring dependencies -->
    <dependency name="spring-core" org="org.springframework" rev="3.0.7.RELEASE"/>
    <dependency name="spring-web" org="org.springframework" rev="3.0.7.RELEASE" />
    <dependency name="spring-context" org="org.springframework" rev="3.0.7.RELEASE" />
    <dependency name="spring-beans" org="org.springframework" rev="3.0.7.RELEASE" />
    <dependency name="spring-expression" org="org.springframework" rev="3.0.7.RELEASE" />
    <dependency name="spring-aop" org="org.springframework" rev="3.0.7.RELEASE" />
    <dependency name="spring-asm" org="org.springframework" rev="3.0.7.RELEASE" />
</dependencies>

于 2013-11-05T16:27:36.333 回答