在Eclipse Project中安装JSF Facet时出错

时间:2018-10-04 13:24:11

标签: eclipse

在Eclipse Project中安装JSF Facet时出错

enter image description here

.metadata / .log中的详细异常跟踪

!ENTRY org.eclipse.wst.common.project.facet.core 4 0 2018-10-04 18:48:27.943
!MESSAGE Failed while installing JavaServer Faces 2.2.
!STACK 0

java.lang.NullPointerException
        at org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDelegate.resolveConfigPath(JSFFacetInstallDelegate.java:313)
        at org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDelegate.createConfigFile(JSFFacetInstallDelegate.java:331)
        at org.eclipse.jst.jsf.core.internal.project.facet.JSFFacetInstallDelegate.execute(JSFFacetInstallDelegate.java:130)
        at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.callDelegate(FacetedProject.java:1477)
        at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.modifyInternal(FacetedProject.java:441)
        at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChangesInternal(FacetedProject.java:1181)
        at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.access$2(FacetedProject.java:1117)
        at org.eclipse.wst.common.project.facet.core.internal.FacetedProject$5.run(FacetedProject.java:1099)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313)
        at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChanges(FacetedProject.java:1109)
        at org.eclipse.wst.common.project.facet.core.internal.FacetedProjectWorkingCopy.commitChanges(FacetedProjectWorkingCopy.java:2020)
        at org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage$4.run(FacetsPropertyPage.java:232)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313)
        at org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage$5.run(FacetsPropertyPage.java:246)
        at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

!SESSION 2018-10-05 10:56:32.004 -----------------------------------------------
eclipse.buildId=3.6.1.201408250818-RELEASE-e44
java.version=1.7.0_51
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product org.springsource.sts.ide
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.springsource.sts.ide

1 个答案:

答案 0 :(得分:0)

该项目是“ Dinamic Web项目”吗?如果是这样,则必须选择2.5或更高版本的“动态Web模块版本”,因为JavaServer Faces 2.2需要此版本。

您也可以尝试删除项目(为了安全起见先保存到另一个位置),并将其作为maven项目导入,在后面添加构面或调整pom.xml示例:

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.1.13</version>
</dependency>
<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.1.13</version>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
</dependency>

您还可以如下图所示检查web.xml。

enter image description here

根据您的“动态Web模块”(请参见版本3.1和web-app_3_1),它应该类似于以下代码:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
         version="3.1">