我使用 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>