geronimo-iia / winstone

Winstone is a servlet container that was written out of a desire to provide servlet functionality without the bloat that full J2EE compliance introduces.
GNU Lesser General Public License v2.1
22 stars 3 forks source link

Servlets don't see classes in bootstrap/lib directory #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  Create a servlet that uses org.apache.log4j.Logger objects directly
2.  set servlet to load on startup
3.  in init method of servlet, print a debug message using a Logger object

What is the expected output? What do you see instead?

What should happen is that the debug message should print out to the console, 
but what happens is the engine fails to start.  The boot.jar contains a copy of 
log4j-1.2.16.jar but apparently it isn't visible to the loaded servlets.

What version of the product are you using? On what operating system?
winstone-1.0.5-boot.jar, windows 7 

Please provide any additional information below.
When trying to startup Winstone with a servlet using log4j Logger class the 
following output occurs:

Tue, 18 Mar 2014 18:44:16 722 GMT, BootStrap Info: Home 
Directory=G:\code\java\winstonetest\dist
Tue, 18 Mar 2014 18:44:16 744 GMT, BootStrap Info: 
Main-Class=net.winstone.Winstone
INFO  18/03/14 14:44:16.904 [main]: stage 1/3: Loading arguments...
INFO  18/03/14 14:44:16.905 [main]: stage 2/3: Loading WebApplication 
configuration...
INFO  18/03/14 14:44:16.905 [main]: stage 3/3: compute JSP classpath...
INFO  18/03/14 14:44:16.959 [main]: Found and enabled the local Servlet 2.5 XSD 
replacement
INFO  18/03/14 14:44:17.188 [main]: Access logging disabled - no logger class 
defined
Tue, 18 Mar 2014 18:44:17 203 GMT, BootStrap Warning: class 
'net.winstone.Winstone', exception occur when invoking 'main' method  : null
Tue, 18 Mar 2014 18:44:17 203 GMT, BootStrap Info: Exit

and the startup fails.  Remove references to org.apache.log4j.Logger from the 
source code the engine starts normally.

Original issue reported on code.google.com by jere.mcd...@gmail.com on 18 Mar 2014 at 6:48

GoogleCodeExporter commented 9 years ago
Hello, in fact winstone see all classes under lib directory, but some package 
like "org.apache.log4j" and "org.slf4j" are not exposed to webapp (in order to 
avoid some issue when an application use his own log framework).

You have to add your log framework under your application folder web-inf/lib

Original comment by jguibert@gmail.com on 4 Apr 2014 at 3:33

GoogleCodeExporter commented 9 years ago
That is what I reported, the jars in the lib directory are not accessible to 
the web applications.  If this is the intention that's fine and easy to work 
around.  In that case, though, you may want to enhance the error reporting 
during bootstrap startup.  This particular servlet was marked to load on start 
and caused the class not found situation while the server was being created but 
the Bootstrap code swallowed that information and simply aborted with a "NULL" 
error.  When I started the server directly (not via Bootstrap) I saw the 
ClassNotFoundException but not when starting from the bootstrap jar.

Original comment by jere.mcd...@gmail.com on 4 Apr 2014 at 3:39

GoogleCodeExporter commented 9 years ago
That is what I reported, the jars in the lib directory are not accessible
to the web applications.  If this is the intention that's fine and easy to
work around.  In that case, though, you may want to enhance the error
reporting during bootstrap startup.  This particular servlet was marked to
load on start and caused the class not found situation while the server was
being created but the Bootstrap code swallowed that information and simply
aborted with a "NULL" error.  When I started the server directly (not via
Bootstrap) I saw the ClassNotFoundException but not when starting from the
bootstrap jar.

Original comment by jere.mcd...@gmail.com on 4 Apr 2014 at 3:39

GoogleCodeExporter commented 9 years ago
Oh ok, I've missed this part of feed back.

I'll see what I can do for that. 

In fact, bootstrap & lib folder, was originaly designed for server and 
application. 
But, because winstone use slf4j, this cause some difficulty if a webapp add his 
own slf4j implementation. 
So, I've filtered this package that shouldn't not be exposed normaly.

But, I'm not really "happy" with this filtering, because we load two time some 
jar and cannot use server class loading facility for our app.

What I see as a best solution, could be:
- add an option "not-share-server-classpath" and apply this filtering if active
- work on error log when we are in your case

Thanks for your reply

Jerome

Original comment by jguibert@gmail.com on 4 Apr 2014 at 3:54

GoogleCodeExporter commented 9 years ago
Added two command line option for now.

I'll test it in case of failure and raise up a good error message.

Original comment by jguibert@gmail.com on 7 Apr 2014 at 8:41

GoogleCodeExporter commented 9 years ago
When filter is active, and we have a classnotfound issue from this filtered 
classes,
the error message is:
Caused by: java.lang.ClassNotFoundException: Class not found (filtered): 
org.slf4j.LoggerFactory
 set option useServerClassPath=false to disable filtering

Original comment by jguibert@gmail.com on 7 Apr 2014 at 9:30