maven plugin, excluding slf4j dependency

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

maven plugin, excluding slf4j dependency

David Smiley @MITRE.org
I'm having configuration / classloader nightmare with SLF4J &
commons-logging on Jetty 6 under JDK 1.4.  I'd like to have the SLF4J
stuff completely off of my classpath when invoking the Jetty plugin with
maven.  Does anyone know how I can ensure that this happens?  I tried
putting the following dependency info right after the <configuration/>
element for the plugin:

                     <dependencies>
                         <dependency>
                             <groupId>log4j</groupId>
                             <artifactId>log4j</artifactId>
                             <version>1.2.8</version>
                         </dependency>
                         <dependency>
                             <groupId>commons-logging</groupId>
                             <artifactId>commons-logging</artifactId>
                             <version>1.1</version>
                         </dependency>
                         <dependency>
                             <groupId>org.mortbay.jetty</groupId>
                             <artifactId>project</artifactId>
                             <version>6.0-SNAPSHOT</version>
                             <type>pom</type>
                             <exclusions>
                                 <exclusion>
                                     <groupId>org.slf4j</groupId>
                    <artifactId>jcl104-over-slf4j</artifactId>
                                 </exclusion>
                                 <exclusion>
                                     <groupId>org.slf4j</groupId>
                    <artifactId>jslf4j-simple</artifactId>
                                 </exclusion>
                             </exclusions>
                         </dependency>
                     </dependencies>

But it did not successfully remove those SLF4J jars because I see it via
mvn -X and the error I ultimately get suggests it's active.

~ David Smiley



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

jan_bartel
David,

Have a look at the plugin how-to page here:
http://jetty.mortbay.org/jetty6/maven-plugin/howto.html

Look at the section about jdk1.5 and JSP2.1 You need to use
a profile for jdk1.4 to introduce a dependency on jsp-2.0
(note that the artifact type is pom) and use exclusions
to get rid of the slf4j jars, and introduce your log4j and
commons logging jars.

cheers
Jan

David Smiley wrote:

> I'm having configuration / classloader nightmare with SLF4J &
> commons-logging on Jetty 6 under JDK 1.4.  I'd like to have the SLF4J
> stuff completely off of my classpath when invoking the Jetty plugin with
> maven.  Does anyone know how I can ensure that this happens?  I tried
> putting the following dependency info right after the <configuration/>
> element for the plugin:
>
>                      <dependencies>
>                          <dependency>
>                              <groupId>log4j</groupId>
>                              <artifactId>log4j</artifactId>
>                              <version>1.2.8</version>
>                          </dependency>
>                          <dependency>
>                              <groupId>commons-logging</groupId>
>                              <artifactId>commons-logging</artifactId>
>                              <version>1.1</version>
>                          </dependency>
>                          <dependency>
>                              <groupId>org.mortbay.jetty</groupId>
>                              <artifactId>project</artifactId>
>                              <version>6.0-SNAPSHOT</version>
>                              <type>pom</type>
>                              <exclusions>
>                                  <exclusion>
>                                      <groupId>org.slf4j</groupId>
>                     <artifactId>jcl104-over-slf4j</artifactId>
>                                  </exclusion>
>                                  <exclusion>
>                                      <groupId>org.slf4j</groupId>
>                     <artifactId>jslf4j-simple</artifactId>
>                                  </exclusion>
>                              </exclusions>
>                          </dependency>
>                      </dependencies>
>
> But it did not successfully remove those SLF4J jars because I see it via
> mvn -X and the error I ultimately get suggests it's active.
>
> ~ David Smiley
>
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

David Smiley @MITRE.org
I've seen that page already, of course.
I have the following dependency exclusion (which now uses the jsp-2.0
artifact):
<dependencies>
                         <dependency>
                             <groupId>org.mortbay.jetty</groupId>
                             <artifactId>jsp-2.0</artifactId>
                             <version>6.0-SNAPSHOT</version>
                             <type>pom</type>
                             <exclusions>
                                 <exclusion>
                                     <groupId>org.slf4j</groupId>
 
<artifactId>jcl104-over-slf4j</artifactId>
                                 </exclusion>
                                 <exclusion>
                                     <groupId>org.slf4j</groupId>
                                     <artifactId>jslf4j-simple</artifactId>
                                 </exclusion>
                             </exclusions>
                         </dependency>
                     </dependencies>

