首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用带Facelets的特立尼达2加载ViewHandler (InstantiationException)

无法使用带Facelets的特立尼达2加载ViewHandler (InstantiationException)
EN

Stack Overflow用户
提问于 2014-01-22 10:41:11
回答 1查看 1.4K关注 0票数 2

好吧,我没有主意了。我正在尝试使用Facelets在Glassfish 4上运行特立尼达2.1.0,但我总是先得到这个异常:

代码语言:javascript
复制
WARNING:   Could not load ViewHandler javax.faces.application.ViewHandler
WARNING:   java.lang.InstantiationException
    at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:374)
    at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl._initIfNeeded(ViewHandlerImpl.java:311)
    at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.createView(ViewHandlerImpl.java:83)

其次是:

代码语言:javascript
复制
SEVERE:   Error when processing tag for component with id: "". The scoped id of the parent component is ":j_id_id5".
java.lang.NullPointerException
    at org.jboss.weld.el.ELCreationalContextStack.getCreationalContextStore(ELCreationalContextStack.java:33)
    at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:47)
    at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.setProperty(UIXComponentELTag.java:297)
    at org.apache.myfaces.trinidadinternal.taglib.html.HtmlScriptTag.setProperties(HtmlScriptTag.java:81)
    at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.setProperties(UIXComponentELTag.java:284)

我目前正在使用com.sun.faces, jsf-impl, 2.2.4。我也尝试过org.apache.myfaces.core, myfaces-impl, 2.1.13,但这给了我大致相同的错误。

我在我的glassfish-web.xml中设置了glassfish-web.xml。在切换JSF实现时,我看到了错误的地方,所以我确信我不会使用绑定到Glassfish的JSF实现。

web.xml中的视图处理程序切换到org.apache.myfaces.trinidadinternal.facelets.TrinidadFaceletViewHandler也不起作用。

我把我的文件删掉了,以便:

代码语言:javascript
复制
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:tr="http://myfaces.apache.org/trinidad"
>
  <f:view>
    <tr:document>
      <tr:outputText value="Hello"/>
    </tr:document>
  </f:view>
</ui:composition>

但我还是会收到上面提到的错误。

首先,我使用了一个使用JSF1.2的特立尼达1.2.14和使用同一个Glashfish服务器的Facelets 1.1.14的项目。我遵循了本文中关于JSF migration的步骤来迁移JSF和Facelets。

因此,我的Facelets 1.1.14依赖项被删除了,我更新了特立尼达和JSF依赖项,并更新了web.xmlfaces-config.xml

有人知道我还能查些什么吗?

更新

我排除了玻璃鱼。我创建了一个新的空白项目,配置了特立尼达2,并尝试在Tomcat 7上运行它,得到了相同的异常。

在我的新项目中,我使用了以下配置:

依赖关系

代码语言:javascript
复制
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-api</artifactId>
  <version>2.2.4</version>
</dependency>
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-impl</artifactId>
  <version>2.2.4</version>
</dependency>
<dependency>
  <groupId>org.apache.myfaces.trinidad</groupId>
  <artifactId>trinidad-api</artifactId>
  <version>2.1.0</version>
</dependency>
<dependency>
  <groupId>org.apache.myfaces.trinidad</groupId>
  <artifactId>trinidad-impl</artifactId>
  <version>2.1.0</version>
</dependency>

web.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1"
         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>
  <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>/faces/*</url-pattern>
  </servlet-mapping>

  <!-- Trinidad -->

  <filter>
    <filter-name>trinidad</filter-name>
    <filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>trinidad</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
  </filter-mapping>

  <servlet>
    <servlet-name>resources</servlet-name>
    <servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class>
  </servlet>

  <!-- This cannot be configured currently -->
  <servlet-mapping>
    <servlet-name>resources</servlet-name>
    <url-pattern>/adf/*</url-pattern>
  </servlet-mapping>

  <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>

  <context-param>
    <param-name>org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER</param-name>
    <!-- TrinidadFaceletViewHander must be the alternate view handler if SessionChangeManager is used -->
    <param-value>javax.faces.application.ViewHandler</param-value>
  </context-param>

  <context-param>
    <!--Unfortunately, Facelets provides no hook for plugging the PageResolver into the logic
      handling "facelets.VIEW_MAPPINGS". You should leave "facelets.VIEW_MAPPINGS"
      unset and use "org.apache.myfaces.trinidad.FACELETS_VIEW_MAPPINGS" instead.-->
    <param-name>org.apache.myfaces.trinidad.FACELETS_VIEW_MAPPINGS</param-name>
    <param-value>*.xhtml</param-value>
  </context-param>

  <!-- / Trinidad -->

  <session-config>
    <session-timeout>
      30
    </session-timeout>
  </session-config>
  <welcome-file-list>
    <welcome-file>faces/index.xhtml</welcome-file>
  </welcome-file-list>
</web-app>

faces-config.xml

代码语言:javascript
复制
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
              xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">

  <application>
    <default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>
  </application>

</faces-config>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-25 08:14:52

Error when processing tag for component with id很容易解决。我想那个人甚至用被剥去的文件就已经走了。

我无法摆脱Could not load ViewHandler的警告。因此,我尝试使用此警告(只有在部署应用程序时才会记录)。在解决了其他一些JSF迁移问题之后,应用程序似乎在运行,没有进一步的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21280600

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档