首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

jboss部署的有关问题

2012-01-30 
jboss部署的问题客户端老是报这个错Exception in thread main java.lang.ClassCastExceptionat com.sun.

jboss部署的问题
客户端老是报这个错 
Exception in thread "main" java.lang.ClassCastException 
at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(Unknown Source) 
at javax.rmi.PortableRemoteObject.narrow(Unknown Source) 
at testsession.CountClient.main(CountClient.java:20) 
Caused by: java.lang.ClassCastException: $Proxy1 
... 3 more 

public class CountClient { 
public static void main(String[] a) throws Exception{ 
java.util.Properties p = new java.util.Properties(); 
  p.put(Context.INITIAL_CONTEXT_FACTORY, 
  "org.jnp.interfaces.NamingContextFactory"); 
  p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces"); 
  p.put(Context.PROVIDER_URL, "jnp://localhost:1099"); 
   
  Context ctx = new InitialContext(p); 
  Object ref = ctx.lookup("JNDICountBean"); 
   
  System.out.println("#############"+ref.getClass().getName()); 
   
  CountHome countHome = (CountHome) PortableRemoteObject.narrow( 
  ref, CountHome.class); 
  Count count = countHome.create(); 
  //System.err.println(ref.getClass().getName()); 
  //HelloLocalHome helloHome = (HelloLocalHome) ref;  
  //HelloLocal hello = helloHome.create(); 
   
  System.out.println(count.count()); 






[解决办法]
CountHome countHome = (CountHome) PortableRemoteObject.narrow(ref, CountHome.class); 

类转换错误, 看看PortableRemoteObject.narrow(ref, CountHome.class)的class是什么。

热点排行