Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » J2EE Preview Server, Jetty, Dynamic Web Projects and log4j
J2EE Preview Server, Jetty, Dynamic Web Projects and log4j [message #211628] Wed, 02 April 2008 22:16 Go to next message
Eclipse UserFriend
Originally posted by: csmith.adcaustin.com

I have a 3rd party servlet I would like to run in my Dynamic Web project
using the embedded J2EE Preview runtime (Jetty). The project has
log4j-1.2.9.jar in the WEB-INF/lib folder.

This servlet runs without problem with a tomcat runtime AND runs without
problem in a stand alone Jetty.

When I try to start the J2EE Preview server, I get:
Starting preview server

Port 8080
Modules:
TransacXML

org.mortbay.util.MultiException[org.apache.commons.logging.L ogConfigurationException:
org.apache.commons.logging.LogConfigurationException: No suitable Log
constructor [Ljava.lang.Class;@1b06041 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by
org.apache.commons.logging.LogConfigurationException: No suitable Log
constructor [Ljava.lang.Class;@1b06041 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category))]
at org.mortbay.http.HttpServer.doStart(HttpServer.java:686)
at org.mortbay.util.Container.start(Container.java:72)
at
org.eclipse.wst.server.preview.internal.PreviewStarter.run(P reviewStarter.java:116)
at
org.eclipse.wst.server.preview.internal.PreviewStarter.main( PreviewStarter.java:39)
org.apache.commons.logging.LogConfigurationException:
org.apache.commons.logging.LogConfigurationException: No suitable Log
constructor [Ljava.lang.Class;@1b06041 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by
org.apache.commons.logging.LogConfigurationException: No suitable Log
constructor [Ljava.lang.Class;@1b06041 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category))
at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:543)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:235)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java :351)
at org.apache.jasper.servlet.JspServlet.<init>(JspServlet.java:58)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Nativ e Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(Native ConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(De legatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:5 13)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:199 )
at org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder. java:240)
at
org.mortbay.jetty.servlet.ServletHandler.initializeServlets( ServletHandler.java:446)
at
org.mortbay.jetty.servlet.WebApplicationHandler.initializeSe rvlets(WebApplicationHandler.java:321)
at
org.mortbay.jetty.servlet.WebApplicationContext.doStart(WebA pplicationContext.java:509)
at org.mortbay.util.Container.start(Container.java:72)
at org.mortbay.http.HttpServer.doStart(HttpServer.java:708)
at org.mortbay.util.Container.start(Container.java:72)
at
org.eclipse.wst.server.preview.internal.PreviewStarter.run(P reviewStarter.java:116)
at
org.eclipse.wst.server.preview.internal.PreviewStarter.main( PreviewStarter.java:39)
Caused by: org.apache.commons.logging.LogConfigurationException: No suitable
Log constructor [Ljava.lang.Class;@1b06041 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category)
at
org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:413)
at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:529)
... 20 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:23 89)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getConstructor(Class.java:1657)
at
org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:410)
... 21 more
org.apache.commons.logging.LogConfigurationException:
org.apache.commons.logging.LogConfigurationException: No suitable Log
constructor [Ljava.lang.Class;@1b06041 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by
org.apache.commons.logging.LogConfigurationException: No suitable Log
constructor [Ljava.lang.Class;@1b06041 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category))
at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:543)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:235)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(L ogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java :351)
at org.apache.jasper.servlet.JspServlet.<init>(JspServlet.java:58)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Nativ e Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(Native ConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(De legatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:5 13)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:199 )
at org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder. java:240)
at
org.mortbay.jetty.servlet.ServletHandler.initializeServlets( ServletHandler.java:446)
at
org.mortbay.jetty.servlet.WebApplicationHandler.initializeSe rvlets(WebApplicationHandler.java:321)
at
org.mortbay.jetty.servlet.WebApplicationContext.doStart(WebA pplicationContext.java:509)
at org.mortbay.util.Container.start(Container.java:72)
at org.mortbay.http.HttpServer.doStart(HttpServer.java:708)
at org.mortbay.util.Container.start(Container.java:72)
at
org.eclipse.wst.server.preview.internal.PreviewStarter.run(P reviewStarter.java:116)
at
org.eclipse.wst.server.preview.internal.PreviewStarter.main( PreviewStarter.java:39)
Caused by: org.apache.commons.logging.LogConfigurationException: No suitable
Log constructor [Ljava.lang.Class;@1b06041 for
org.apache.commons.logging.impl.Log4JLogger (Caused by
java.lang.NoClassDefFoundError: org/apache/log4j/Category)
at
org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:413)
at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(L ogFactoryImpl.java:529)
... 20 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:23 89)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getConstructor(Class.java:1657)
at
org.apache.commons.logging.impl.LogFactoryImpl.getLogConstru ctor(LogFactoryImpl.java:410)
... 21 more

