Discussions

EJB programming & troubleshooting: EJB - Jboss : java.lang.ClassCastException

  1. EJB - Jboss : java.lang.ClassCastException (7 messages)

    Hi all,

    I´m having problems calling to a remote EJB (in other app.) from a ejb from mine. It is the first time i try to do something similar, and im getting this message error:

    ----------------
    java.lang.ClassCastException at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
    at es.caib.regentjur.ejb.MySession.getRemoteHome(MySession.java:233)
    at es.caib.regentjur.ejb.ConexionPADBean.setPersonaPAD(ConexionPADBean.java:581)
    at es.caib.regentjur.ejb.ConexionPADBean.setPersona(ConexionPADBean.java:285)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    ---------------------
    I must admit that im a little bit lost and confused about this, and i cant figure out which can be the problem,
    it will be great if some one can help me about it.
    The application server i´m actually using is jboss 3.2.61p and both applications are deployed on it.

    Thanks a lot,
    cheers,
    Diego

    Threaded Messages (7)

  2. ít is me again[ Go to top ]

    hi, it is me again, im going to post too the method im using, maybe here will be the problem....

    protected Object getRemoteHome(String jndi, String homeClass, String url) throws EJBException, RemoteException{

    Object home = null;
    String jndiName = "java:comp/env/" + jndi;
            Properties propContext = new Properties();

            try{
                if (url != null){
                    propContext.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                    propContext.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                    propContext.put(Context.PROVIDER_URL, url);
                }

                InitialContext jndiContext = new InitialContext(propContext);
                
          
                Object obj = jndiContext.lookup(jndiName);


    home = PortableRemoteObject.narrow(obj, Class.forName(homeClass));


            } catch (Exception ex){
                throw new EJBException(ex);
            }
            
            return home;
        }

    hope it ill help...
  3. hi,
    Can you just tell us what version of JBoss are you using?
    Do you have the exception only when you hot redeploy the application? What if you restart jboss?
    Is your application built up correcty with the jar and war in the ear?


    Lauro
    Nelcom, J2EE in Ticino, Switzerland
  4. hi Lauro[ Go to top ]

    Hi Lauro,

    As I posted above, the Jboss version i´m using is 3.2.6p1.

    The error code is showed just when the method is called,
    and it not goes far away from the line:
     'home = PortableRemoteObject.narrow(obj, Class.forName(homeClass));
     '

    it throws a: '[STDOUT] javax.ejb.EJBException: null; CausedByException is:
    null'

    any idea?
  5. HI![ Go to top ]

    Hi all,

    I have solved the problem!

    It wasn´t anything about the method, that u can use freely if you want, it was about the jndi pointer at the call of the method.

    Thanks everybody who has read this thread,
    read you soon,
    cheers,
    Diego
  6. Hi,
    I am getting the same ClassCastException. Can you please explain what exactly you did to solve it?

    Thanks a lot.

    Atul.
  7. That exception occurs when the WAR file includes any EJB-related classes, either in WEB-INF/lib or WEB-INF/classes folder. Remove any EJB-related JARs/Classes from the WAR and it should work fine. For more info, check this link: http://www.jboss.com/?module=bb&op=viewtopic&p=3896901
  8. EJB+ClassCastException[ Go to top ]

    I am also getting same exception, I have check my war file does not contain any ejb classes and WEB-INF/classes also does not contain any ejb classes. I do not know why this is happening. -Lave