当我尝试远程远程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,但事实并非如此。有没有人有任何想法解决这个问题?
提前致谢
答案 0 :(得分:0)
解决!
问题是由JBoss的统一类加载器引起的。我解决了在jboss-app.xml中创建自定义加载器的问题:
<loader-repository> com.cardcheck loader = cardCheck heard </ loader-repository>