Could be:

 1. Classloader issue - the MachineManager class loaded by the
DefaultServiceManager isn't the same as the one loaded by the servlet.
(I.e. they are loaded by different classloaders.)

 2. The implementing class of the MachineManager interface doesn't
implement MachineManager.

Check that the servlet doesn't have its own copy of MachineManager.

/LS

> -----Original Message-----
> From: Jaroslaw Palka [mailto:[EMAIL PROTECTED] 
> Sent: den 7 oktober 2003 16:43
> To: Avalon framework users
> Subject: RE: ClassCastException in Jetty
> 
> 
> The line which causes exception:
> 
> MachineManager mngr = 
> (MachineManager)srvMng.lookup(MachineManager.ROLE);
> 
> and here is output from program:
> 
> class org.apache.avalon.framework.service.DefaultServiceManager
> class org.apache.avalon.framework.logger.LogKitLogger
> class $Proxy1
> --
> Open WebMail Project (http://openwebmail.org)
> 
> 
> ---------- Original Message -----------
> From: "Leo Sutic" <[EMAIL PROTECTED]>
> To: "'Avalon framework users'" <[EMAIL PROTECTED]>
> Sent: Tue, 7 Oct 2003 16:02:19 +0200
> Subject: RE: ClassCastException in Jetty
> 
> > Jaroslav,
> > 
> > it's not obvious which line of your code causes the 
> > ClassCastException. Could you do the following:
> > 
> >  1. Point out which line causes the exception.
> > 
> >  2. Add, just before that line, a statement that will print 
> to stderr 
> > the class name, like this:
> > 
> >      System.err.println (request.getSession().getAttribute
> > (WebServer.SERVICE_MANAGER).getClass ());
> >      ServiceManager srvMng =
> >  (ServiceManager)request.getSession().getAttribute
> >  (WebServer.SERVICE_MANAGER);
> > 
> >      System.err.println (request.getSession().getAttribute
> > (WebServer.LOGGER).getClass ());
> >      Logger logger = (Logger)request.getSession().getAttribute
> >  (WebServer.LOGGER);
> >      try {
> >        System.err.println (srvMng.lookup 
> > (MachineManager.ROLE).getClass ());
> >        MachineManager mngr = (MachineManager)srvMng.lookup
> >  (MachineManager.ROLE);
> > 
> >  request.getSession().setAttribute("machines",mngr.getRegistere
> > dMachines
> >  ());
> >      } catch (ServiceException e) {
> >        e.printStackTrace();
> >      }
> >      response.sendRedirect("/vend/jsp/machine.jsp");
> > 
> > Run the program and tell us what the output is. You can have some 
> > classloader issues in the servlet container.
> > 
> > /LS
> > 
> > > -----Original Message-----
> > > From: Jaroslaw Palka [mailto:[EMAIL PROTECTED]
> > > Sent: den 7 oktober 2003 15:21
> > > To: [EMAIL PROTECTED]
> > > Subject: ClassCastException in Jetty
> > > 
> > > 
> > > Hi!!!
> > > 
> > > I'm new to Avalon framework and my task in my company is to
> > > evaluate this 
> > > solution.
> > > I've spend few hours on creating simple applications running 
> > > under Phoenix, 
> > > but I get stuck in integrating phoenix with jetty using 
> > > JettyPhoenix from 
> > > jetty.mortbay.org.
> > > 
> > > I have LoginServlet which executes lookup on
> > > ServiceManager.My problem is 
> > > that I get ClassCastException.Here is code:
> > > 
> > >     ServiceManager srvMng =
> > > (ServiceManager)request.getSession().getAttribute
> > > (WebServer.SERVICE_MANAGER);
> > >     Logger logger = (Logger)request.getSession().getAttribute
> > > (WebServer.LOGGER);
> > >     try {
> > >       MachineManager mngr = (MachineManager)srvMng.lookup 
> > > (MachineManager.ROLE);
> > >       
> > > request.getSession().setAttribute("machines",mngr.getRegistere
> > dMachines
> > > ());
> > >     } catch (ServiceException e) {
> > >       e.printStackTrace();
> > >     }
> > >     response.sendRedirect("/vend/jsp/machine.jsp");
> > > 
> > > and here is exception:
> > > 
> > > java.lang.ClassCastException
> > >         at 
> com.piksar.vend.LoginServlet.service(LoginServlet.java:44)
> > >         at
> > > javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > >         at org.mortbay.jetty.servlet.ServletHolder.handle
> > > (ServletHolder.java:35
> > > )
> > >         at 
> org.mortbay.jetty.servlet.Invoker.service(Invoker.java:184)
> > >         at 
> > > javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > >         at org.mortbay.jetty.servlet.ServletHolder.handle
> > > (ServletHolder.java:35
> > > )
> > >         at 
> org.mortbay.jetty.servlet.WebApplicationHandler.dispatch
> > > (WebApplicat
> > > onHandler.java:294)
> > >         at org.mortbay.jetty.servlet.ServletHandler.handle
> > > (ServletHandler.java:
> > > 67)
> > >         at 
> org.mortbay.http.HttpContext.handle(HttpContext.java:1723)
> > >         at org.mortbay.jetty.servlet.WebApplicationContext.handle
> > > (WebApplicatio
> > > Context.java:514)
> > > 
> > > I'm using jetty 4.2.12, phoenix 4.0.4, and JettyPhoenix 1.1.
> > > Can anyone help 
> > > me.
> > > 
> > > Jarek
> > > 
> > > 
> > > 
> --------------------------------------------------------------------
> > > -
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > 
> > > 
> > >
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> ------- End of Original Message -------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to