And I've put that in many places simultaneously to include: a jdk1.4
activated profile in my pom (because I'm using 1.4), off the plugin
configuration in pluginManagement/plugin(for jetty)/dependencies, and in
the pom's dependencymanagement.  Every time I run jetty:run, those darn
SLF4J jars get loaded, which screw up commons-logging when my webapp
tries to use commons-logging.  The actual error I see, by the way is this:
Caused by: org.apache.commons.discovery.DiscoveryException: Class
org.apache.commons.logging.impl.SLF4FLogFactory does not implement
org.apache.commons.logging.LogFactory

But SLF4FLogFactory does in fact implement LogFactory... I believe this
error is due to a classloader issue whereas commons-logging is in my
webapp (it should be there) and also by Jetty... and so different
classloaders are loading it.  That's my theory.  I'd rather have SLF4J
off my classpath altogether so it can't mess with things.

~ David Smiley

Jan Bartel wrote:

> David,
>
> Have a look at the plugin how-to page here:
> http://jetty.mortbay.org/jetty6/maven-plugin/howto.html
>
> Look at the section about jdk1.5 and JSP2.1 You need to use
> a profile for jdk1.4 to introduce a dependency on jsp-2.0
> (note that the artifact type is pom) and use exclusions
> to get rid of the slf4j jars, and introduce your log4j and
> commons logging jars.
>
> cheers
> Jan
>
> David Smiley wrote:
>> I'm having configuration / classloader nightmare with SLF4J &
>> commons-logging on Jetty 6 under JDK 1.4.  I'd like to have the SLF4J
>> stuff completely off of my classpath when invoking the Jetty plugin with
>> maven.  Does anyone know how I can ensure that this happens?  I tried
>> putting the following dependency info right after the <configuration/>
>> element for the plugin:
>>
>>                      <dependencies>
>>                          <dependency>
>>                              <groupId>log4j</groupId>
>>                              <artifactId>log4j</artifactId>
>>                              <version>1.2.8</version>
>>                          </dependency>
>>                          <dependency>
>>                              <groupId>commons-logging</groupId>
>>                              <artifactId>commons-logging</artifactId>
>>                              <version>1.1</version>
>>                          </dependency>
>>                          <dependency>
>>                              <groupId>org.mortbay.jetty</groupId>
>>                              <artifactId>project</artifactId>
>>                              <version>6.0-SNAPSHOT</version>
>>                              <type>pom</type>
>>                              <exclusions>
>>                                  <exclusion>
>>                                      <groupId>org.slf4j</groupId>
>>                     <artifactId>jcl104-over-slf4j</artifactId>
>>                                  </exclusion>
>>                                  <exclusion>
>>                                      <groupId>org.slf4j</groupId>
>>                     <artifactId>jslf4j-simple</artifactId>
>>                                  </exclusion>
>>                              </exclusions>
>>                          </dependency>
>>                      </dependencies>
>>
>> But it did not successfully remove those SLF4J jars because I see it via
>> mvn -X and the error I ultimately get suggests it's active.
>>
>> ~ David Smiley
>>
>>
>>
>> -------------------------------------------------------------------------
>> Using Tomcat but need to do more? Need to support web services, security?
>> Get stuff done quickly with pre-integrated technology to make your job easier
>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

jan_bartel
David,

You've got a minor typo which isn't helping:
jslf4j-simple should be just slf4j-simple.

However, I've been trying to get this profile to work and
failing miserably. Somehow the %"$%£%!! slf4j jars stay
on the classpath!

Just for the record, my profile looks like (sorry about the
poor indentation):
  <profiles>
    <profile>
      <id>jdk1.4</id>
      <activation>
        <jdk>1.4</jdk>
      </activation>
       <dependencies>
                         <dependency>
                             <groupId>org.mortbay.jetty</groupId>
                             <artifactId>jsp-2.0</artifactId>
                             <version>6.0-SNAPSHOT</version>
                             <type>pom</type>
                             <exclusions>
                                 <exclusion>
                                      <artifactId>jcl104-over-slf4j</artifactId>
                                     <groupId>org.slf4j</groupId>
                                 </exclusion>
                                 <exclusion>
                                     <artifactId>slf4j-simple</artifactId>
                                     <groupId>org.slf4j</groupId>
                                 </exclusion>
                             </exclusions>
                         </dependency>
                     </dependencies>
    </profile>
  </profiles>


Now strangely enough, if I use jdk1.5 instead and change my profile
to apply to jdk1.5 instead, it works! The slf4j jars are off the classpath!

At this point, I am going to have to ask you to bring this up with
the maven guys, as it seems like a bug to me.

In the interim, is there any way you could learn to love slf4j instead?
Could you just run the plugin with it instead of commons-logging?
You could try making your commons-logging of scope
<provided> so it doesn't go into the runtime of the
plugin. Of course, I think that will mean that it won't get built
into your war either, so perhaps in that case you could try putting
it as a <dependency> for the war plugin?

regards
Jan


David Smiley wrote:

> I've seen that page already, of course.
> I have the following dependency exclusion (which now uses the jsp-2.0
> artifact):
> <dependencies>
>                          <dependency>
>                              <groupId>org.mortbay.jetty</groupId>
>                              <artifactId>jsp-2.0</artifactId>
>                              <version>6.0-SNAPSHOT</version>
>                              <type>pom</type>
>                              <exclusions>
>                                  <exclusion>
>                                      <groupId>org.slf4j</groupId>
>  
> <artifactId>jcl104-over-slf4j</artifactId>
>                                  </exclusion>
>                                  <exclusion>
>                                      <groupId>org.slf4j</groupId>
>                                      <artifactId>jslf4j-simple</artifactId>
>                                  </exclusion>
>                              </exclusions>
>                          </dependency>
>                      </dependencies>
>
> And I've put that in many places simultaneously to include: a jdk1.4
> activated profile in my pom (because I'm using 1.4), off the plugin
> configuration in pluginManagement/plugin(for jetty)/dependencies, and in
> the pom's dependencymanagement.  Every time I run jetty:run, those darn
> SLF4J jars get loaded, which screw up commons-logging when my webapp
> tries to use commons-logging.  The actual error I see, by the way is this:
> Caused by: org.apache.commons.discovery.DiscoveryException: Class
> org.apache.commons.logging.impl.SLF4FLogFactory does not implement
> org.apache.commons.logging.LogFactory
>
> But SLF4FLogFactory does in fact implement LogFactory... I believe this
> error is due to a classloader issue whereas commons-logging is in my
> webapp (it should be there) and also by Jetty... and so different
> classloaders are loading it.  That's my theory.  I'd rather have SLF4J
> off my classpath altogether so it can't mess with things.
>
> ~ David Smiley
>
> Jan Bartel wrote:
>
>>David,
>>
>>Have a look at the plugin how-to page here:
>>http://jetty.mortbay.org/jetty6/maven-plugin/howto.html
>>
>>Look at the section about jdk1.5 and JSP2.1 You need to use
>>a profile for jdk1.4 to introduce a dependency on jsp-2.0
>>(note that the artifact type is pom) and use exclusions
>>to get rid of the slf4j jars, and introduce your log4j and
>>commons logging jars.
>>
>>cheers
>>Jan
>>
>>David Smiley wrote:
>>
>>>I'm having configuration / classloader nightmare with SLF4J &
>>>commons-logging on Jetty 6 under JDK 1.4.  I'd like to have the SLF4J
>>>stuff completely off of my classpath when invoking the Jetty plugin with
>>>maven.  Does anyone know how I can ensure that this happens?  I tried
>>>putting the following dependency info right after the <configuration/>
>>>element for the plugin:
>>>
>>>                     <dependencies>
>>>                         <dependency>
>>>                             <groupId>log4j</groupId>
>>>                             <artifactId>log4j</artifactId>
>>>                             <version>1.2.8</version>
>>>                         </dependency>
>>>                         <dependency>
>>>                             <groupId>commons-logging</groupId>
>>>                             <artifactId>commons-logging</artifactId>
>>>                             <version>1.1</version>
>>>                         </dependency>
>>>                         <dependency>
>>>                             <groupId>org.mortbay.jetty</groupId>
>>>                             <artifactId>project</artifactId>
>>>                             <version>6.0-SNAPSHOT</version>
>>>                             <type>pom</type>
>>>                             <exclusions>
>>>                                 <exclusion>
>>>                                     <groupId>org.slf4j</groupId>
>>>                    <artifactId>jcl104-over-slf4j</artifactId>
>>>                                 </exclusion>
>>>                                 <exclusion>
>>>                                     <groupId>org.slf4j</groupId>
>>>                    <artifactId>jslf4j-simple</artifactId>
>>>                                 </exclusion>
>>>                             </exclusions>
>>>                         </dependency>
>>>                     </dependencies>
>>>
>>>But it did not successfully remove those SLF4J jars because I see it via
>>>mvn -X and the error I ultimately get suggests it's active.
>>>
>>>~ David Smiley
>>>
>>>
>>>
>>>-------------------------------------------------------------------------
>>>Using Tomcat but need to do more? Need to support web services, security?
>>>Get stuff done quickly with pre-integrated technology to make your job easier
>>>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>>
>>
>>
>>-------------------------------------------------------------------------
>>Using Tomcat but need to do more? Need to support web services, security?
>>Get stuff done quickly with pre-integrated technology to make your job easier
>>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
>
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

Ceki Gulcu-2
In reply to this post by David Smiley @MITRE.org

Hello,

The slf4j-simple.jar dependency should not get on your way. It only
includes SLF4J classes without any reference to comming-logging (JCL). If
you really want to use commons logging instead of jcl104-over-slf4j.jar
then removing the jcl104-over-slf4j.jar dependency should eliminate
interactions with JCL.

I would also suggest to read the SLF4J docs [1] which explain the purpose
of the various SLF4J jar files. As Jan implied, there might be a Maven
issue involved as well.

I hope this helps,

[1] http://www.slf4j.org/manual.html

At 08:45 PM 7/13/2006, David Smiley wrote:

>I'm having configuration / classloader nightmare with SLF4J &
>commons-logging on Jetty 6 under JDK 1.4.  I'd like to have the SLF4J
>stuff completely off of my classpath when invoking the Jetty plugin with
>maven.  Does anyone know how I can ensure that this happens?  I tried
>putting the following dependency info right after the <configuration/>
>element for the plugin:
>
>                      <dependencies>
>                          <dependency>
>                              <groupId>log4j</groupId>
>                              <artifactId>log4j</artifactId>
>                              <version>1.2.8</version>
>                          </dependency>
>                          <dependency>
>                              <groupId>commons-logging</groupId>
>                              <artifactId>commons-logging</artifactId>
>                              <version>1.1</version>
>                          </dependency>
>                          <dependency>
>                              <groupId>org.mortbay.jetty</groupId>
>                              <artifactId>project</artifactId>
>                              <version>6.0-SNAPSHOT</version>
>                              <type>pom</type>
>                              <exclusions>
>                                  <exclusion>
>                                      <groupId>org.slf4j</groupId>
>                     <artifactId>jcl104-over-slf4j</artifactId>
>                                  </exclusion>
>                                  <exclusion>
>                                      <groupId>org.slf4j</groupId>
>                     <artifactId>jslf4j-simple</artifactId>
>                                  </exclusion>
>                              </exclusions>
>                          </dependency>
>                      </dependencies>
>
>But it did not successfully remove those SLF4J jars because I see it via
>mvn -X and the error I ultimately get suggests it's active.
>
>~ David Smiley
>
>
>
>-------------------------------------------------------------------------
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>_______________________________________________
>jetty-discuss mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/jetty-discuss

--
Ceki Gülcü
http://ceki.blogspot.com/


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

David Smiley @MITRE.org
In reply to this post by jan_bartel
I have started a threat on the maven list but no responses yet:
http://www.nabble.com/jetty6-plugin%2C-excluding-slf4j-dependency-tf1954762.html

By the way... I don't think the profiles way of handling this is correct since when I do that... it puts jetty's jsp-2.0 related jars on the classpath for all of my many modules.  They end up in my war files!  Instead... I belive the dependencies element off of the particular plugin is where this belongs... since I'm trying to tweak the dependencies of the plugin, not of my project.  The distiction is important.

I looked into the classloading problem a bit more that can be seen with jdk 1.4, jetty via maven, and a webapp that's using JCL (such as axis 1.x web services).  Commons-logging uses commons-discovery to discover the logging implementation class.  That class (an SLF4J class) does implement the JCL interface... however the SLF4J implementing class's JCL interface was loaded by ClassWorlds (underneath the jetty webapp loader) which is different than the interface that was ALSO loaded by the webapp loader.  This is difficult to explain.  This doesn't have to do with the logging framework war... this could happen to anything else that jetty has on its classpath.  I think the solution may be for the webapp classloader to skip over jetty's loader (making jetty extremely transparent).  This would hide anything jetty wants to use.  There would have to be an intermediate classloader between the systemclassloader and jetty's loader and that would be the standard servlet API jar.  Is anyone following me?

I've reluctantly switched to SLF4J... I don't want to take sides in a logging framework war.  I just want an app (that I didn't even write) to work.
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

jan_bartel
Hi David,

comments inline below.

> I have started a threat on the maven list but no responses yet:
> http://www.nabble.com/jetty6-plugin%2C-excluding-slf4j-dependency-tf1954762.html
Cool.

> By the way... I don't think the profiles way of handling this is correct
> since when I do that... it puts jetty's jsp-2.0 related jars on the
> classpath for all of my many modules.  They end up in my war files!
> Instead... I belive the dependencies element off of the particular plugin is
> where this belongs... since I'm trying to tweak the dependencies of the
> plugin, not of my project.  The distiction is important.
The way the jsp jar dependencies used to be decided was with some quite
convoluted code I wrote. It worked, but the maven committers sent me a
patch to do it via profiles, so I applied that after beta17. They also
suggested the overriding of the profiles in the client pom by using the
same profile id. It appears that maven may not be strictly applying this
properly, which is something the maven-ers need to look into.

Having said that, I think this is only a short-term problem.

I want to replace the jsp container used by plugin. Currently, there are
2 choices: jsp-2.0 or jsp-2.1. Both of these are jasper (from tomcat). The
jsp-2.0 is mature, but the jsp-2.1 implementation is very under-done. I would
make jsp-2.1 the default (because it should also handle jsp-2.0 isms) but
because of the bugs in it, people want to drop back to using the more mature
jsp-2.0.

My intended solution is to instead use the jsp container from glassfish.
This is already available with standard jetty as a patch. I have been
corresponding with Jan Luehe of glassfish and their jsp container is
nearly ready to use the eclipse compiler instead of javac. As soon as
that is available, I will switch the plugin to using that exclusively.
Then I believe we can get rid of this jsp-2.0/jsp-2.1 dichotomy because
we will have only a single impl that works for both versions.

> I looked into the classloading problem a bit more that can be seen with jdk
> 1.4, jetty via maven, and a webapp that's using JCL (such as axis 1.x web
> services).  Commons-logging uses commons-discovery to discover the logging
> implementation class.  That class (an SLF4J class) does implement the JCL
> interface... however the SLF4J implementing class's JCL interface was loaded
> by ClassWorlds (underneath the jetty webapp loader) which is different than
> the interface that was ALSO loaded by the webapp loader.  This is difficult
> to explain.  This doesn't have to do with the logging framework war... this
> could happen to anything else that jetty has on its classpath.  I think the
> solution may be for the webapp classloader to skip over jetty's loader
> (making jetty extremely transparent).  This would hide anything jetty wants
> to use.  There would have to be an intermediate classloader between the
> systemclassloader and jetty's loader and that would be the standard servlet
> API jar.  Is anyone following me?
Yeah.

I've been thinking of changing the plugin to create a new classloader for
jetty that would be the parent loader for the webapp, but would have as
it's parent the system classloader (ie we would effectively "skip" the
maven classworlds' loader).

I am hesitant to do this because a) messing around with classloaders is
always hairy and you wind up in a world of pain and b) I haven't worked
out how to make sure the new classloader has all of the necessary jars,
which would at least be = plugin's dependency jars + client's plugin dependencies + client dependencies

