[jboss-user] [JNDI/Naming/Network] - EJB3: cannot be cast

MarWestermann do-not-reply at jboss.com
Wed Nov 7 18:17:11 EST 2007


Hi,

I've a problem and hope anyone can help me.

I've a EJB3 module deployed to a JBoss JBoss-4.2.2-GA. The module consists the following classes/interfaces:


  | package com.zoo;
  | 
  | import javax.ejb.Remote;
  | 
  | @Remote
  | public interface Tiger {
  | 	public String roar();
  | }
  | 

  | package com.zoo;
  | 
  | import javax.ejb.Stateless;
  | 
  | @Stateless
  | public class TigerBean implements Tiger {
  | 	public String roar() {
  | 		return "Roar!!!";
  | 	}
  | }
  | 

After deploying the module the global JNDI Namespace is like:


  | +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
  |   +- jmx (class: org.jnp.interfaces.NamingContext)
  |   |   +- invoker (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- RMIAdaptor (proxy: $Proxy47 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
  |   |   +- rmi (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
  |   +- TigerBean (class: org.jnp.interfaces.NamingContext)
  |   |   +- remote (proxy: $Proxy71 implements interface com.zoo.Tiger,interface org.jboss.ejb3.JBossProxy)
  |   +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
  |   +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
  |   +- Tiger (class: org.jnp.interfaces.NamingContext)
  |   +- UserTransactionSessionFactory (proxy: $Proxy14 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
  |   +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
  |   +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
  |   +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
  |   +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
  |   +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
  |   +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
  |   +- queue (class: org.jnp.interfaces.NamingContext)
  |   |   +- A (class: org.jboss.mq.SpyQueue)
  |   |   +- testQueue (class: org.jboss.mq.SpyQueue)
  |   |   +- ex (class: org.jboss.mq.SpyQueue)
  |   |   +- DLQ (class: org.jboss.mq.SpyQueue)
  |   |   +- D (class: org.jboss.mq.SpyQueue)
  |   |   +- C (class: org.jboss.mq.SpyQueue)
  |   |   +- B (class: org.jboss.mq.SpyQueue)
  |   +- topic (class: org.jnp.interfaces.NamingContext)
  |   |   +- testDurableTopic (class: org.jboss.mq.SpyTopic)
  |   |   +- testTopic (class: org.jboss.mq.SpyTopic)
  |   |   +- securedTopic (class: org.jboss.mq.SpyTopic)
  |   +- console (class: org.jnp.interfaces.NamingContext)
  |   |   +- PluginManager (proxy: $Proxy48 implements interface org.jboss.console.manager.PluginManagerMBean)
  |   +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
  |   +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
  |   +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
  |   +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
  |   +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
  | 

After that I developed a test-Client with the following code:

  | public class Visitor {
  | 
  | 	public void run() {
  | 		
  | 		try {
  | 			InitialContext ctx = new InitialContext();
  | 			Tiger bean = (Tiger) ctx.lookup("TigerBean");
  | 			
  | 			System.out.println(bean.roar());
  | 			//System.out.println(Visitor.class.getSimpleName());
  | 		}
  | 		catch (Exception e){
  | 			e.printStackTrace();
  | 		}
  | 	}
  | 	
  | 	
  | 	
  | 	public static void main(String[] args) {
  | 		new Visitor().run();	
  | 
  | 	}
  | 
  | }
  | 

Trying to run it I get the following exception:

java.lang.ClassCastException: org.jnp.interfaces.NamingContext cannot be cast to com.zoo.Tiger

Can me somebody help with that case.

Thx Marco

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4102712#4102712

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4102712



More information about the jboss-user mailing list