好吧,我没有想法。我正在尝试使用Facelets在Glassfish 4上运行Trinidad 2.1.0,但我一直在获得此例外:
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)
接下来是:
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
中设置了<class-loader delegate="true" />
。我看到切换JSF实现时错误的差异,因此我确定我不会使用捆绑的JSF实现。
将web.xml
中的视图处理程序切换到org.apache.myfaces.trinidadinternal.facelets.TrinidadFaceletViewHandler
也不起作用。
我已经将文档删除到:
<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>
,但我仍会收到上述错误。
我从使用Trinidad 1.2.14的项目开始,使用JSF 1.2和Facelets 1.1.14,该项目在同一Glashfish服务器上工作。我遵循了本文中有关JSF迁移的步骤,以迁移JSF和FACELET。
因此,我的facelets 1.1.14被删除了,我已经更新了Trinidad和JSF依赖项,并更新了web.xml
和faces-config.xml
。
有人知道我还能检查什么?
更新
我排除了玻璃鱼。我创建了一个新的空白项目,配置了Trinidad 2,并试图在Tomcat 7上运行并获得了同样的例外。
在我的新项目中,我使用以下配置:
依赖项
<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
<?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
<?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>
Error when processing tag for component with id
很容易解决。我认为一个人甚至使用了剥离文件。
我无法摆脱Could not load ViewHandler
警告。因此,我尝试使用此警告(只有在部署应用程序时才会记录)。解决了其他一些JSF迁移问题后,该应用程序似乎正在运行而没有其他问题。