Hello all,

I'm seeing a very odd behavior I could really use some assistance with.

The base error I'm getting is:

Could not find a coercion from type
com.java.dse.cwp.eos.components.webdesign.objects.Tab to type
com.java.dse.cwp.eos.components.webdesign.objects.Tab.

Which is pretty odd, especially considering that my classpath only contains
one "Tab" class, and "com.java.dse.cwp.eos.components.webdesign.objects.Tab"
is it.

Tab is just a container class which essentially has two String members, and
accessors, not that I think this matters.

The issue is reported from Tapestry in a loop component, when I try to loop
over a List<Tab> returned from this function:

Code:

        public List<Tab> getTabs()
        {
                if (tabs == null && isValidProduct())
                {
                        tabs = new ArrayList<Tab>();
                        tabs.addAll(product.getTabs());
                        tabs.add(new Tab(true, "Get It" /* TODO: put this in 
the template! */,
null));
                }

                return tabs;
        }

where 'tab' is a 'List<Tab>' and 'product.getTabs()' returns a 'List<Tab>'

I can comment out the line 'tabs.addAll(product.getTabs());' and everything
works (?!?!?) so I think something very odd is going on and the Tab class is
being munged behind the scenes.

The full (well, I truncated it a bit) error/stack is below:

ERROR [http-8080-1: Product]: Render queue error in
BeginRender[Product:d7.loop]: Failure writing parameter 'value' of component
Product:d7.loop: Could not find a coercion from type
com.java.dse.cwp.eos.components.webdesign.objects.Tab to type
com.java.dse.cwp.eos.components.webdesign.objects.Tab.  Available coercions:
...
org.apache.tapestry5.ioc.internal.util.TapestryException: Failure writing
parameter 'value' of component Product:d7.loop: Could not find a coercion
from type com.java.dse.cwp.eos.components.webdesign.objects.Tab to type
com.java.dse.cwp.eos.components.webdesign.objects.Tab.  Available coercions:
... [at classpath:com/java/dse/cwp/eos/components/webdesign/D7.tml, line 12]
        at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:948)
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException: Failure
writing parameter 'value' of component Product:d7.loop: Could not find a
coercion from type com.java.dse.cwp.eos.components.webdesign.objects.Tab to
type com.java.dse.cwp.eos.components.webdesign.objects.Tab.  Available
coercions: ... [at
classpath:com/java/dse/cwp/eos/components/webdesign/D7.tml, line 12]
        at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.write(InternalComponentResourcesImpl.java:544)
Caused by: java.lang.IllegalArgumentException: Could not find a coercion
from type com.java.dse.cwp.eos.components.webdesign.objects.Tab to type
com.java.dse.cwp.eos.components.webdesign.objects.Tab.  Available coercions:
...
        at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.findOrCreateCoercion(TypeCoercerImpl.java:244)
ERROR [http-8080-1: RequestExceptionHandler]: Processing of request failed
with uncaught exception: Render queue error in BeginRender[Product:d7.loop]:
Failure writing parameter 'value' of component Product:d7.loop: Could not
find a coercion from type
com.java.dse.cwp.eos.components.webdesign.objects.Tab to type
com.java.dse.cwp.eos.components.webdesign.objects.Tab.  Available coercions:
...
org.apache.tapestry5.internal.services.RenderQueueException: Render queue
error in BeginRender[Product:d7.loop]: Failure writing parameter 'value' of
component Product:d7.loop: Could not find a coercion from type
com.java.dse.cwp.eos.components.webdesign.objects.Tab to type
com.java.dse.cwp.eos.components.webdesign.objects.Tab.  Available coercions:
... [at classpath:com/java/dse/cwp/eos/components/webdesign/D7.tml, line 12]
        at
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:86)
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException: Failure
writing parameter 'value' of component Product:d7.loop: Could not find a
coercion from type com.java.dse.cwp.eos.components.webdesign.objects.Tab to
type com.java.dse.cwp.eos.components.webdesign.objects.Tab.  Available
coercions: ... [at
classpath:com/java/dse/cwp/eos/components/webdesign/D7.tml, line 12]
        at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:948)
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException: Failure
writing parameter 'value' of component Product:d7.loop: Could not find a
coercion from type com.java.dse.cwp.eos.components.webdesign.objects.Tab to
type com.java.dse.cwp.eos.components.webdesign.objects.Tab.  Available
coercions: ... [at
classpath:com/java/dse/cwp/eos/components/webdesign/D7.tml, line 12]
        at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.write(InternalComponentResourcesImpl.java:544)
