3 Replies Latest reply: Apr 22, 2012 4:33 PM by gebuh RSS

Tomahawk + Seam not working

Asuka Langley Newbie

So I have a Seam Project and I'm trying to integrate Tomahawk 1.2. I've copied the tomahawk12.jar in WebInf/lib and I have the following configuration in web.xml:




<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>

<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>
<filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <url-pattern>*.seam</url-pattern>
</filter-mapping>





I want to use the Scheduler but I get the following Exception:





"Caused by: javax.el.ELException: /pages/Interpreter/interpreterCalendar.xhtml @28,67 value="#{schedule.model}": Error reading 'model' on type org.javassist.tmp.java.lang.Object_$$_javassist_seam_2
        at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
        at javax.faces.component.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:113)
        ... 66 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
        at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
        at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
        at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
        at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
        at org.javassist.tmp.java.lang.Object_$$_javassist_seam_2.getModel(Object_$$_javassist_seam_2.java)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
        at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
        at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
        at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
        at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
        at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
        at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
        ... 67 more
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/web/tomcat/service/WebCtxLoader$ENCLoader) previously initiated loading for a different type with name "org/apache/myfaces/custom/schedule/model/SimpleScheduleModel"
        at $Proxy234.getModel(Unknown Source)
        ... 89 more"







