This is not a bug. It is a lack of understanding of ClassLoaders by the poster
you referred to in your search. If you search the Orion mailing list archives,
you will see many postings related to this subject. The problem is that ClassLoader
issues are more complicated in an application server environment, and the old
Class.forName( String name ) technique for loading classes no longer applies.

There was a posting by someone who has written a paper on ClassLoader issues.
That posting is in the archives. I would strongly recommend that you read that
paper, as it will clarify this issue for you.

tim.

> 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