0

不知何故,当我尝试远程远程 EJB3 调用时,会抛出 ClassCastException。

服务器:

public interface CardManager extends Manager {
     public CardCheckResponse check(CardCheckRequest request);
}


@Remote
public interface RMICardManagerRemote extends CardManager {
     static String CARD_CHECK_RMI_REMOTE_JNDI = "CardCheckRMI/remote";
}


@Stateless
@RemoteBinding(jndiBinding = RMICardManagerRemote.CARD_CHECK_RMI_REMOTE_JNDI)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class RealRMICardManager implements RMICardManagerRemote {
    private CardManager cardManager = injector.getInstance(CardManager.class);

    @Override
    public CardCheckResponse check(CardCheckRequest request) {
    return cardManager.check(request);
    }

}

客户:

InitialContext remoteContext = new InitialContext(PropertiesUtil.getCardCheckProp());
RMICardManagerRemote rmiCardManagerRemote = (RMICardManagerRemote) remoteContext.lookup(RMICardManagerRemote.CARD_CHECK_RMI_REMOTE_JNDI);

//throws ClassCastException
CardCheckResponse cardCheckResponse = rmiCardManagerRemote.check(cardCheckRequest); 

堆栈跟踪:

java.lang.ClassCastException: com.cardcheck.dto.CardCheckResponse cannot be cast to com.cardcheck.dto.CardCheckResponse
    at $Proxy307.check(Unknown Source)
    at com.xxx.cardCheck(RechargeAdapter.java:267)

我检查了它是否是重复的 jar,但事实并非如此。有没有人有任何想法来解决这个问题?

提前致谢

4

1 回答 1

0

解决了!

该问题是由 JBoss 的统一类加载器引起的。我解决了在 jboss-app.xml 中创建自定义加载器的问题:

<loader-repository> com.cardcheck loader = cardCheck heard </ loader-repository>
于 2012-08-01T20:52:59.170 回答