Try using the current thread's context class loader in the forName() 
statement. This has allowed me to load some classe that I otherwise could 
not get to load.

At 07:21 PM 2/13/2001 +0100, you wrote:
>I'm trying to use Class.forName in the startup of an application
>running in Orion.
>
>It simply does not work.
>
>Here is a piece of the code:
>                                 System.out.println("Class to use for 
> logging " + classtouse);
>                                 Class classname = logclass;
>                                 try {
>                                         System.out.println("1");
>                                         logclass = 
> Class.forName(classtouse);
>                                         //logclass = 
> Logging.class.getClassLoader().loadClass(classtouse);
>
>
>                                         System.out.println("2");
>                                 } catch (ClassNotFoundException e) {
>                                         System.out.println("3");
>                                         System.err.println("Could not 
> find class " + classtouse);
>                                         System.out.println("4");
>                                         System.err.println(e.toString());
>                                         System.out.println("5");
>                                         logclass = classname;
>                                         System.out.println("6");
>                                 }
>                                 System.out.println("7");
>
>                                 System.out.println("OK");
>                         } catch (Exception e) {
>                                 System.out.println("8");
>                                 System.err.println("Exception during 
> parsing: " + e);
>                         }
>
>
>And what do we see when we start Orion with this application:
>
>Class to use for logging org.mmbase.util.logging.log4j.Log4jImpl
>1
>Orion/1.4.5 initialized
>
>You see, after '1' it simply stops, and we see in the log and when we
>try to see a page:
>         java.lang.NoClassDefFoundError: org.mmbase.servlet.JamesServlet
>which does not make sense to me, because I'm sure that this class
>_does_ exist, and I dont' get this message if I cut away this specific
>code with 'forName'.
>
>I've searched with google, and found someone with the same problem,
>which was called a bug in orion by someone else:
>
>see 
>http://www.google.com/search?q=cache:list.working-dogs.com/lists/turbine/Turbine%2520Digest%252002-13-00+forName+orionserver&hl=en
>(would that URL be reliable?, well, a few cites from it:
>
>[[
> > Turbine class and other are loaded correctly with the servlet class =
>loader,
> > But Class.forName() break this logic as it goes directly to the Global
> > system class loader.
>
>Right. In that case, what should happen is this:
>
>Class.forName() is called in the scope of orion's custom classloader. The
>systemclassloader is then asked to find the class. When it can't find it,
>then the custom class loader should attempt to find the class. It sounds
>like this part is what isn't happening and is a bug in the orion
>classloader.
>
> > I guess it is possible to hide the problem by modify the server =
>classpath
> > but this is a dirty hack :(
>
>...
>
>
> > I am not familiar with Turbine code and I am not sure what is the right
> > approach here, or if this is a problem. What do you think?
>
>Tell the people who make Orion to fix their broken classloader. This is a
>prime example of why people shouldn't write closed source servlet engines.
>
>]]
>
>Was this a bug indeed? Is it solved? It there a workaround? Does
>anyone understand what I mean?
>
>
>  Michiel
>
>--
>Michiel Meeuwissen - NOS internet
>Mediacentrum kamer 203 - tel. +31 (0)35 6773065
>http://www.mmbase.org
>http://www.purl.org/NET/mihxil/



Reply via email to