我使用Eclipse> Liferay Project> Portlet> JSF 2.x> Primefaces創建了一個新項目。然後,我正在嘗試將Spring Bean管理添加到它,通過以下demo。
問題在於,當部署到tomcat 7時,生成的portlet引發異常。Liferay和JSF2 + Spring集成
Source Document: jndi:/localhost/jsf-test-portlet/WEB-INF/faces-config.xml Cause: Class 'org.springframework.web.jsf.el.SpringBeanFacesELResolver' is missing a runtime dependency: java.lang.NoClassDefFoundError: org/springframework/beans/factory/access/el/SpringBeanELResolver
如果我查看項目的'lib'目錄,這些jar就位,在生成的WAR中是一樣的。所以我不知道問題可能源於哪裏。
我的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="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>
我faces-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>
如果你下載了[JSF2彈簧的portlet]戰爭(https://www.liferay.com/community/liferay-項目/ liferay-faces /演示#jsf2-spring-portlet)演示並將其部署到您的$ LIFERAY_HOME/deploy文件夾中,然後在您的tomcat環境中工作嗎? –
我做了你的建議,並且它在WAR中完美工作(我可以看到工作申請表)。但在部署時我的問題仍然存在(例外)。 – whyem