@Conversational + @Scope("REQUEST")  Failed on java.lang.ClassCastException: 
java.lang.String incompatible with java.lang.Thread
--------------------------------------------------------------------------------------------------------------------------------

                 Key: TUSCANY-1660
                 URL: https://issues.apache.org/jira/browse/TUSCANY-1660
             Project: Tuscany
          Issue Type: Bug
    Affects Versions: Java-SCA-0.99
         Environment: WindowsXP, IBM JDK5
            Reporter: Jun JIe Nan
             Fix For: Java-SCA-0.99


I tried to make some sense on @Conversational and @Scope("REQUEST"), but 
failed.  The error message:
java.lang.ClassCastException: java.lang.String incompatible with 
java.lang.Thread
    at org.apache.tuscany.sca.core.scope.RequestScopeContainer.getWrapper 
(RequestScopeContainer.java:35)
    at 
org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.getInstance(JavaImplementationInvoker.java:62)
    at 
org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke
 (JavaImplementationInvoker.java:85)
    at 
org.apache.tuscany.sca.binding.sca.impl.RuntimeSCABindingInvoker.invoke(RuntimeSCABindingInvoker.java:48)
    at org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke 
(JDKInvocationHandler.java:270)
    at 
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:114)
    at $Proxy9.empty(Unknown Source)
    at samples.hex.HexTest.testCartService (HexTest.java:77)
I tried:

   1.  @Conversational + @Scope("STATELESS")
   2.  @Conversational + @Scope("CONVERSATION")
   3.  @Conversational + @Scope("COMPOSITE")

All the above 3 worked fine and did not have the error message above.

Anybody can give me some hints, thanks!

The component definition:
    <component name="CartComponent">
        <implementation.java class="samples.hex.cart.impl.CartImpl"/>
    </component>

The implementation:
package samples.hex.cart.impl;

import java.util.HashMap;
import java.util.Map;

import org.osoa.sca.annotations.ConversationID;
import org.osoa.sca.annotations.Destroy;
import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Service;

import samples.hex.cart.services.CartService;

@Scope("REQUEST")
@Service(CartService.class)
public class CartImpl implements CartService {
   
    @ConversationID
    protected String conversationID;

    protected Map<String, Integer> cart;
    @Init
    protected void init(){
        if(cart==null)
            cart = new HashMap<String, Integer>();
    }
   
    public void empty() {
        cart.clear();
    }

    public Map<String, Integer> getItems() {
        return cart;
    }

    public void updateItem(String itemID, int quantity) {
        if(quantity<=0)
            cart.remove(itemID);
        cart.put(itemID, quantity);
        System.out.println (conversationID + ":" + this);
    }

    @Destroy
    protected void destroy(){
        empty();
    }
}

The interface:
package samples.hex.cart.services;

import java.util.Map ;

import org.osoa.sca.annotations.Conversational;

@Conversational
public interface CartService{
    public void updateItem(String itemID, int quantity);
    public void empty();
    public Map<String, Integer> getItems();
}

The Test Code:
    @Test
    public void testCartService(){
        CartService cart = hex.getService(CartService.class, 
"CartComponent/CartService");
        assertNotNull(cart);
        cart.empty();
    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to