It comes from the fact that the Tomcat webapp classloader basically
checks itself for a class before going to the parent classloader,
which is the opposite behavior of a standard classloader.  This can
create all sorts of problems as classes can be loaded twice (once by
parent, and once by child) and will be considered to be completely
different classes by the VM.

http://www.openejb.org/tomcat-ejbclasses.html

-David

On Fri, Jun 10, 2005 at 02:18:52PM -0600, Lajos Moczar wrote:
> 
> Felipe -
> 
> Typically this error occurs when you have your bean file in multiple 
> locations in the Tomcat installation. Unfortunately, the Tomcat 
> classloader hierarchy should take of this problem but it doesn't.
> 
> Regards,
> 
> Lajos
> 
> 
> Felipe Palma Dias wrote:
> 
> >Hi.
> >
> >When I run my code in Tomcat the follow exception is
> >showed:
> >
> >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
> >com.pakprint.psl.ServiceLocator.getHome(ServiceLocator.java:119)
> >        at
> >com.pakprint.b2paper.webservices.UIRepositorySoapBindingImpl.getWidget(UIRepositorySoapBindingImpl.java:44)
> >        at
> >com.pakprint.b2paper.webservices.UIRepositorySoapBindingSkeleton.getWidget(UIRepositorySoapBindingSkeleton.java:56)
> >
> >
> >But, when I run out of Tomcat my code works. My code
> >is:
> >
> >            Properties p = new Properties();
> >            
> >            //The JNDI properties you set depend
> >            //on which server you are using.
> >            //These properties are for the Remote
> >Server.
> >            p.put("java.naming.factory.initial",
> >"org.openejb.client.RemoteInitialContextFactory");
> >            p.put("java.naming.provider.url",
> >"127.0.0.1:4201");
> >            p.put("java.naming.security.principal",
> >"myuser");
> >            p.put("java.naming.security.credentials",
> >"mypass");    
> >            
> >            //Now use those properties to create
> >            //a JNDI InitialContext with the server.
> >            InitialContext ctx = new InitialContext( p
> >);
> >            
> >            //Lookup the bean using it's deployment id
> >            Object obj = ctx.lookup("/XULService");
> >            
> >            System.out.println("object="+obj);
> >            
> >            //Be good and use RMI remote object
> >narrowing
> >            //as required by the EJB specification.
> >            XULServiceHome ejbHome =
> >(XULServiceHome)ServiceLocator.getInstance().getHome("/XULService",XULServiceHome.class);
> >            
> >            //PortableRemoteObject.narrow();
> >        
> >            //Use the HelloHome to create a
> >HelloObject
> >            XULServiceObject ejbObject =
> >ejbHome.create();
> >
> >
> >Felipe F. Palma Dias - S?o Paulo/SP
> >http://www.palmadias.com.br
> >MSN: [EMAIL PROTECTED]
> >Yahoo: palmadias
> >Mobile: +55 11 99157578
> >
> >
> >     
> >     
> >             
> >____________________________________________________
> >Yahoo! Mail, cada vez melhor: agora com 1GB de espa?o gr?tis! 
> >http://mail.yahoo.com.br
> >
> 
> -- 
> 
> 
>                    Lajos Moczar
>       ----------------------------------------
>     Open Source Support, Consulting and Training
>       ----------------------------------------

Reply via email to