Problem with Facelets and Tomahawk

Hi,

I am trying to get started with Facelets and Tomahawk. The former works with my application but when I want to include Tomahawk it stops working. In fact, it stops working when I add the Tomahawk jar file as a library.

I use Netbeans 5.5 and facelets-DEV version.

I tried using a different facelets version and a different tomahawk version. But still the same problem.

I followed the instructions on:

http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk

So, I created tomahawk.taglib.xml:

<?xml version="1.0"?>

<!DOCTYPE facelet-taglib PUBLIC

"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"

"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">

<facelet-taglib>

<namespace>http://myfaces.apache.org/tomahawk</namespace>

<tag>

<tag-name>panelTab</tag-name>

<component>

<component-type>org.apache.myfaces.HtmlPanelTab</component-type>

<renderer-type>javax.faces.Group</renderer-type>

</component>

</tag>

<tag>

<tag-name>panelTabbedPane</tag-name>

<component>

<component-type>org.apache.myfaces.HtmlPanelTabbedPane</component-type>

<renderer-type>org.apache.myfaces.TabbedPane</renderer-type>

</component>

</tag>

</facelet-taglib>

And then declared the taglib in my web.xml file:

<context-param>

<param-name>facelets.LIBRARIES</param-name>

<param-value>/WEB-INF/tomahawk.taglib.xml</param-value>

</context-param>

But when I want to deploy the application I get the following error:

WebModule[/proto1]Exception sending context initialized event to listener instance ofclass com.sun.faces.config.ConfigureListener

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

at org.apache.myfaces.renderkit.html.util.ExtensionsPhaseListener.<clinit>(ExtensionsPhaseListener.java:45)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

at java.lang.Class.newInstance0(Class.java:355)

at java.lang.Class.newInstance(Class.java:308)

at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:960)

at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:594)

at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:496)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4236)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4760)

at com.sun.enterprise.web.WebModule.start(WebModule.java:292)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:833)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:817)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:662)

at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1479)

at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1143)

at com.sun.enterprise.web.WebContainer.loadJ2EEApplicationWebModules(WebContainer.java:1068)

at com.sun.enterprise.server.TomcatApplicationLoader.load(TomcatApplicationLoader.java:128)

at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:322)

at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:216)

at com.sun.enterprise.server.ApplicationManager.applicationDeployed(ApplicationManager.java:189)

at com.sun.enterprise.server.ApplicationManager.applicationEnabled(ApplicationManager.java:754)

at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeApplicationDeployEventListener(AdminEventMulticaster.java:914)

at com.sun.enterprise.admin.event.AdminEventMulticaster.handleApplicationDeployEvent(AdminEventMulticaster.java:892)

at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:445)

at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:160)

at com.sun.enterprise.admin.server.core.AdminNotificationHelper.sendNotification(AdminNotificationHelper.java:128)

at com.sun.enterprise.admin.server.core.ConfigInterceptor.postInvoke(ConfigInterceptor.java:109)

at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:97)

at $Proxy1.invoke(Unknown Source)

at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:297)

at com.sun.enterprise.admin.jmx.remote.server.callers.InvokeCaller.call(InvokeCaller.java:56)

at com.sun.enterprise.admin.jmx.remote.server.MBeanServerRequestHandler.handle(MBeanServerRequestHandler.java:142)

at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.processRequest(RemoteJmxConnectorServlet.java:109)

at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.doPost(RemoteJmxConnectorServlet.java:180)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)

at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)

at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)

at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)

at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)

at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)

Context startup failed due to previous errors

Does someone know how I can solve this problem? Thanks in advance.

Cheers,

Luuk.

[8114 byte] By [Sarmatiana] at [2007-11-26 16:52:59]
# 1

I have solved the problem. First I added the following library file:

'commons-logging.jar' (I thought this file was already part of the JSF framework in Netbeans 5.5). That made it possible to load the application, but then I also got some kind of rendering error:

phase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@94a944) threw exception: java.lang.NoClassDefFoundError: org/apache/commons/el/Logger

I thought that maybe it had to do with some other library files, so I added all the library files that i found in a working example:

