不知何故,当我尝试远程远程 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,但事实并非如此。有没有人有任何想法来解决这个问题?
提前致谢