6 Replies Latest reply on Jul 3, 2006 3:50 AM by slarchet

    Jboss seam tomahaw integration of jscookmenu

    slarchet

      hi everybody

      I'm currently facing a strange pb between Tomahawk and Jboss Seam.
      It looks like NavigationMenuItem[] object returned by my Stateless Bean lose some cast information's when it's handled by NaviagtionMenuUtils class of tomahawk package.

      My test configuration is :
      a superMenu.jsp contains a JsCookMenu tag that dynamically get menu items from a stateless bean.

      my software cfg:

      Jboss is 4.04.GA
      Seam is 1.0.1
      MyFaces 1.1.3
      Tomahawk 1.1.3
      Linus RH Enterpise 4.XX
      JDK Sun 1.5.0_05-b05

      my Stateless Bean source taht returns the array of NavigationMenuItem:

      import static org.jboss.seam.ScopeType.STATELESS;
      import java.io.Serializable;
      import org.jboss.seam.annotations.*;
      import org.jboss.seam.log.Log;
      
      import org.apache.myfaces.custom.navmenu.NavigationMenuItem;
      
      @Name("mainMenu")
      @Scope(STATELESS)
      public class MainMenu implements Serializable
      {
       @Logger
       private Log log;
      
       public MainMenu()
       {
       }
      
       public NavigationMenuItem[] getNavItems() {
       NavigationMenuItem[] navItems=new NavigationMenuItem[2];
       navItems[0]=new NavigationMenuItem("Item 1 Label","action1");
       navItems[1]=new NavigationMenuItem("Item 3 Label","action3");
       System.out.println("produced class name="+navItems.getClass().getName());
       return navItems;
       }
      }
      


      my jsp source wich invoke mainMenu.navItems


      <?xml version="1.0" encoding="UTF-8" ?>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
      <%@ page language="java" contentType="text/html; charset=UTF-8"
       pageEncoding="UTF-8"%>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <!-- JSCook Menu -->
      <script language="JavaScript" src="jscookmenu/JSCookMenu.js" type="text/javascript">
      </script>
      <script language="JavaScript" src="jscookmenu/ThemeOffice/theme.js" type="text/javascript">
      </script>
      <link rel="stylesheet" href="jscookmenu/ThemeOffice/theme.css" type="text/css"/>
      <script language="JavaScript" src="jscookmenu/ThemeIE/theme.js" type="text/javascript">
      </script>
      <link rel="stylesheet" href="jscookmenu/ThemeIE/theme.css" type="text/css"/>
      <title>Insert title here</title>
      </head>
      <body>
      <f:view>
       <h:form>
       <t:jscookMenu id="menu2" layout="hbr" theme="ThemeIE">
       <t:navigationMenuItems value="#{mainMenu.navItems}" />
       </t:jscookMenu>
       </h:form>
      </f:view>
      </body>
      </html>
      



      part of org.apache.myfaces.custom.navmenu.NaviagtionMenuUtils (addNavigationMenuItems method) class that I decorated with a System.out.println in order to make simple checking and follow progress of objects in Eclipse debugger.

      public static void addNavigationMenuItems(UISelectItems child, List list)
       {
       Object value = child.getValue();
       System.out.println("returned class name="+value.getClass().getName());
      
       if (value instanceof NavigationMenuItem)
       {
       list.add(value);
       }
       else if (value instanceof NavigationMenuItem[])
       {
       for (int i = 0; i < ((NavigationMenuItem[])value).length; i++)
       {
       list.add(((NavigationMenuItem[])value));
       }
       }
       else if (value instanceof Collection)
       {
       for (Iterator it = ((Collection)value).iterator(); it.hasNext();)
       {
       Object item = it.next();
       if (!(item instanceof NavigationMenuItem))
       {
       FacesContext facesContext = FacesContext.getCurrentInstance();
       throw new IllegalArgumentException("Collection referenced by UINavigationMenuItems with id " + child.getClientId(facesContext) + " does not contain Objects of type NavigationMenuItem");
       }
       list.add(item);
       }
       }
       else
       {
       FacesContext facesContext = FacesContext.getCurrentInstance();
       throw new IllegalArgumentException("Value binding of UINavigationMenuItems with id " + child.getClientId(facesContext) + " does not reference an Object of type NavigationMenuItem, NavigationMenuItem[], Collection or Map");
       }
       }
      


      exception returned is :

      2006-06-29 15:55:42,367 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: mainMenu
      2006-06-29 15:55:42,367 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.process
      2006-06-29 15:55:42,368 DEBUG [org.jboss.seam.Component] instantiating Seam component: mainMenu
      2006-06-29 15:55:42,380 DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolved name to seam component
      2006-06-29 15:55:42,388 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@181e7fe, cl=org.jboss.mx.loading.HeirarchicalLoaderRepository3$CacheClassLoader@c7f06{ url=null ,addedOrder=0}
      2006-06-29 15:55:42,388 INFO [STDOUT] produced class name=[Lorg.apache.myfaces.custom.navmenu.NavigationMenuItem;
       2006-06-29 15:55:42,391 INFO [STDOUT] returned class name=[Lorg.apache.myfaces.custom.navmenu.NavigationMenuItem;
       2006-06-29 15:55:42,431 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/test-seam].[jsp]] Servlet.service() for servlet jsp threw exception
      java.lang.IllegalArgumentException: Value binding of UINavigationMenuItems with id _id0:_id1 does not reference an Object of type NavigationMenuItem, NavigationMenuItem[], Collection or Map
       at org.apache.myfaces.custom.navmenu.NavigationMenuUtils.addNavigationMenuItems(NavigationMenuUtils.java:145)
       at org.apache.myfaces.custom.navmenu.NavigationMenuUtils.getNavigationMenuItemList(NavigationMenuUtils.java:100)
       at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.encodeChildren(HtmlJSCookMenuRenderer.java:161)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:319)
       at javax.faces.webapp.UIComponentTag.encodeChildren(UIComponentTag.java:343)
       at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:251)
       at org.apache.jsp.superMenu_jsp._jspx_meth_t_jscookMenu_0(superMenu_jsp.java:181)
       at org.apache.jsp.superMenu_jsp._jspx_meth_h_form_0(superMenu_jsp.java:148)
       at org.apache.jsp.superMenu_jsp._jspx_meth_f_view_0(superMenu_jsp.java:117)
       at org.apache.jsp.superMenu_jsp._jspService(superMenu_jsp.java:82)
       at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
       at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
       at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
       at org.jboss.seam.jsf.SeamViewHandler.renderView(SeamViewHandler.java:59)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      2006-06-29 15:55:42,434 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/test-seam].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      javax.faces.FacesException: Value binding of UINavigationMenuItems with id _id0:_id1 does not reference an Object of type NavigationMenuItem, NavigationMenuItem[], Collection or Map
       at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:421)
       at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
       at org.jboss.seam.jsf.SeamViewHandler.renderView(SeamViewHandler.java:59)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.apache.jasper.JasperException: Value binding of UINavigationMenuItems with id _id0:_id1 does not reference an Object of type NavigationMenuItem, NavigationMenuItem[], Collection or Map
       at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
       at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415)
       ... 25 more
      
      



      I can produce the same kind of error If return a List of NavigationMenuItem instead of an array. In this case, the List instance is properly recognized but items returned by iteration aren't detected as NavigationMenuItem.

      I 'm now stucked on this pb since a week.
      I haven't seen any pb of this kind posted here, I hope that's only a configuration pb from me.


      please help !!!


        • 1. Re: Jboss seam tomahaw integration of jscookmenu
          pmuir

          Are you sure you don't have two copies of the Tomahawk/Myfaces jars in your source path? It looks to me like although you have an array of NavigationMenuItem it's not being recognised as such.

          • 2. Re: Jboss seam tomahaw integration of jscookmenu
            slarchet

            I follow your advices and made some checks about presence of both myfaces and tomahawk jar.

            I've updated myfaces jar to myfaces*-1.1.3.jar into tomcat service but unfortunately there is still the same problem.


            There is something strange about tomahawk, I must put tomahawk.jar in both base directory of my ear package and also WEB-INF/lib directory of the war package (itself packaged into ear pack).
            If I remove tomhawk package from the base of my ear package, the bean can't be deployed because NavigationMenuItem class mentionned into the bean is missing.
            In other hand, if I remove tomahawk package into WEB-INF/lib it fails during the jsp file processing.
            => finally I removed tomahawk package from both locations and put it directly into <jboss-path>/server/default/lib directory.

            I have 3 questions :

            - where should be located faces jar and tomahawk jar
            - where can I find a sample of JscookMenu implementation in a context of Jboss/Seam ?
            - is it possible that another jar files can contain some classes of tomahawk/myfaces ?

            I continue investigations !!


            • 3. Re: Jboss seam tomahaw integration of jscookmenu

              I have jscook menu working with no problems. Put tomahawk in the following directory.

              default\deploy\jbossweb-tomcat55.sar\jsf-libs

              It does not need to be in the lib or ear.

              • 4. Re: Jboss seam tomahaw integration of jscookmenu
                kryzys

                Try putting <t:jscookMenu...> outside of the <h:form> tag.
                As far as I know it doesn't work if placed inside a form, because it renders its own html-form.

                • 5. Re: Jboss seam tomahaw integration of jscookmenu

                  This is not it. I assumed that mine had a form around it, but it did not. I added one just to see and it still works perfectly.

                  • 6. Re: Jboss seam tomahaw integration of jscookmenu
                    slarchet

                    Effectively, I moved Tomahawk jar from /default/server/lib to
                    /default/server/deploy/jbossweb-tomcat55.sar\jsf-libs
                    and everything is working fine now.

                    It was simple but efficient.

                    I thank you for your help.

                    I hope, in the future, to be helpfull for you as you've been for me on this pb.

                    Cdly,