http://www-128.ibm.com/developerworks/java/library/j-facelets/

Somehow, I don't get any errors anymore. But to be honest I don't know which library file could actually solved the last problem. Also, I think that I added a lot of library files that I actually don't need for my simple application.

Maybe someone can shed some light on this?

Cheers,

Luuk

Sarmatiana at 2007-7-8 23:20:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

I have managed to get rid of errors. However, Tomahawk still does not work for me. I really do not have a clue why it doesn't.

But when I load the application, it looks like the tomahawk tags are not interpreted. I want to try the following code:

<h:form>

<t:panelTabbedPane bgcolor="#FFFFCC">

<t:panelTab label="Tab 1">

<f:verbatim><H1>Tab 1</H1></f:verbatim>

</t:panelTab>

<t:panelTab label="Tab 2">

<f:verbatim><H1>Tab 2</H1></f:verbatim>

</t:panelTab>

<t:panelTab label="Tab 3">

<f:verbatim><H1>Tab 3</H1></f:verbatim>

</t:panelTab>

<h:commandButton value="Common Button" action="..."/>

</t:panelTabbedPane>

</h:form>

But all I can see are three headers and one button. No, tabbed pane!

If I look at the source of the page then I see that the tomahawk tags are left untouched. Of course, I have defined a namespace for tomahawk: xmlns:t="http://myfaces.apache.org/tomahawk". So, that could not be the problem.

