OK, I'm out of ideas. I'm trying to get Trinidad 2.1.0 running on Glassfish 4 using Facelets, but I keep getting this exception first:
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)
Followed by:
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)
I'm currently using com.sun.faces, jsf-impl, 2.2.4
. I also tried org.apache.myfaces.core, myfaces-impl, 2.1.13
, but this gave me more or less the same error.
I've set <class-loader delegate="true" />
in my glassfish-web.xml
. I see differences in error when switching JSF implementations, so I'm sure I'm not using the JSF implementation bundled with Glassfish.
Switching the view handler in the web.xml
to org.apache.myfaces.trinidadinternal.facelets.TrinidadFaceletViewHandler
also did not work.
I've stripped down my document to:
<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>
But I'm still getting the mentioned errors.
I started with a project using Trinidad 1.2.14 using JSF 1.2 and Facelets 1.1.14 which was working on the same Glashfish server. I've followed the steps in this article on JSF migration to migrate JSF and Facelets.
So, my Facelets 1.1.14 dependency is removed, I've updated the Trinidad and JSF dependencies and updated the web.xml
and faces-config.xml
.
Does anyone know what else I could check?
Update
I ruled out Glassfish. I created a new blank project, configured Trinidad 2 and tried to run it on Tomcat 7 and got the same exception.
In my new project I used the following configuration:
Dependencies
<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>