I'll have a chat to the maven guys and see if I can clarify this a bit.
I didn't realize that the maven container was using SLF4J too.

> I've reluctantly switched to SLF4J... I don't want to take sides in a
> logging framework war.  I just want an app (that I didn't even write) to
> work.
I hear you.

cheers
Jan


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

Ceki Gulcu-2
In reply to this post by David Smiley @MITRE.org

I would like to make an observation with the hope that it will be helpful.
First, JCL does *not* use commons discovery, but axis 1.x does. If my
memory serves me correctly, Axis uses commons-discovery to load JCL and in
the process it may inadvertently load the jcl-over-slf4j implementation of
JCL instead of the official JCL.


At 06:34 AM 7/18/2006, David Smiley wrote:

>I have started a threat on the maven list but no responses yet:
>http://www.nabble.com/jetty6-plugin%2C-excluding-slf4j-dependency-tf1954762.html
>
>By the way... I don't think the profiles way of handling this is correct
>since when I do that... it puts jetty's jsp-2.0 related jars on the
>classpath for all of my many modules.  They end up in my war files!
>Instead... I belive the dependencies element off of the particular plugin is
>where this belongs... since I'm trying to tweak the dependencies of the
>plugin, not of my project.  The distiction is important.
>
>I looked into the classloading problem a bit more that can be seen with jdk
>1.4, jetty via maven, and a webapp that's using JCL (such as axis 1.x web
>services).  Commons-logging uses commons-discovery to discover the logging
>implementation class.  That class (an SLF4J class) does implement the JCL
>interface... however the SLF4J implementing class's JCL interface was loaded
>by ClassWorlds (underneath the jetty webapp loader) which is different than
>the interface that was ALSO loaded by the webapp loader.  This is difficult
>to explain.  This doesn't have to do with the logging framework war... this
>could happen to anything else that jetty has on its classpath.  I think the
>solution may be for the webapp classloader to skip over jetty's loader
>(making jetty extremely transparent).  This would hide anything jetty wants
>to use.  There would have to be an intermediate classloader between the
>systemclassloader and jetty's loader and that would be the standard servlet
>API jar.  Is anyone following me?
>
>I've reluctantly switched to SLF4J... I don't want to take sides in a
>logging framework war.  I just want an app (that I didn't even write) to
>work.
>--
>View this message in context:
>http://www.nabble.com/maven-plugin%2C-excluding-slf4j-dependency-tf1939206.html#a5372486
>Sent from the Jetty Discuss forum at Nabble.com.
>
>
>-------------------------------------------------------------------------
>Take Surveys. Earn Cash. Influence the Future of IT
>Join SourceForge.net's Techsay panel and you'll get the chance to share your
>opinions on IT & business topics through brief surveys -- and earn cash
>http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>_______________________________________________
>jetty-discuss mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/jetty-discuss

--
Ceki Gülcü
http://ceki.blogspot.com/


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

Dave Syer

> I would like to make an observation with the hope that it will be helpful.
> First, JCL does *not* use commons discovery, but axis 1.x does. If my
> memory serves me correctly, Axis uses commons-discovery to load JCL and in
> the process it may inadvertently load the jcl-over-slf4j implementation of
> JCL instead of the official JCL.

Anybody got any idea how to do this?  In my case it is definitely Axis that causes the classloader logging problem, and th eonly way I can make it go away is to hack the jcl104-over-slf4j jar file to change the LogFactory config file to point back to good old LogFactoryImpl.
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

Dave Syer
In reply to this post by jan_bartel

> Have a look at the plugin how-to page here:
> http://jetty.mortbay.org/jetty6/maven-plugin/howto.html

That only helped when I also *removed* the commons-logging and log4j jar dependencies from my war.  Interesting to know, but I don't really want to have to do that - it's only jetty that forces me to do this, and jetty isn't our production platform (I'm just using it for testing).