I use the following libraries (which also cover all the dependencies needed for Tomahawk- see http://myfaces.apache.org/tomahawk/dependencies.html):

commons-beanutils-1.6.1.jar

commons-codec-1.3.jar

commons-collections-3.1.jar

commons-digester-1.6.jar

commons-el-1.0.jar

commons-fileupload-1.0.jar

commons-lang-2.1.jar

commons-logging-1.0.jar

commons-validator-1.1.4.jar

el-api-1.0.jar

el-ri-1.0.jar

jsf-facelets.jar

jstl-1.1.2.jar

tomahawk-1.1.3.jar

I also have the Extension filter in web.xml:

<!-- (Tomahawk) Extensions Filter -->

<filter>

<filter-name>MyFacesExtensionsFilter</filter-name>

<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>

<init-param>

<param-name>maxFileSize</param-name>

<param-value>20m</param-value>

<!-- <description>Set the size limit for uploaded files.

Format: 10 - 10 bytes

10k - 10 KB

10m - 10 MB

1g - 1 GB

</description> -->

</init-param>

</filter>

<filter-mapping>

<filter-name>MyFacesExtensionsFilter</filter-name>

<servlet-name>Faces Servlet</servlet-name>

</filter-mapping>

<filter-mapping>

<filter-name>MyFacesExtensionsFilter</filter-name>

<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>

</filter-mapping>

Can anyone help me out with this? I would really appreciate it. I really dont know what options there are left, also because I get no error.

Cheers,

Luuk

Sarmatiana at 2007-7-8 23:20:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Add these libs:1. myfaces-api and myfaces-impl (i assume u use myfaces)2. oro-2.xxx.jarThen you have to make a tld for tomahawk.Read this link for further instructions http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk
javaBuffa at 2007-7-8 23:20:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

sorry i missed the first part of your post. i could see that you have read http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk

At any rate here is my web.xml in case this would help (i know you would be careful with some settings like config files, extensions, etc). I am using MyFaces/Tomahawk/Facelets and life has been better.

web.xml

####################

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

version="2.4">

<display-name>Site 5.0</display-name>

<description>site running Java 5.0</description>

<context-param>

<param-name>javax.faces.CONFIG_FILES</param-name>

<param-value>

/WEB-INF/faces-managed-beans.xml,

/WEB-INF/faces-navigation.xml,

</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>

<param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value>

</context-param>

<context-param>

<description>

Prevents MyFaces objects from being serialized.

Compromising meory with speed.

</description>

<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>

<param-value>false</param-value>

</context-param>

<context-param>

<description>

May be set true in development but false in production.

Compressed objects save memory but may eat up resource

during compression/decompression

</description>

<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>

<param-value>false</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>

<param-value>20</param-value>

</context-param>

<context-param>

<description>

State saving method set to server to save network IO

</description>

<param-name>javax.faces.STATE_SAVING_METHOD</param-name>

<param-value>server</param-value>

</context-param>

<context-param>

<description>

Spring ApplicationContexts

</description>

<param-name>contextConfigLocation</param-name>

<param-value>

WEB-INF/conf/applicationContext-dom.xml

WEB-INF/conf/applicationContext-ds.xml

WEB-INF/conf/applicationContext-dao.xml

</param-value>

</context-param>

<listener>

<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>

</listener>

<!-- Faces Servlet -->

<servlet>

<servlet-name>Faces Servlet</servlet-name>

<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<!-- Faces Servlet Mapping -->

<servlet-mapping>

<servlet-name>Faces Servlet</servlet-name>

<url-pattern>/faces/*</url-pattern>

</servlet-mapping>

<!-- Use Documents Saved as *.xhtml -->

<context-param>

<param-name>javax.faces.DEFAULT_SUFFIX</param-name>

<param-value>.xhtml</param-value>

</context-param>

<context-param>

<param-name>facelets.DEVELOPMENT</param-name>

<param-value>true</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>

<param-value>true</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.PRETTY_HTML</param-name>

<param-value>true</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>

<param-value>false</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>

<param-value>true</param-value>

</context-param>

<context-param>

<param-name>facelets.LIBRARIES</param-name>

<param-value>/WEB-INF/tomahawk.taglib.xml</param-value>

</context-param>

<filter>

<filter-name>MyFacesExtensionsFilter</filter-name>

<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>

<init-param>

<param-name>maxFileSize</param-name>

<param-value>20m</param-value>

</init-param>

</filter>

<!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->

<filter-mapping>

<filter-name>MyFacesExtensionsFilter</filter-name>

<!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->

<servlet-name>Faces Servlet</servlet-name>

</filter-mapping>

<!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->

<filter-mapping>

<filter-name>MyFacesExtensionsFilter</filter-name>

<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>

</filter-mapping>

<!--filter>

<filter-name>SecurityFilter</filter-name>

<filter-class>com.branders.garden.view.utils.SecurityFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>SecurityFilter</filter-name>

<url-pattern>*.xhtml</url-pattern>

</filter-mapping -->

<listener>

<listener-class>

org.springframework.web.context.ContextLoaderListener

</listener-class>

</listener>

<!--listener>

<listener-class>

com.view.utils.ServiceFactory

</listener-class>

</listener -->

</web-app>

gaces-config.xml

########################

...

<application>

<!-- tell JSF to use Facelets -->

<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>

</application>

<application>

<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>

</application>

...

javaBuffa at 2007-7-8 23:20:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Actually I am using Netbeans 5.5 and I have added the JSF framework to my project. So I guess that means that I am using the Sun-RI implementation? I don't know the precise implications of this approach. All I can say is that the "jsf-impl.jar" is listed under Sun Java Application Server (which contains a few other jar-files).

I have added the libraries that you have suggested, but unfortunately, still the same problem.

By 'tld for tomahawk' you mean the 'tomahawk.taglib.xml' file (tag library). I have that as well.

But I will take a look at your web.xml. And I have to agree, web development is a whole new experience.

Sarmatiana at 2007-7-8 23:20:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

I have solved the problem. The cause was in my web.xml:

<context-param>

<param-name>facelets.LIBRARIES</param-name>

<param-value>/WEB-INF/proto1.taglib.xml</param-value>

</context-param>

<context-param>

<param-name>facelets.LIBRARIES</param-name>

<param-value>/WEB-INF/tomahawk.taglib.xml</param-value>

</context-param>

Apparantly, this is not the way to load two different tag libraries. In practice, only the first one will be loaded. In my case, it blocked Tomahawk.

So, I have solved the problem, but at the same time I am dealing with a new one. Maybe someone has a short answer on this one?

Anyway, javaBuff you have earned 3 stars.

Cheers,

Luuk

Sarmatiana at 2007-7-8 23:20:41 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...