My servlet does not run.

If I remove the log4j jar file, the Preview server start up fine and reports
that the servlet is loaded. When the servet actually trys to run, it
complains about log4j

Starting preview server

Port 8080
Modules:
TransacXML

Apr 2, 2008 5:10:17 PM org.mortbay.jetty.servlet.ServletHandler handle
WARNING: Error for /TransacXML/webservice
java.lang.NoClassDefFoundError: org/apache/log4j/Priority
at com.websydian.pka.servlet.AbstractServlet.InitializeLog(Unkn own Source)
at com.websydian.pka.servlet.AbstractServlet.InitAll(Unknown Source)
at com.websydian.pka.servlet.J2eeProxy.InitAll(Unknown Source)
at com.websydian.pka.servlet.AbstractServlet.doGet(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:596)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder .java:428)
at
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(Web ApplicationHandler.java:473)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandl er.java:568)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
at
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebAp plicationContext.java:633)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.http.HttpServer.service(HttpServer.java:909)
at org.mortbay.http.HttpConnection.service(HttpConnection.java: 820)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.ja va:986)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:8 37)
at
org.mortbay.http.SocketListener.handleConnection(SocketListe ner.java:245)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:3 57)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:5 34)


As you can see, the servlet falls over when it tries to use log4j. This is
a third party servlet and I do not have source. Any suggestions?
Re: J2EE Preview Server, Jetty, Dynamic Web Projects and log4j [message #211717 is a reply to message #211628] Thu, 03 April 2008 15:07 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
If you start the J2EE Preview server, open the Debug view, then
right-click the Java executable in the tree and select Properties, you
will find something similar to the following as the executed command:

<java home>\bin\javaw.exe
-classpath
<eclipse_home> \eclipse\plugins\org.apache.commons.logging_1.0.4.v200706111 724.jar;
<eclipse_home> \eclipse\plugins\org.apache.commons.el_1.0.0.v200706111724.j ar;
<eclipse_home>\eclipse\plugins\javax.servlet_2.4.0.v200706111738.jar;
<eclipse_home>\eclipse\plugins\javax.servlet.jsp_2.0.0.v200706191603.jar;
<eclipse_home> \eclipse\plugins\org.apache.jasper_5.5.17.v200706111724.jar;
<eclipse_home> \eclipse\plugins\org.mortbay.jetty_5.1.11.v200706111724.jar;
<wtp_home> \eclipse\plugins\org.eclipse.wst.server.preview_1.0.0.v20070 5302225.jar
org.eclipse.wst.server.preview.internal.PreviewStarter
<workspace_home> \.metadata\.plugins\org.eclipse.wst.server.core\tmp?\preview .xml

The problem is "org.apache.commons.logging_1.0.4". Without specifically
configuring what you want commons.logging to do, you get what ever the
default configuration algorithm decides. The knock on commons.logging
has always been that this default configuration algorithm works in some
cases and doesn't work in others. This is one of the "others". The
solution to the errant behavior depends very much on the details of your
situation and what exactly you want to accomplish. Assuming you don't
care about what the Jetty server is logging, but just want to use Log4J
in the webapp, then I believe adding the following VM argument to the
J2EE Preview launch configuration should get things working:

-Dorg.apache.commons.logging.Log=org.apache.commons.logging. impl.SimpleLog

This tells commons.logging to always use the default "SimpleLog" logger
instead of letting the configuration algorithm incorrectly "discover"
the Log4J in your webapp. Your webapp should then be free to use Log4J
without interference from commons.logging. See if that fixes your
situation. Supposedly commons.logging 1.1.x is better about this kind
of thing, but I don't currently see it in the installed Eclipse bundles,
even for Eclipse 3.4 and WTP 3.0.

Cheers,
Larry


Christopher Smith wrote:
> I have a 3rd party servlet I would like to run in my Dynamic Web project
> using the embedded J2EE Preview runtime (Jetty). The project has
> log4j-1.2.9.jar in the WEB-INF/lib folder.
>
> This servlet runs without problem with a tomcat runtime AND runs without
> problem in a stand alone Jetty.
>
> When I try to start the J2EE Preview server, I get:
> Starting preview server
>
> Port 8080
> Modules:
> TransacXML
>
<Stack trace snipped/>

>
> My servlet does not run.
>
> If I remove the log4j jar file, the Preview server start up fine and
> reports that the servlet is loaded. When the servet actually trys to
> run, it complains about log4j
>
> Starting preview server
>
> Port 8080
> Modules:
> TransacXML
>

<Stack trace snipped/>

>
> As you can see, the servlet falls over when it tries to use log4j. This
> is a third party servlet and I do not have source. Any suggestions?
Re: J2EE Preview Server, Jetty, Dynamic Web Projects and log4j [message #211744 is a reply to message #211717] Thu, 03 April 2008 15:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: csmith.adcaustin.com

Thank you Larry

That was it.

"Larry Isaacs" <Larry.Isaacs@sas.com> wrote in message
news:ft2rs1$5gu$1@build.eclipse.org...
(something absolutly spot on)
Re: J2EE Preview Server, Jetty, Dynamic Web Projects and log4j [message #212742 is a reply to message #211717] Tue, 22 April 2008 00:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jason.hendriks.ca

Larry, I had the same problem. Adding the VM argument to the J2EE
Preview launch configuration made the error go away and allowed the J2EE
Preview Server to start. Thank-you.

*But*. Now I can't see any output that my own classes send to Commons
logging. This was working as an Eclipse Java project, but as a, Eclipse
Dynamic Web Project it does not work. If I use log4j logging directly
from my own classes, the logging works fine.

(i.e.) In the web project, l2 generates output as specified by
log4j.properties but l1 does not.

private final static Log l1 = LogFactory.getLog(MyTest.class);
private final static Logger l2 = Logger.getLogger(MyTest.class);

There are no errors. Perhaps I'm missing something non-Eclipse related
for connecting Log4J to Commons Logging in a J2EE application?


Larry Isaacs wrote:
> If you start the J2EE Preview server, open the Debug view, then
> right-click the Java executable in the tree and select Properties, you
> will find something similar to the following as the executed command:
>
> <java home>\bin\javaw.exe
> -classpath
> <eclipse_home> \eclipse\plugins\org.apache.commons.logging_1.0.4.v200706111 724.jar;
>
> <eclipse_home> \eclipse\plugins\org.apache.commons.el_1.0.0.v200706111724.j ar;
>
> <eclipse_home>\eclipse\plugins\javax.servlet_2.4.0.v200706111738.jar;
> <eclipse_home>\eclipse\plugins\javax.servlet.jsp_2.0.0.v200706191603.jar;
> <eclipse_home> \eclipse\plugins\org.apache.jasper_5.5.17.v200706111724.jar;
> <eclipse_home> \eclipse\plugins\org.mortbay.jetty_5.1.11.v200706111724.jar;
> <wtp_home> \eclipse\plugins\org.eclipse.wst.server.preview_1.0.0.v20070 5302225.jar
>
> org.eclipse.wst.server.preview.internal.PreviewStarter
> <workspace_home> \.metadata\.plugins\org.eclipse.wst.server.core\tmp?\preview .xml
>
>
> The problem is "org.apache.commons.logging_1.0.4". Without specifically
> configuring what you want commons.logging to do, you get what ever the
> default configuration algorithm decides. The knock on commons.logging
> has always been that this default configuration algorithm works in some
> cases and doesn't work in others. This is one of the "others". The
> solution to the errant behavior depends very much on the details of your
> situation and what exactly you want to accomplish. Assuming you don't
> care about what the Jetty server is logging, but just want to use Log4J
> in the webapp, then I believe adding the following VM argument to the
> J2EE Preview launch configuration should get things working:
>
> -Dorg.apache.commons.logging.Log=org.apache.commons.logging. impl.SimpleLog
>
> This tells commons.logging to always use the default "SimpleLog" logger
> instead of letting the configuration algorithm incorrectly "discover"
> the Log4J in your webapp. Your webapp should then be free to use Log4J
> without interference from commons.logging. See if that fixes your
> situation. Supposedly commons.logging 1.1.x is better about this kind
> of thing, but I don't currently see it in the installed Eclipse bundles,
> even for Eclipse 3.4 and WTP 3.0.
>
> Cheers,
> Larry
>
>
> Christopher Smith wrote:
>> I have a 3rd party servlet I would like to run in my Dynamic Web
>> project using the embedded J2EE Preview runtime (Jetty). The project
>> has log4j-1.2.9.jar in the WEB-INF/lib folder.
>>
>> This servlet runs without problem with a tomcat runtime AND runs
>> without problem in a stand alone Jetty.
>>
>> When I try to start the J2EE Preview server, I get:
>> Starting preview server
>>
>> Port 8080
>> Modules:
>> TransacXML
>>
> <Stack trace snipped/>
>
>>
>> My servlet does not run.
>>
>> If I remove the log4j jar file, the Preview server start up fine and
>> reports that the servlet is loaded. When the servet actually trys to
>> run, it complains about log4j
>>
>> Starting preview server
>>
>> Port 8080
>> Modules:
>> TransacXML
>>
>
> <Stack trace snipped/>
>
>>
>> As you can see, the servlet falls over when it tries to use log4j.
>> This is a third party servlet and I do not have source. Any suggestions?
Re: J2EE Preview Server, Jetty, Dynamic Web Projects and log4j [message #212790 is a reply to message #212742] Tue, 22 April 2008 14:33 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
Application servers and servlet containers host other "applications",
which leads to complexities involving classloaders. This makes logging
setup difficult given the various use cases that may be desired. Some
may want a single choice of logger and configuration for the entire
application server or servlet container. Others may want each webapp to
have their own choice of logger and logging configuration. Typically,
each use case requires a different configuration of the server. This is
why WTP has largely punted on this issue. Thus, at the current time,
logging configuration is left as an exercise for the user.

Since Preview Server (i.e. Jetty) is using the full commons logging
1.0.4 jar, the possibilities are somewhat restricted. The suggestion
earlier basically implemented the use case of getting commons logging
out of the way so each webapp could independently use log4j directly.
By configuring commons logging to use SimpleLog, I would expect the
commons logging output to go to the console. It defaults to writing
output to System.err with a default level of "info". Are you not seeing
such output in the Console view? Is it your desire instead to have your
webapp use commons logging running on top of Log4j rather than Log4j
directly?

Cheers,
Larry


Jason Hendriks wrote:
> Larry, I had the same problem. Adding the VM argument to the J2EE
> Preview launch configuration made the error go away and allowed the J2EE
> Preview Server to start. Thank-you.
>
> *But*. Now I can't see any output that my own classes send to Commons
> logging. This was working as an Eclipse Java project, but as a, Eclipse
> Dynamic Web Project it does not work. If I use log4j logging directly
> from my own classes, the logging works fine.
>
> (i.e.) In the web project, l2 generates output as specified by
> log4j.properties but l1 does not.
>
> private final static Log l1 = LogFactory.getLog(MyTest.class);
> private final static Logger l2 = Logger.getLogger(MyTest.class);
>
> There are no errors. Perhaps I'm missing something non-Eclipse related
> for connecting Log4J to Commons Logging in a J2EE application?
>
>
> Larry Isaacs wrote:
>> If you start the J2EE Preview server, open the Debug view, then
>> right-click the Java executable in the tree and select Properties, you
>> will find something similar to the following as the executed command:
>>
>> <java home>\bin\javaw.exe
>> -classpath
>> <eclipse_home> \eclipse\plugins\org.apache.commons.logging_1.0.4.v200706111 724.jar;
>>
>> <eclipse_home> \eclipse\plugins\org.apache.commons.el_1.0.0.v200706111724.j ar;
>>
>> <eclipse_home>\eclipse\plugins\javax.servlet_2.4.0.v200706111738.jar;
>> <eclipse_home>\eclipse\plugins\javax.servlet.jsp_2.0.0.v200706191603.jar;
>> <eclipse_home> \eclipse\plugins\org.apache.jasper_5.5.17.v200706111724.jar;
>>
>> <eclipse_home> \eclipse\plugins\org.mortbay.jetty_5.1.11.v200706111724.jar;
>>
>> <wtp_home> \eclipse\plugins\org.eclipse.wst.server.preview_1.0.0.v20070 5302225.jar
>>
>> org.eclipse.wst.server.preview.internal.PreviewStarter
>> <workspace_home> \.metadata\.plugins\org.eclipse.wst.server.core\tmp?\preview .xml
>>
>>
>> The problem is "org.apache.commons.logging_1.0.4". Without
>> specifically configuring what you want commons.logging to do, you get
>> what ever the default configuration algorithm decides. The knock on
>> commons.logging has always been that this default configuration
>> algorithm works in some cases and doesn't work in others. This is one
>> of the "others". The solution to the errant behavior depends very
>> much on the details of your situation and what exactly you want to
>> accomplish. Assuming you don't care about what the Jetty server is
>> logging, but just want to use Log4J in the webapp, then I believe
>> adding the following VM argument to the J2EE Preview launch
>> configuration should get things working:
>>
>> -Dorg.apache.commons.logging.Log=org.apache.commons.logging. impl.SimpleLog
>>
>>
>> This tells commons.logging to always use the default "SimpleLog"
>> logger instead of letting the configuration algorithm incorrectly
>> "discover" the Log4J in your webapp. Your webapp should then be free
>> to use Log4J without interference from commons.logging. See if that
>> fixes your situation. Supposedly commons.logging 1.1.x is better
>> about this kind of thing, but I don't currently see it in the
>> installed Eclipse bundles, even for Eclipse 3.4 and WTP 3.0.
>>
>> Cheers,
>> Larry
>>
>>
>> Christopher Smith wrote:
>>> I have a 3rd party servlet I would like to run in my Dynamic Web
>>> project using the embedded J2EE Preview runtime (Jetty). The project
>>> has log4j-1.2.9.jar in the WEB-INF/lib folder.
>>>
>>> This servlet runs without problem with a tomcat runtime AND runs
>>> without problem in a stand alone Jetty.
>>>
>>> When I try to start the J2EE Preview server, I get:
>>> Starting preview server
>>>
>>> Port 8080
>>> Modules:
>>> TransacXML
>>>
>> <Stack trace snipped/>
>>
>>>
>>> My servlet does not run.
>>>
>>> If I remove the log4j jar file, the Preview server start up fine and
>>> reports that the servlet is loaded. When the servet actually trys to
>>> run, it complains about log4j
>>>
>>> Starting preview server
>>>
>>> Port 8080
>>> Modules:
>>> TransacXML
>>>
>>
>> <Stack trace snipped/>
>>
>>>
>>> As you can see, the servlet falls over when it tries to use log4j.
>>> This is a third party servlet and I do not have source. Any
>>> suggestions?
Re: J2EE Preview Server, Jetty, Dynamic Web Projects and log4j [message #212876 is a reply to message #212790] Thu, 24 April 2008 13:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jason.hendriks.ca

I'm a long-time Websphere AD and Rational AD user just trying Eclipse
for the first time. Best practice at Big Blue is keen on abstraction, so
yes I am used to hiding the Log4J layer from my apps with Commons Logging.

I AM seeing red (syserr) text in the console as the J2EE Preview server
starts. And I do see black (sysout) text from Log4J from my own code.
But there is no text (red or black!) from my own code when I attempt to
use Commons Logging.

Log4J is a fine work-around, I'm surprised and impressed at how well
Eclipse for Linux ran 'out-of-the-box'.

v3.3.2 by the way.

Thanks for your time, Larry.


Larry Isaacs wrote:
> Application servers and servlet containers host other "applications",
> which leads to complexities involving classloaders. This makes logging
> setup difficult given the various use cases that may be desired. Some
> may want a single choice of logger and configuration for the entire
> application server or servlet container. Others may want each webapp to
> have their own choice of logger and logging configuration. Typically,
> each use case requires a different configuration of the server. This is
> why WTP has largely punted on this issue. Thus, at the current time,
> logging configuration is left as an exercise for the user.
>
> Since Preview Server (i.e. Jetty) is using the full commons logging
> 1.0.4 jar, the possibilities are somewhat restricted. The suggestion
> earlier basically implemented the use case of getting commons logging
> out of the way so each webapp could independently use log4j directly. By
> configuring commons logging to use SimpleLog, I would expect the commons
> logging output to go to the console. It defaults to writing output to
> System.err with a default level of "info". Are you not seeing such
> output in the Console view? Is it your desire instead to have your
> webapp use commons logging running on top of Log4j rather than Log4j
> directly?
>
> Cheers,
> Larry
>
>
> Jason Hendriks wrote:
>> Larry, I had the same problem. Adding the VM argument to the J2EE
>> Preview launch configuration made the error go away and allowed the
>> J2EE Preview Server to start. Thank-you.
>>
>> *But*. Now I can't see any output that my own classes send to Commons
>> logging. This was working as an Eclipse Java project, but as a,
>> Eclipse Dynamic Web Project it does not work. If I use log4j logging
>> directly from my own classes, the logging works fine.
>>
>> (i.e.) In the web project, l2 generates output as specified by
>> log4j.properties but l1 does not.
>>
>> private final static Log l1 = LogFactory.getLog(MyTest.class);
>> private final static Logger l2 = Logger.getLogger(MyTest.class);
>>
>> There are no errors. Perhaps I'm missing something non-Eclipse related
>> for connecting Log4J to Commons Logging in a J2EE application?
>>
>>
>> Larry Isaacs wrote:
>>> If you start the J2EE Preview server, open the Debug view, then
>>> right-click the Java executable in the tree and select Properties,
>>> you will find something similar to the following as the executed
>>> command:
>>>
>>> <java home>\bin\javaw.exe
>>> -classpath
>>> <eclipse_home> \eclipse\plugins\org.apache.commons.logging_1.0.4.v200706111 724.jar;
>>>
>>> <eclipse_home> \eclipse\plugins\org.apache.commons.el_1.0.0.v200706111724.j ar;
>>>
>>> <eclipse_home>\eclipse\plugins\javax.servlet_2.4.0.v200706111738.jar;
>>> <eclipse_home>\eclipse\plugins\javax.servlet.jsp_2.0.0.v200706191603.jar;
>>>
>>> <eclipse_home> \eclipse\plugins\org.apache.jasper_5.5.17.v200706111724.jar;
>>>
>>> <eclipse_home> \eclipse\plugins\org.mortbay.jetty_5.1.11.v200706111724.jar;
>>>
>>> <wtp_home> \eclipse\plugins\org.eclipse.wst.server.preview_1.0.0.v20070 5302225.jar
>>>
>>> org.eclipse.wst.server.preview.internal.PreviewStarter
>>> <workspace_home> \.metadata\.plugins\org.eclipse.wst.server.core\tmp?\preview .xml
>>>
>>>
>>> The problem is "org.apache.commons.logging_1.0.4". Without
>>> specifically configuring what you want commons.logging to do, you get
>>> what ever the default configuration algorithm decides. The knock on
>>> commons.logging has always been that this default configuration
>>> algorithm works in some cases and doesn't work in others. This is
>>> one of the "others". The solution to the errant behavior depends
>>> very much on the details of your situation and what exactly you want
>>> to accomplish. Assuming you don't care about what the Jetty server
>>> is logging, but just want to use Log4J in the webapp, then I believe
>>> adding the following VM argument to the J2EE Preview launch
>>> configuration should get things working:
>>>
>>> -Dorg.apache.commons.logging.Log=org.apache.commons.logging. impl.SimpleLog
>>>
>>>
>>> This tells commons.logging to always use the default "SimpleLog"
>>> logger instead of letting the configuration algorithm incorrectly
>>> "discover" the Log4J in your webapp. Your webapp should then be free
>>> to use Log4J without interference from commons.logging. See if that
>>> fixes your situation. Supposedly commons.logging 1.1.x is better
>>> about this kind of thing, but I don't currently see it in the
>>> installed Eclipse bundles, even for Eclipse 3.4 and WTP 3.0.
>>>
>>> Cheers,
>>> Larry
>>>
>>>
>>> Christopher Smith wrote:
>>>> I have a 3rd party servlet I would like to run in my Dynamic Web
>>>> project using the embedded J2EE Preview runtime (Jetty). The
>>>> project has log4j-1.2.9.jar in the WEB-INF/lib folder.
>>>>
>>>> This servlet runs without problem with a tomcat runtime AND runs
>>>> without problem in a stand alone Jetty.
>>>>
>>>> When I try to start the J2EE Preview server, I get:
>>>> Starting preview server
>>>>
>>>> Port 8080
>>>> Modules:
>>>> TransacXML
>>>>
>>> <Stack trace snipped/>
>>>
>>>>
>>>> My servlet does not run.
>>>>
>>>> If I remove the log4j jar file, the Preview server start up fine and
>>>> reports that the servlet is loaded. When the servet actually trys
>>>> to run, it complains about log4j
>>>>
>>>> Starting preview server
>>>>
>>>> Port 8080
>>>> Modules:
>>>> TransacXML
>>>>
>>>
>>> <Stack trace snipped/>
>>>
>>>>
>>>> As you can see, the servlet falls over when it tries to use log4j.
>>>> This is a third party servlet and I do not have source. Any
>>>> suggestions?
Re: J2EE Preview Server, Jetty, Dynamic Web Projects and log4j [message #212884 is a reply to message #212790] Thu, 24 April 2008 13:31 Go to previous message
Eclipse UserFriend
Originally posted by: jason.hendriks.ca

I'm a long-time Websphere AD and Rational AD user just trying Eclipse
for the first time. Best practice at Big Blue is keen on abstraction, so
yes I am used to hiding the Log4J layer from my apps with Commons Logging.

I AM seeing red (syserr) text in the console as the J2EE Preview server
starts. And I do see black (sysout) text from Log4J from my own code.
But there is no text (red or black!) from my own code when I attempt to
use Commons Logging.

Log4J is a fine work-around, I'm surprised and impressed at how well
Eclipse for Linux ran 'out-of-the-box'.

v3.3.2 by the way.

Thanks for your time, Larry.


Larry Isaacs wrote:
> Application servers and servlet containers host other "applications",
> which leads to complexities involving classloaders. This makes logging
> setup difficult given the various use cases that may be desired. Some
> may want a single choice of logger and configuration for the entire
> application server or servlet container. Others may want each webapp to
> have their own choice of logger and logging configuration. Typically,
> each use case requires a different configuration of the server. This is
> why WTP has largely punted on this issue. Thus, at the current time,
> logging configuration is left as an exercise for the user.
>
> Since Preview Server (i.e. Jetty) is using the full commons logging
> 1.0.4 jar, the possibilities are somewhat restricted. The suggestion
> earlier basically implemented the use case of getting commons logging
> out of the way so each webapp could independently use log4j directly. By
> configuring commons logging to use SimpleLog, I would expect the commons
> logging output to go to the console. It defaults to writing output to
> System.err with a default level of "info". Are you not seeing such
> output in the Console view? Is it your desire instead to have your
> webapp use commons logging running on top of Log4j rather than Log4j
> directly?
>
> Cheers,
> Larry
>
>
> Jason Hendriks wrote:
>> Larry, I had the same problem. Adding the VM argument to the J2EE
>> Preview launch configuration made the error go away and allowed the
>> J2EE Preview Server to start. Thank-you.
>>
>> *But*. Now I can't see any output that my own classes send to Commons
>> logging. This was working as an Eclipse Java project, but as a,
>> Eclipse Dynamic Web Project it does not work. If I use log4j logging
>> directly from my own classes, the logging works fine.
>>
>> (i.e.) In the web project, l2 generates output as specified by
>> log4j.properties but l1 does not.
>>
>> private final static Log l1 = LogFactory.getLog(MyTest.class);
>> private final static Logger l2 = Logger.getLogger(MyTest.class);
>>
>> There are no errors. Perhaps I'm missing something non-Eclipse related
>> for connecting Log4J to Commons Logging in a J2EE application?
>>
>>
>> Larry Isaacs wrote:
>>> If you start the J2EE Preview server, open the Debug view, then
>>> right-click the Java executable in the tree and select Properties,
>>> you will find something similar to the following as the executed
>>> command:
>>>
>>> <java home>\bin\javaw.exe
>>> -classpath
>>> <eclipse_home> \eclipse\plugins\org.apache.commons.logging_1.0.4.v200706111 724.jar;
>>>
>>> <eclipse_home> \eclipse\plugins\org.apache.commons.el_1.0.0.v200706111724.j ar;
>>>
>>> <eclipse_home>\eclipse\plugins\javax.servlet_2.4.0.v200706111738.jar;
>>> <eclipse_home>\eclipse\plugins\javax.servlet.jsp_2.0.0.v200706191603.jar;
>>>
>>> <eclipse_home> \eclipse\plugins\org.apache.jasper_5.5.17.v200706111724.jar;
>>>
>>> <eclipse_home> \eclipse\plugins\org.mortbay.jetty_5.1.11.v200706111724.jar;
>>>
>>> <wtp_home> \eclipse\plugins\org.eclipse.wst.server.preview_1.0.0.v20070 5302225.jar
>>>
>>> org.eclipse.wst.server.preview.internal.PreviewStarter
>>> <workspace_home> \.metadata\.plugins\org.eclipse.wst.server.core\tmp?\preview .xml
>>>
>>>
>>> The problem is "org.apache.commons.logging_1.0.4". Without
>>> specifically configuring what you want commons.logging to do, you get
>>> what ever the default configuration algorithm decides. The knock on
>>> commons.logging has always been that this default configuration
>>> algorithm works in some cases and doesn't work in others. This is
>>> one of the "others". The solution to the errant behavior depends
>>> very much on the details of your situation and what exactly you want
>>> to accomplish. Assuming you don't care about what the Jetty server
>>> is logging, but just want to use Log4J in the webapp, then I believe
>>> adding the following VM argument to the J2EE Preview launch
>>> configuration should get things working:
>>>
>>> -Dorg.apache.commons.logging.Log=org.apache.commons.logging. impl.SimpleLog
>>>
>>>
>>> This tells commons.logging to always use the default "SimpleLog"
>>> logger instead of letting the configuration algorithm incorrectly
>>> "discover" the Log4J in your webapp. Your webapp should then be free
>>> to use Log4J without interference from commons.logging. See if that
>>> fixes your situation. Supposedly commons.logging 1.1.x is better
>>> about this kind of thing, but I don't currently see it in the
>>> installed Eclipse bundles, even for Eclipse 3.4 and WTP 3.0.
>>>
>>> Cheers,
>>> Larry
>>>
>>>
>>> Christopher Smith wrote:
>>>> I have a 3rd party servlet I would like to run in my Dynamic Web
>>>> project using the embedded J2EE Preview runtime (Jetty). The
>>>> project has log4j-1.2.9.jar in the WEB-INF/lib folder.
>>>>
>>>> This servlet runs without problem with a tomcat runtime AND runs
>>>> without problem in a stand alone Jetty.
>>>>
>>>> When I try to start the J2EE Preview server, I get:
>>>> Starting preview server
>>>>
>>>> Port 8080
>>>> Modules:
>>>> TransacXML
>>>>
>>> <Stack trace snipped/>
>>>
>>>>
>>>> My servlet does not run.
>>>>
>>>> If I remove the log4j jar file, the Preview server start up fine and
>>>> reports that the servlet is loaded. When the servet actually trys
>>>> to run, it complains about log4j
>>>>
>>>> Starting preview server
>>>>
>>>> Port 8080
>>>> Modules:
>>>> TransacXML
>>>>
>>>
>>> <Stack trace snipped/>
>>>
>>>>
>>>> As you can see, the servlet falls over when it tries to use log4j.
>>>> This is a third party servlet and I do not have source. Any
>>>> suggestions?
Previous Topic:Difficulties with StructuredTextEditor in a MultiPageEditorPart
Next Topic:Help with jar files not getting exported in WAR file
Goto Forum:
  


Current Time: Thu Mar 28 18:07:51 GMT 2024

Powered by FUDForum. Page generated in 0.02905 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top