You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by -=j=- <ja...@twaxx.com> on 2009/10/14 19:41:58 UTC

Re: cxf.aegis.DatabindingException: Cannot create mapping for java.util.List, unspecified component type for method getAll parameter -1

My pleasure sir, I understand that the better we doc this stuff, the
easier it will be for all of us to build what we want / need to build so
I do what I can to put answers out there when I have 'em.  I now have a
nice appfuse / mule dist and have successfully exposed and consumed a
service on it, and am creating a dist where I can quickly put together
appfuse / mule dists with a high degree of polish and using best
practices open src coding... With the dist in it's current state there's
no proprietary IP in it (my domain model classes are Foo.java and
Bar.java, etc., and with DAO/Svc/struts2 web front ends), so if you'd
like me to contribute the dist as an example, I'd be happy to do it.  If
you want me to do this, it might be a good idea for me to beat on it a
bit to make sure it's as solid as possible so there are fewer
bugs/surprise/etc.  AppFuse offers *very* tight java open src web app
starter projects and this now adds mule / cxf into that dist making it
even more powerful... Let me know...

-=j=-

On Wed, 2009-10-14 at 13:31 -0400, Daniel Kulp wrote:

> 
> Thanks for the update for archival purposes.   
> 
> Not having any real Mule experience, definitely not an area I would have been 
> able to help too much with.   :-(
> 
> Dan
> 
> 
> On Tue October 13 2009 7:58:02 pm jackalista wrote:
> > Hi,
> > 
> > I managed to resolve this, it turns out 3 things had to be changed:
> > 
> > 1. Apparently the CXFServlet and the MuleRESTReceiverServlet don't play
> >  nice together. I'm not shocked about this but I am disappointed; I wanted
> >  to run services both from mule and from the web app but it looks like that
> >  may not be possible.  You must take the CXFServlet (or most likely the
> >  XFire servlet too) out of your web.xml and remove the mapping and map the
> >  mule receiver servlet to /services/*.
> > 
> > 2. Similarly, thou shalt not declare any endpoints via CXF means (again,
> > likely also true of xfire), at least not via cxf-servlet.xml. I had this
> > declaration in cxf-servlet.xml but needed to comment it out, as CXF will
> > publish it even with the CXFServlet not in play:
> > 
> > <!--
> > <jaxws:endpoint
> > id="FooService"
> > implementor="#fooManager"
> > address="/FooService" >
> > </jaxws:endpoint>
> > -->
> > 
> > 3. The above two were not shocking, I had doubts from the get-go about
> > running both CXF and mule servlets together in the same web app but this
> > last part surprised me. I had found an example on the mule site showing how
> > to change the databinding. The example shows an inbound-endpoint with CXF
> > prefix, instead of the prefix-less inbound-endpoint I found in the
> >  bookstore example. It didn't seem like I could change the binding to aegis
> >  without using the prefix but when I used the prefix I got a
> > MalformedEndpointException... but if I remove the cxf prefix (and also the
> > binding directive), it works fine... ?!?!?  I haven't any deep detail on
> > that yet but I'll try to come back and update this to make it easier for
> >  the next guy... the mule example webapp code is no where near as
> >  functional nor as pretty as appfuse so I want to get this working to
> >  facilitate building mule web apps.  The problematic and working config for
> >  the mule endpoint are here...
> > 
> > This structure throws a MalformedEndpointException:
> > 
> > <cxf:inbound-endpoint
> >  address="cxf:http://0.0.0.0:8888/services/FooService"> <cxf:databinding>
> > <spring:bean class="org.apache.cxf.aegis.databinding.AegisDatabinding"/>
> > </cxf:databinding>
> > </cxf:inbound-endpoint>
> > 
> > This structure does not throw any exceptions and the web app loads:
> > 
> > <inbound-endpoint address="cxf:http://0.0.0.0:8888/services/FooService"/>
> > 
> > 
> > -=j=-
> > 
> > jackalista wrote:
> > > It occurred to me that I might want to clarify what I'm asking, since
> > > it's a slightly complicated scenario.  As my immediate exception is an
> > > aegis.DatabindingException, I was hoping somebody with good experience
> > > with CXF & aegis could look at my mapping file setup and / or
> > > annotations. Since they don't seem to be having any effect I suspect I'm
> > > doing something ignorant, as I am pretty inexperienced with CXF and
> > > Aegis.
> > >
> > > Also, I'm pretty green to this code, is it foolish to try to expose the
> > > same service via mule *and* the web app?  They are exposed at different
> > > addresses, but it's the same code, the mule service definition refers to
> > > the same spring bean successfully exposed by CXF and the web app.  Do
> > > implementation details preclude exposing this same service via mule at a
> > > different address?  The web app is successfully publishing the service at
> > > /services/FooService, but the mule configuration at /mule/FooService is
> > > hitting the binding exception.  If I make a request of a /mule/* URL the
> > > mule servlet gets invoked but can't find the endpoint, I think because it
> > > failed o get properly created due to the binding exception.
> > >
> > > My goal is to integrate mule into appfuse (and mule embeds cxf), but
> > > perhaps I'm taking a misstep in my pursuit of this.  Should I perhaps
> > > suppress the web app's publication of services?  I'm not seeing any
> > > conflict with ports or anything unless that's somehow involved with this
> > > binding exception but I'm new to both mule and CXF (I have more
> > > experience with appfuse and want to exploit it's web app capabilities and
> > > add mule in).  It's a common scenario to load mule in web apps but most
> > > of the code on the mule site has very rudimentary web apps while appfuse
> > > has fairly high production values by comparison, I want to add mule to
> > > that rich environment.  I am at liberty to share the code, there's not
> > > any "client" IP involved (hence the FooService), if anybody's interested,
> > > I can post it or send it to you.
> > >
> > > Thanks,
> > >
> > > --jack
> > >
> > > jackalista wrote:
> > >> Hi,
> > >>
> > >> I'm trying to integrate mule which uses CXF and Aegis under the hood
> > >> into a current appfuse dist and am running into a binding exception. 
> > >> I've set the binding to use Aegis, and it looks like it's having trouble
> > >> with a service super class that features a method "getAll()" with a
> > >> parameterized List<T> return value where type variable T is set to a
> > >> domaon model class by the instantiating extending class.  The method
> > >> signature is here:
> > >>
> > >> List<T> getAll();
> > >>
> > >> At run time, extending class FooManagerImpl which implements interface
> > >> FooManager, is instantiated and it's inherited getAll() method sig looks
> > >> like this (Foo.java is the the hibernate persistent domain model class):
> > >>
> > >> List<Foo> getAll();
> > >>
> > >> I've tried to use both the standard appfuse dist which includes xfire
> > >> and I also tried replacing xfire with CXF in appfuse but both suffer the
> > >> same Aegis binding exception about a failure to map the List return
> > >> value of getAll().  I'm taking this to mean that mule is using CXF /
> > >> Aegis
> > >>
> > >> I tried exposing the superclass getAll method directly in the subclass
> > >> interface and implementation and then put this annotation on it to try
> > >> to keep Aegis from trying to bind it but it had no effect.  I followed
> > >> docs on annotations for this here:
> > >>
> > >> http://cwiki.apache.org/CXF20DOC/developing-a-service.html#DevelopingaSe
> > >>rvice-DevelopingaServiceusingJAXWS
> > >>
> > >> The annotation, which was apparently ignored, looks like this, but the
> > >> wsdl still showed the getAll() method:
> > >>
> > >>   @WebMethod(exclude = true)
> > >>   public List<Foo> getAll();
> > >>
> > >> I also tried to use an Aegis XML mapping file which I placed in the jar
> > >> alonside the interface class [see attached screendump] is called
> > >> FooManager.aegis.xml [the class it is to map is the service interface
> > >> FooManager.class / FooManager.java, etc.].  The mapping class looks like
> > >> this:
> > >>
> > >> <mappings>
> > >>     <mapping name="FooManager">
> > >>         <method name="getAll">
> > >>             <return-type name="foos"
> > >> componentType="org.jackalista.integration.model.Foo"/>
> > >>         </method>
> > >>     </mapping>
> > >> </mappings>
> > >>
> > >> Docs on using mapping files is here (for aegis 2.1, as I'm using CXF
> > >> 2.1.5), see the section on "Services and Parameters":
> > >>
> > >> http://cwiki.apache.org/CXF20DOC/aegis-21.html
> > >>
> > >>
> > >> It seems that both the exlude annotation and the aegis mapping file are
> > >> both being oignored but as I'm new to boeth CXF and Aegis, it may be due
> > >> to use error.  In the version of appfuse in which I replaced xfire with
> > >> cxf, I used the version of cxf that the latest mule apparently uses
> > >> which is 2.1.5.  The web app *is* able to expose the same annotated
> > >> service interface and class properly as a web service and publishes the
> > >> wsld at localhost:8080/services/FooService?wsdl as would be expected. 
> > >> It looks like appfuse and mule each have their own instance of CXF but
> > >> I'm not sure about that.  While the web app and its CXF properly publish
> > >> the web service, mule and the CXF it uses are hitting an exception
> > >> related to Aegis trying to map the getAll() method and failing.
> > >>
> > >> The exception being thrown is:
> > >>
> > >> Caused by: org.apache.cxf.aegis.DatabindingException: Error initializing
> > >> parameters for operation
> > >> {http://service.integration.jackalista.org/}getAll:  Cannot create
> > >> mapping for java.util.List, unspecified component type for method getAll
> > >> parameter -1
> > >>
> > >>
> > >> Can anybody point me in the right direction?  It seems like the aegis
> > >> mapping code is having trouble with the parameterized List<T> getAll()
> > >> return value where T = Foo.java at run time.  I uploaded a small zip
> > >> file of relevant files if that helps...
> > >> http://www.nabble.com/file/p25831156/jarfile.and.scrn.dump.zip
> > >> jarfile.and.scrn.dump.zip I suspect that I may be doing something naive
> > >> / stupid with the mapping file, the annotation or may perhaps be
> > >> approaching this incorrectly, any help would be greatly appreciated,
> > >> thanks.
> > >>
> > >> --jack
> > >>
> > >>
> > >> My mule config is loaded via the listener from web.xml, essentially I
> > >> too the bookstore demo code configuration and grafted it onto an appfuse
> > >> dist.  Here's the service configuration for the service experiencing the
> > >> binding exception, FooService:
> > >>
> > >>
> > >> Fisrt I import my spring (2.5.6) applicationContext.xml with my service
> > >> interface & impl in it:
> > >>
> > >> <!-- import beans from appfuse applicationContext.xml -->
> > >> <spring:beans>
> > >>   <spring:import resource="classpath:applicationContext.xml" />
> > >> </spring:beans>
> > >>
> > >> Then, here's the service deinition
> > >>
> > >> <service name="FooService">
> > >>   <inbound>
> > >>     <!-- Public interface -->
> > >>     <cxf:inbound-endpoint address="cxf:http://0.0.0.0:8777/mule/foo">
> > >>       <cxf:databinding>
> > >>         <spring:bean
> > >> class="org.apache.cxf.aegis.databinding.AegisDatabinding"/>
> > >>       </cxf:databinding>
> > >>     </cxf:inbound-endpoint>
> > >>
> > >>     <!-- Administration interface -->
> > >>     <inbound-endpoint address="servlet://foo">
> > >>       <transformers>
> > >>         <!-- Convert request parameters to String object -->
> > >>         <custom-transformer
> > >> class="org.jackalista.integration.service.transformers.HttpRequestToStri
> > >>ng"/> </transformers>
> > >>       <response-transformers>
> > >>         <!-- Format response to be a nice HTML page -->
> > >>         <custom-transformer
> > >> class="org.jackalista.integration.service.transformers.AddFooListRespons
> > >>e"/> <!-- Force text/html, otherwise it falls back to request props,
> > >> which have form-encoded one -->
> > >>         <transformer ref="setHtmlContentType"/>
> > >>       </response-transformers>
> > >>     </inbound-endpoint>
> > >>   </inbound>
> > >>   <pooled-component>
> > >>     <!-- singleton-object
> > >> class="org.jackalista.integration.service.impl.FooManagerImpl" / -->
> > >>     <spring-object bean="fooManager" />
> > >>   </pooled-component>
> > >>  http://www.nabble.com/file/p25831156/aegis.binding.problem.zip
> > >> aegis.binding.problem.zip
> > 
>