Also I get way more logging than I want, once the app starts up because slf4j ignores my log4j.properties.  I just want to switch it off, but I can't.  Anyone else have anything to offer here?
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

jan_bartel
Dave,

Sorry for the tardy response, but believe me I've been
thinking about your issue.

The commons logging discovery mechanism is a big problem.

I don't want to take slf4j out of the
plugin dependencies, because this would mean that the
plugin would not work out-of-the-box.

However, having it in there means that webapps that include
jars which use the discovery mechanism put a big spanner
in the works.

One other thing you could maybe try. Can you try putting an
<exclusion> for commons-logging in the <dependencies>
for the jetty plugin. That way, you can (hopefully) run as slf4j
under the plugin, put still have your commons-logging jar
generated inside your webapp. Note that slf4j-simple will only
log INFO level and above.

I frankly can't see any way of making anything work with the
commons discovery mechanism, other than to check in all of
the jasper-2.0 code and remove the use of commons-logging
altogether (which is kinda what glassfish did for jsp-2.1).

regards
Jan





Dave Syer wrote:

>
>>Have a look at the plugin how-to page here:
>>http://jetty.mortbay.org/jetty6/maven-plugin/howto.html
>
>
> That only helped when I also *removed* the commons-logging and log4j jar
> dependencies from my war.  Interesting to know, but I don't really want to
> have to do that - it's only jetty that forces me to do this, and jetty isn't
> our production platform (I'm just using it for testing).
>
> Also I get way more logging than I want, once the app starts up because
> slf4j ignores my log4j.properties.  I just want to switch it off, but I
> can't.  Anyone else have anything to offer here?


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

Dave Syer
> The commons logging discovery mechanism is a big problem.

So I can see...

> Can you try putting an
> <exclusion> for commons-logging in the <dependencies> 
> for the jetty plugin.

I thought of that, but I don't think maven supports exlcusions in plugin dependencies.  You can put them in project dependencies, but not (according to the schema) in plugin dependencies.  That's why I am forced to exlcude them at  the project level (which is no good for a production system).

> Note that slf4j-simple will only
> log INFO level and above.

Is this hard-coded somewhere?  It is really not convenient - INFO logging in my project is extremely verbose.  I need to make WARN the default and override special cases.
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

jan_bartel
Dave,

Dave Syer wrote:

>>The commons logging discovery mechanism is a big problem.
>
>
> So I can see...
>
>
>>Can you try putting an
>><exclusion> for commons-logging in the <dependencies>
>>for the jetty plugin.
>
>
> I thought of that, but I don't think maven supports exlcusions in plugin
> dependencies.  You can put them in project dependencies, but not (according
> to the schema) in plugin dependencies.  That's why I am forced to exlcude
> them at  the project level (which is no good for a production system).
Hhhmm, I will ping the maven guys again.


>>Note that slf4j-simple will only
>>log INFO level and above.
>
>
> Is this hard-coded somewhere?  It is really not convenient - INFO logging in
> my project is extremely verbose.  I need to make WARN the default and
> override special cases.

slf4j-simple is hardcoded to only put out INFO level messages and it is not
configurable (that's why is called "simple" I guess ;-)). With jetty standalone,
you can swap in different slf4j impls by copying them into $jetty.home/lib/jsp2.0.
The idea was supposed to be the same for the plugin, however, the exclusion
mechanism does not appear to be working, so it looks like for now it is not
replaceable. I will talk to the maven guys and see what they have to say.

cheers
Jan

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

jan_bartel
First, let me say that the following ONLY APPLIES TO JDK1.4 USERS.

Do NOT use this solution with jdk1.5, just be happy that you are using
a jsp2.1 implementation that is free of logging hassles! :-)

It's been a titanic struggle, but I believe we now have a solution that
will allow you to use commons logging with the jetty container with the
plugin.

The solution is currently checked in to svn (rev  815) so please try
and let me know the results. Note that you should be able to leave
your commons-logging and log4j jars as dependencies for your webapp.

To use this solution you need to:

1. Add slf4j-jcl, commons-logging and log4j as dependencies to your
   <plugin> declaration. Here's an example:

      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.0-SNAPSHOT</version>
        <configuration>
          <scanIntervalSeconds>5</scanIntervalSeconds>
        </configuration>
       <dependencies>
        <dependency>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
          <version>1.1</version>
          <type>jar</type>
        </dependency>
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-jcl</artifactId>
          <version>1.0.1</version>
          <type>jar</type>
        </dependency>
        <dependency>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
          <version>1.2.13</version>
          <type>jar</type>
        </dependency>
       </dependencies>
      </plugin>


2. run the plugin like so (assuming you have a src/main/resources/log4j.properties file):

   mvn -Dslf4j=false -Dlog4j.configuration=file:./target/classes/log4j.properties jetty:run

Let me re-iterate: DO NOT use -Dslf4j=false WITH JDK1.5 - you don't need it and you don't want it!

If I hear that this solution is working, then I'll update the wiki info accordingly.

regards
Jan

Jan Bartel wrote:

> Dave,
>
> Dave Syer wrote:
>
>>>The commons logging discovery mechanism is a big problem.
>>
>>
>>So I can see...
>>
>>
>>
>>>Can you try putting an
>>><exclusion> for commons-logging in the <dependencies>
>>>for the jetty plugin.
>>
>>
>>I thought of that, but I don't think maven supports exlcusions in plugin
>>dependencies.  You can put them in project dependencies, but not (according
>>to the schema) in plugin dependencies.  That's why I am forced to exlcude
>>them at  the project level (which is no good for a production system).
>
> Hhhmm, I will ping the maven guys again.
>
>
>
>>>Note that slf4j-simple will only
>>>log INFO level and above.
>>
>>
>>Is this hard-coded somewhere?  It is really not convenient - INFO logging in
>>my project is extremely verbose.  I need to make WARN the default and
>>override special cases.
>
>
> slf4j-simple is hardcoded to only put out INFO level messages and it is not
> configurable (that's why is called "simple" I guess ;-)). With jetty standalone,
> you can swap in different slf4j impls by copying them into $jetty.home/lib/jsp2.0.
> The idea was supposed to be the same for the plugin, however, the exclusion
> mechanism does not appear to be working, so it looks like for now it is not
> replaceable. I will talk to the maven guys and see what they have to say.
>
> cheers
> Jan
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

Dave Syer
> It's been a titanic struggle, but I believe we now have a solution that
> will allow you to use commons logging with the jetty container with the
> plugin.

Thanks, it almost worked for me.  My web app context initialised OK, with the normal amount of logging I epect from my own log4j.properties.  But then I got a fat exception from jetty (as it was initialising jsp?), saying "You have more than one version of 'org.apache.commons.logging.Log' visible".

So I took the commons-logging and log4j dependencies out of the jetty plugin configuration in my pom.  And now it all looks fine until the same point where I get a StackOverflowException.  No stack trace (and mvn -e didn't reveal anything additional).
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

Dave Syer
Here are the mvn outputs after the context has initialised (with the file system path to project replaced by me in this post), in case it helps...
:WARN:  failed jsp
:WARN:  failed ContextHandler@8f2ca6{/opvantage,file://src/main/webapp/}
:WARN:  failed ContextHandlerCollection@1746634
:WARN:  failed HandlerCollection@e1fa50
:INFO:  Started SelectChannelConnector @ 0.0.0.0:8080
:WARN:  failed Server@1b8fdf2
[INFO] :INFO:  Shutdown hook executing
:INFO:  Shutdown hook complete
Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.StackOverflowError
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 50 seconds
[INFO] Finished at: Sat Aug 26 09:44:01 BST 2006
[INFO] Final Memory: 49M/63M
[INFO] ------------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

jan_bartel
Can you post your pom.xml and a run of the plugin with -X flag?

regards
Jan

Dave Syer wrote:

> Here are the mvn outputs after the context has initialised (with the
> file system path to project replaced by me in this post), in case it
> helps...
>
> :WARN:  failed jsp
> :WARN:  failed ContextHandler@8f2ca6{/opvantage,file://src/main/webapp/}
> :WARN:  failed ContextHandlerCollection@1746634
> :WARN:  failed HandlerCollection@e1fa50
> :INFO:  Started SelectChannelConnector @ 0.0.0.0:8080
> :WARN:  failed Server@1b8fdf2
> [INFO] :INFO:  Shutdown hook executing
> :INFO:  Shutdown hook complete
> Jetty server exiting.
> [INFO] ------------------------------------------------------------------------
> [ERROR] FATAL ERROR
> [INFO] ------------------------------------------------------------------------
> [INFO] null
> [INFO] ------------------------------------------------------------------------
> [INFO] Trace
> java.lang.StackOverflowError
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 50 seconds
> [INFO] Finished at: Sat Aug 26 09:44:01 BST 2006
> [INFO] Final Memory: 49M/63M
> [INFO] ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
> View this message in context: Re: maven plugin, excluding slf4j
> dependency
> <http://www.nabble.com/maven-plugin%2C-excluding-slf4j-dependency-tf1939206.html#a5995878>
> Sent from the Jetty Discuss
> <http://www.nabble.com/Jetty-Discuss-f60.html> forum at Nabble.com.
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> jetty-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-discuss


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

Dave Syer
> Can you post your pom.xml and a run of the plugin with -X flag?

The pom is massive, so I'll only include an excerpt:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <packaging>war</packaging>
[...group and artifactid, plus parent project...]

  <dependencies>
[... many dependencies, including one that itself depends on commons-logging and log4j]
  </dependencies>

<pluginRepositories>
    <pluginRepository>
      <id>mortbay-repo</id>
      <name>mortbay-repo</name>
      <url>http://www.mortbay.org/maven2/snapshot</url>
    </pluginRepository>
  </pluginRepositories>

        <build>
                <finalName>context</finalName>

               
                <plugins>
                        <plugin>
                                <groupId>org.mortbay.jetty</groupId>
                                <artifactId>maven-jetty-plugin</artifactId>
                                <version>6.0-SNAPSHOT</version>
                                <configuration>
                                        <contextPath>${project.build.finalName}</contextPath>
                    <slf4j>false</slf4j>
                                </configuration>
                                <dependencies>
                    <dependency>
                      <groupId>org.slf4j</groupId>
                      <artifactId>slf4j-jcl</artifactId>
                      <version>1.0.1</version>
                    </dependency>
                                </dependencies>
                        </plugin>
                        </plugin>
                </plugins>
        </build>

</project>

I'll send you the log file in an e-mail...
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

jan_bartel
Dave,

Instead of <slf4j>false</slf4j> in the pom.xml you need to use
-Dslf4j=false on the command line. Otherwise, you will wind up
with 2 copies of commons-logging: your own and the one from
slf4j-jcl, which appears to be the explanation for your problem.

cheers
Jan


Dave Syer wrote:

>>Can you post your pom.xml and a run of the plugin with -X flag?
>
>
> The pom is massive, so I'll only include an excerpt:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
>
>   <modelVersion>4.0.0</modelVersion>
>   <packaging>war</packaging>
> [...group and artifactid, plus parent project...]
>
>   <dependencies>
> [... many dependencies, including one that itself depends on commons-logging
> and log4j]
>   </dependencies>
>
> <pluginRepositories>
>     <pluginRepository>
>       <id>mortbay-repo</id>
>       <name>mortbay-repo</name>
>       <url>http://www.mortbay.org/maven2/snapshot</url>
>     </pluginRepository>
>   </pluginRepositories>
>
> <build>
> <finalName>context</finalName>
>
> <!-- Allow us to test the app quickly with $ mvn jetty:run -->
> <plugins>
> <plugin>
> <groupId>org.mortbay.jetty</groupId>
> <artifactId>maven-jetty-plugin</artifactId>
> <version>6.0-SNAPSHOT</version>
> <configuration>
> <contextPath>${project.build.finalName}</contextPath>
>                     <slf4j>false</slf4j>
> </configuration>
> <dependencies>
>                     <dependency>
>                       <groupId>org.slf4j</groupId>
>                       <artifactId>slf4j-jcl</artifactId>
>                       <version>1.0.1</version>
>                     </dependency>
> </dependencies>
> </plugin>
> </plugin>
> </plugins>
> </build>
>
> </project>
>
> I'll send you the log file in an e-mail...
>


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: maven plugin, excluding slf4j dependency

Dave Syer
> Instead of <slf4j>false</slf4j> in the pom.xml you need to use
> -Dslf4j=false on the command line.

Thanks.  Tried it, and it made no difference (still getting StackOverflowError from jetty, after app has initialised).  Also tried moving the commons-logging dependency out of the web app and into the plugin, and that gave the same result.