4 Replies Latest reply on Apr 8, 2008 12:58 PM by hvram.hvram1.gmail.com

    Cannot convert type calss to interface ..coerceToType error

    hvram.hvram1.gmail.com

      Hi


      I am trying to use the dataModel in rich:calendar and I am getting the following error .


          The class is implementing the interface .  I am using JBoss 4.2.1 GA . I tried copying the jsf-libs from jboss AS1 beta 3 and tried again but the error is the same .


         Is there a way to pass a converter or something of that sort to avoid this error ?


      java.lang.IllegalArgumentException: Cannot convert com.yostech.yoscare.YosCalendarDataModel@972517 of type class com.yostech.yoscare.YosCalendarDataModel_$$_javassist_60 to interface org.richfaces.model.CalendarDataModel
      
              at org.jboss.el.lang.ELSupport.coerceToType(ELSupport.java:358)
      
              at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:188)
      
              at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
      
              at javax.faces.component.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:102)


        • 1. Re: Cannot convert type calss to interface ..coerceToType error
          pmuir

          Not a clue what you are talking about.


          What is AS1 beta3?


          Probably you have multiple copies of richfaces-api.jar floating around.


          And, please make an effort to format your post. Anything formatted that badly in the future I would probably moderate.

          • 2. Re: Cannot convert type calss to interface ..coerceToType error
            hvram.hvram1.gmail.com

            Hi Pete
               Sorry for the formatting . But I tried to format this using the Format selected text ..


                For the problem I am using rich:calendar component . One of the  properties of the component is a attribute called dataModel which is expected to be of type org.richfaces.model.CalendarDataModel interface.


                I have a seam class which implements the above interface . I also added an entry for richfaces-api.jar in the application.xml  of my Seam applicatio . The richfaces-api.jar is present in the root directory of my ear . I checked the exploded archives and did not find multiple copies of richfaces jars.


                When I try to access the page I get the above error which says it cannot convert the value from class to interface .


                 I  read in a forum entry somewhere that JBoss Application Server 5.0 beta 3 has an updated version of jboss-faces.jar and that might solve this problem .


                 Thanks for any help in solving this problem .  I have been trying for a long time to get this working . I wanted to know if there is a converter or something that I need to specify

            • 3. Re: Cannot convert type calss to interface ..coerceToType error
              jimk1723

              Me thinks this question is better suited for the RichFaces User forum.


              Actually, now that I look at your stacktrace, it looks like the instance it's trying to coerce is javaassisted - I remember there was a JIRA issue...ah yes, here it is: JBSEAM-2111. Upgrading your JSF libs might be a solution.


              Another idea, try adding @BypassInterceptors to your data model implementation. That should take the proxy out of the equation. Of course you'll need to tweak your implementation if it's using any code that requires AOP.

              • 4. Re: Cannot convert type calss to interface ..coerceToType error
                hvram.hvram1.gmail.com

                I finally figured out the problem .


                My application was developed initailly using seam 1.2.1.GA and I had moved to Seam 2.0 .  While moving I had moved the libraries etc. to the new version but did not move the build.xml to reflect the new packaging .


                So I did the following :


                  



                • Generated a fresh project using seam-gen and then got rich:calendar to work with it .




                • Changed my build.xml ( specifically the ear, war and jar tasks to match the structure generated by seam-gen )




                • Changed the resources/META-INF/application.xml to match the one generated by seam-gen




                Now things are working fine. From what I could see the main difference is in the directory structure of the ear file and the addition of the commons-beanutils.jar file under lib of the ear.


                Thanks for all the help . I guess this should go into the Seam  migration FAQ