Caused by: java.lang.IllegalArgumentException: Could not find a coercion
from type com.java.dse.cwp.eos.components.webdesign.objects.Tab to type
com.java.dse.cwp.eos.components.webdesign.objects.Tab.  Available coercions:
...
        at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.findOrCreateCoercion(TypeCoercerImpl.java:244)


If I change the code slightly, I get a different, but similar issue:

Essentially I get "java.lang.ClassCastException:
com.java.dse.cwp.eos.components.webdesign.objects.Tab cannot be cast to
com.java.dse.cwp.eos.components.webdesign.objects.Tab" which really weirds
me out.

Offending code (the exception occurs on the 'for (Tab...'  line:

        public List<Tab> getTabs()
        {
                if (tabs == null && isValidProduct())
                {
                        tabs = new ArrayList<Tab>();
                        for (Tab tab : product.getTabs())
                        {
                                tabs.add(new Tab(tab.isDefault(), 
tab.getText(), tab.getLink()));
                        }
                        tabs.add(new Tab(true, "Get It" /* TODO: put this in 
the template! */,
null));
                }

                return tabs;
        }


Error:

Render queue error in BeginRender[Product:if]: Failure reading parameter
'test' of component Product:if:
com.java.dse.cwp.eos.components.webdesign.objects.Tab cannot be cast to
com.java.dse.cwp.eos.components.webdesign.objects.Tab


Template offending line:

<t:if test="tabs">


Stack:

Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException: Failure
reading parameter 'test' of component Product:if:
com.java.dse.cwp.eos.components.webdesign.objects.Tab cannot be cast to
com.java.dse.cwp.eos.components.webdesign.objects.Tab [at
classpath:com/java/dse/cwp/eos/pages/Product.tml, line 11]
        at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:516)
        at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:496)
        at
org.apache.tapestry5.corelib.components.If._$read_parameter_test(If.java)
        at org.apache.tapestry5.corelib.components.If.test(If.java:45)
        at
org.apache.tapestry5.corelib.base.AbstractConditional.beginRender(AbstractConditional.java:59)
        at
org.apache.tapestry5.corelib.base.AbstractConditional.beginRender(AbstractConditional.java)
        at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$BeginRenderPhase.invokeComponent(ComponentPageElementImpl.java:206)
        at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.run(ComponentPageElementImpl.java:164)
        at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:933)
        ... 74 more
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
com.java.dse.cwp.eos.components.webdesign.objects.Tab cannot be cast to
com.java.dse.cwp.eos.components.webdesign.objects.Tab [at
classpath:com/java/dse/cwp/eos/pages/Product.tml, line 11]
        at
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:62)
        at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:510)
        ... 82 more
Caused by: java.lang.ClassCastException:
com.java.dse.cwp.eos.components.webdesign.objects.Tab cannot be cast to
com.java.dse.cwp.eos.components.webdesign.objects.Tab
        at com.java.dse.cwp.eos.pages.Product.getTabs(Product.java:92)
        at
$PropertyConduit_12265bc215d.get($PropertyConduit_12265bc215d.java)
        at
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
        ... 83 more


I'd greatly appreciate some help in figuring this one out.

Thanks,

Levi
-- 
View this message in context: 
http://n2.nabble.com/-T5.1--Coercion-Class-mismatch-error-%28a-real-headbanger%29-tp3237426p3237426.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to