any ideas?

  • 1. Re: Tomahawk + Seam not working
    gebuh Newbie

    I just got the Tomahawk scheduler working with Seam, here's what I did.

    This is for Seam 2.2, Jboss 5.1 with tomahawk 1.2-1.1.11

    I added the following jars to my apps lib and deployed-jars.list:

    commons-el.jar

    commons-fileupload-1.2.2.jar

    tomahawk12-1.1.11.jar

     

    added the following to app web.xml:

    <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>
    
    <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <url-pattern>*.seam</url-pattern>
    </filter-mapping>
    
     <filter-mapping>
      <filter-name>DisableUrlSessionFilter</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>
     <filter-mapping>
      <filter-name>Seam Filter</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>
    

     

    I used a dummyScheduleModel class(it extends a class in the tomahawk jar) that I got from here:

     

    public class DummyScheduleModel extends SimpleScheduleModel
    {
     public DummyScheduleModel()
     {
     super();
     final Calendar calendar = Calendar.getInstance();
     calendar.setTime(new Date());
     final DefaultScheduleEntry entry = new DefaultScheduleEntry();
     entry.setId("dummyEntry");
     entry.setStartTime(calendar.getTime());
     calendar.add(Calendar.MINUTE, 45);
     entry.setEndTime(calendar.getTime());
     entry.setTitle("Test MyFaces schedule component");
     entry.setSubtitle("my office");
     entry.setDescription("We need to get this thing out of the sandbox ASAP.");
     setMode(ScheduleModel.WEEK);
     addEntry(entry);
     refresh();
     System.err.println("Created DummyScheduleModel instance with an event on "
     + entry.getStartTime() + ".");
     }
     
     public boolean isEmpty()
     {
     System.err.println("Called isEmpty (" + super.isEmpty() + ")");
     return super.isEmpty();
     }
     
     public Date getSelectedDate()
     {
     System.err.println("Called getSelectedDate (" + super.getSelectedDate() + ")");
     return super.getSelectedDate();
     }
     
     public ScheduleEntry getSelectedEntry()
     {
     System.err.println("Called getSelectedEntry (" + super.getSelectedEntry() + ")");
     return super.getSelectedEntry();
     }
     
     public boolean isEntrySelected()
     {
     System.err.println("Called isEntrySelected (" + super.isEntrySelected() + ")");
     return super.isEntrySelected();
     }
     
     public int getMode()
     {
     System.err.println("Called getMode (" + super.getMode() + ")");
     return super.getMode();
     }
     
     public Object get(int i)
     {
     System.err.println("Called get (" + super.get(i) + ")");
     return super.get(i);
     }
     
     public boolean containsDate(Date date)
     {
     System.err.println("Called containsDate (" + super.containsDate(date) + ")");
     return super.containsDate(date);
     }
     
     public int size()
     {
     System.err.println("Called size (" + super.size() + ")");
     return super.size();
     }
    }

     

     

    And created a page to display the scheduler:

    <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <ui:composition xmlns="http://www.w3.org/1999/xhtml"
        xmlns:s="http://jboss.com/products/seam/taglib"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
          xmlns:a="http://richfaces.org/a"
        xmlns:c="http://java.sun.com/jstl/core"
        xmlns:rich="http://richfaces.org/rich"
        xmlns:fn="http://java.sun.com/jsp/jstl/functions" 
        xmlns:t="http://myfaces.apache.org/tomahawk"
        template="layout/template.xhtml">
            <style type="text/css">
            .ecol1 { vertical-align: top; padding-right : 25px }
            .ecol2 { vertical-align: top; border-left: #ACBECE 1px solid; padding-left : 10px }
            .rich-calendar-tool-btn{
                font-family: Arial, Verdana;
            } 
        </style>
        <ui:define name="body">
        <h:form>
    
    <rich:messages/>
    <t:div >
        <t:inputCalendar id="scheduleNavigator"
            value="#{dummyScheduleModel.selectedDate}" />
    </t:div>
    <t:div >
            <t:schedule value="#{dummyScheduleModel}" id="schedule"
                rendered="true" visibleEndHour="21" visibleStartHour="7"
                 workingEndHour="17" workingStartHour="9" readonly="false"
                 theme="default" tooltip="true"
                 compactMonthDayOfWeekDateFormat="EEEE"
                 headerDateFormat="MM-dd-yyyy"
                 compactWeekRowHeight="200"
                 compactMonthRowHeight="100"
                 >
            </t:schedule>
    </t:div>        
    
        </h:form>  
        </ui:define> 
    </ui:composition>
    

    note that the <style> tag is unnecessary, it's a holdover from some earlier experimentation.

    I ran into some problems with css, because of my current css table setting there were no borders on my schedule. In the table setting in our theme.css I changed

    border-collapse: collapse;

    border-spacing: 0px;

     

    to

    border-collapse: separate;

    border-spacing: 1px;

     

    I also added:

    div.schedule-compact-default .day .header {
        background-color: #BED6F8;
        color: #000000;
        font-size: 10px;
        text-align: left;
        vertical-align: middle;
    }
    

    to make the headings match our application colors.

     

    I haven't gotten to the point of actually adding entries, but hopefully that won't take as long as getting the initial configuration set up.

     

    lots of good examples here:

    http://example.irian.at/myfacesexamples/home.jsf

    this was helpful also

    http://shrubbery.mynetgear.net/c/display/MWI/Using+Tomahawk+with+Seam+and+Facelets

  • 2. Re: Tomahawk + Seam not working
    gebuh Newbie

    looks like I'm going to have to scratch using tomahawk.  The only way I can get it working is by using the myfaces extension filter, which is crazy stupid because it breaks my seam file uploads.

    Back to the drawing board.

  • 3. Re: Tomahawk + Seam not working
    gebuh Newbie

    ok, one more time-I spent some time on the myfaces forums and found what looks like a workable solution.

    I tried using the non-extensionFilter solution:

     

    <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>
        <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
        <param-value>false</param-value>
      </context-param> 
      <context-param>
        <param-name>org.apache.myfaces.DISABLE_TOMAHAWK_FACES_CONTEXT_WRAPPER</param-name>
         <param-value>false</param-value>
      </context-param>
    

    I couldn't get this to work, you're supposed to comment out the myExtensionFilter stuff when you use this, but when I do, my server keeps bouncing til a "can't complete" message displays.

     

    What I did find was that ordering in web.xml matters.  So I can use the myExtensionFilter as long as it's AFTER my Seam filters (that includes mapping).  When I do that, I can still use richFaces fileUpload and tomahawk scheduler, the tomahawk fileUpload won't work if called after another upload filter:

     

    <filter-name>Seam Filter</filter-name>
      <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
      <init-param>
       <param-name>createTempFiles</param-name>
       <param-value>false</param-value>
      </init-param>
     </filter>
    
    <!-- tomahawk --> 
     <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>
    
     <filter-mapping>
      <filter-name>Seam Filter</filter-name>
      <url-pattern>/*</url-pattern>
     </filter-mapping>
     <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
    </filter-mapping>
    
    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <url-pattern>*.seam</url-pattern>
    </filter-mapping>