You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Russell Brown <Ru...@ioko.com> on 2008/09/25 17:43:22 UTC

T5: 5.0.14 Bizarre ClassNotFoundException

Hi,
Not sure if this is totally a T5 issue but I am just seeing if anyone has seen this. I have a page that uses the Form component but when I call the page I get a ClassNotFoundException for org.slf4j.Logger. Now I know that the class is on the classpath as I have Struts app running in the same container and Calling Class.forName("org.slf4j.Logger", true, this.getClass().getClassLoader()) in a struts action yields a class but the toClass method in org.apache.tapestry5.internal.services.InternalClassTransformationImpl throws a ClassNotFoundException.

If I change the code in that class to use the parent of the parent class loader then the class is found.

Any ideas? Is this a bug, is there some way to make Tapestry's class loader aware of the Class?

Cheers

Russell

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: T5: 5.0.14 Bizarre ClassNotFoundException

Posted by Russell Brown <Ru...@ioko.com>.
Thanks. I think that is the second time you have told me.

I'll remember this time, I'm sure.

Cheers

Russell


-----Original Message-----
From: Ben Gidley [mailto:ben@gidley.co.uk]
Sent: Fri 9/26/2008 8:03 AM
To: Tapestry users
Subject: Re: T5: 5.0.14 Bizarre ClassNotFoundException
 
Russell,
Are you using a main class to start your app?

If so  you need the line

 // Remove slf4j from list of classes not exposed to webapp
                webapp.setServerClasses(new String[]
{"-org.mortbay.jetty.plus.jaas.", "org.mortbay.jetty."});


In your class - see http://wiki.apache.org/tapestry/Tapestry5RunViaMain.

The reason is Jetty thinks slf4j is a 'server' class and in line with
the J2EE specification is stops it 'leaking' into web application
classloaders. This line tells it to let it through.

THis only effects T5 pages/components when you are using the
runViaMain method. It won't effect your non T5 classes as they are
loaded in the system classloader. Whereas the enhanced T5
pages/components load in the web class loader.

Thanks

Ben


On Thu, Sep 25, 2008 at 5:05 PM, Russell Brown <Ru...@ioko.com> wrote:
>
> Hi Toby,
> Thanks for that. I have suspicion I have a maven nightmare on my hands. I have used maven's "exlusion" to exclude SLF4j from being included by Tapestry as we want to control the version. I can see that the Pages and Components use a different class loader, I guess they have to for all that run time transformation that is going on but they _should_ be able to load classes that their parents can in my humble opinion.
>
> I've just had a double, triple check and there is only one SLF4j jar on the classpath, the one I intended to have there. The one that my Struts actions can access.
>
> I'll keep digging for now. Thanks for the help, it does confirm that my main problem is probably maven/dependancy based but exacerbated by Tapestry's class loading.
>
> Cheers
>
> Russell
>
>
> -----Original Message-----
> From: Toby Hobson [mailto:toby.hobson@googlemail.com]
> Sent: Thu 9/25/2008 5:00 PM
> To: Tapestry users
> Subject: Re: T5: 5.0.14 Bizarre ClassNotFoundException
>
> Hi Russel,
>
> Just a thought but it might be worth checking your classpath. T5 will pull
> SLF4 into the classpath anyway so you could have included it twice. Because
> T5 uses a separate classloader for Pages and Components it may be getting
> confused. I've run into similar problems before.
>
> Cheers
>
> Toby
>
> 2008/9/25 Russell Brown <Ru...@ioko.com>
>
> > Hi,
> > Not sure if this is totally a T5 issue but I am just seeing if anyone has
> > seen this. I have a page that uses the Form component but when I call the
> > page I get a ClassNotFoundException for org.slf4j.Logger. Now I know that
> > the class is on the classpath as I have Struts app running in the same
> > container and Calling Class.forName("org.slf4j.Logger", true,
> > this.getClass().getClassLoader()) in a struts action yields a class but the
> > toClass method in
> > org.apache.tapestry5.internal.services.InternalClassTransformationImpl
> > throws a ClassNotFoundException.
> >
> > If I change the code in that class to use the parent of the parent class
> > loader then the class is found.
> >
> > Any ideas? Is this a bug, is there some way to make Tapestry's class loader
> > aware of the Class?
> >
> > Cheers
> >
> > Russell
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org




Re: T5: 5.0.14 Bizarre ClassNotFoundException

Posted by Ben Gidley <be...@gidley.co.uk>.
Russell,
Are you using a main class to start your app?

If so  you need the line

 // Remove slf4j from list of classes not exposed to webapp
                webapp.setServerClasses(new String[]
{"-org.mortbay.jetty.plus.jaas.", "org.mortbay.jetty."});


In your class - see http://wiki.apache.org/tapestry/Tapestry5RunViaMain.

The reason is Jetty thinks slf4j is a 'server' class and in line with
the J2EE specification is stops it 'leaking' into web application
classloaders. This line tells it to let it through.

THis only effects T5 pages/components when you are using the
runViaMain method. It won't effect your non T5 classes as they are
loaded in the system classloader. Whereas the enhanced T5
pages/components load in the web class loader.

Thanks

Ben


On Thu, Sep 25, 2008 at 5:05 PM, Russell Brown <Ru...@ioko.com> wrote:
>
> Hi Toby,
> Thanks for that. I have suspicion I have a maven nightmare on my hands. I have used maven's "exlusion" to exclude SLF4j from being included by Tapestry as we want to control the version. I can see that the Pages and Components use a different class loader, I guess they have to for all that run time transformation that is going on but they _should_ be able to load classes that their parents can in my humble opinion.
>
> I've just had a double, triple check and there is only one SLF4j jar on the classpath, the one I intended to have there. The one that my Struts actions can access.
>
> I'll keep digging for now. Thanks for the help, it does confirm that my main problem is probably maven/dependancy based but exacerbated by Tapestry's class loading.
>
> Cheers
>
> Russell
>
>
> -----Original Message-----
> From: Toby Hobson [mailto:toby.hobson@googlemail.com]
> Sent: Thu 9/25/2008 5:00 PM
> To: Tapestry users
> Subject: Re: T5: 5.0.14 Bizarre ClassNotFoundException
>
> Hi Russel,
>
> Just a thought but it might be worth checking your classpath. T5 will pull
> SLF4 into the classpath anyway so you could have included it twice. Because
> T5 uses a separate classloader for Pages and Components it may be getting
> confused. I've run into similar problems before.
>
> Cheers
>
> Toby
>
> 2008/9/25 Russell Brown <Ru...@ioko.com>
>
> > Hi,
> > Not sure if this is totally a T5 issue but I am just seeing if anyone has
> > seen this. I have a page that uses the Form component but when I call the
> > page I get a ClassNotFoundException for org.slf4j.Logger. Now I know that
> > the class is on the classpath as I have Struts app running in the same
> > container and Calling Class.forName("org.slf4j.Logger", true,
> > this.getClass().getClassLoader()) in a struts action yields a class but the
> > toClass method in
> > org.apache.tapestry5.internal.services.InternalClassTransformationImpl
> > throws a ClassNotFoundException.
> >
> > If I change the code in that class to use the parent of the parent class
> > loader then the class is found.
> >
> > Any ideas? Is this a bug, is there some way to make Tapestry's class loader
> > aware of the Class?
> >
> > Cheers
> >
> > Russell
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: T5: 5.0.14 Bizarre ClassNotFoundException

Posted by Russell Brown <Ru...@ioko.com>.
Hi Toby,
Thanks for that. I have suspicion I have a maven nightmare on my hands. I have used maven's "exlusion" to exclude SLF4j from being included by Tapestry as we want to control the version. I can see that the Pages and Components use a different class loader, I guess they have to for all that run time transformation that is going on but they _should_ be able to load classes that their parents can in my humble opinion.

I've just had a double, triple check and there is only one SLF4j jar on the classpath, the one I intended to have there. The one that my Struts actions can access.

I'll keep digging for now. Thanks for the help, it does confirm that my main problem is probably maven/dependancy based but exacerbated by Tapestry's class loading.

Cheers

Russell


-----Original Message-----
From: Toby Hobson [mailto:toby.hobson@googlemail.com]
Sent: Thu 9/25/2008 5:00 PM
To: Tapestry users
Subject: Re: T5: 5.0.14 Bizarre ClassNotFoundException
 
Hi Russel,

Just a thought but it might be worth checking your classpath. T5 will pull
SLF4 into the classpath anyway so you could have included it twice. Because
T5 uses a separate classloader for Pages and Components it may be getting
confused. I've run into similar problems before.

Cheers

Toby

2008/9/25 Russell Brown <Ru...@ioko.com>

> Hi,
> Not sure if this is totally a T5 issue but I am just seeing if anyone has
> seen this. I have a page that uses the Form component but when I call the
> page I get a ClassNotFoundException for org.slf4j.Logger. Now I know that
> the class is on the classpath as I have Struts app running in the same
> container and Calling Class.forName("org.slf4j.Logger", true,
> this.getClass().getClassLoader()) in a struts action yields a class but the
> toClass method in
> org.apache.tapestry5.internal.services.InternalClassTransformationImpl
> throws a ClassNotFoundException.
>
> If I change the code in that class to use the parent of the parent class
> loader then the class is found.
>
> Any ideas? Is this a bug, is there some way to make Tapestry's class loader
> aware of the Class?
>
> Cheers
>
> Russell
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



Re: T5: 5.0.14 Bizarre ClassNotFoundException

Posted by Toby Hobson <to...@googlemail.com>.
Hi Russel,

Just a thought but it might be worth checking your classpath. T5 will pull
SLF4 into the classpath anyway so you could have included it twice. Because
T5 uses a separate classloader for Pages and Components it may be getting
confused. I've run into similar problems before.

Cheers

Toby

2008/9/25 Russell Brown <Ru...@ioko.com>

> Hi,
> Not sure if this is totally a T5 issue but I am just seeing if anyone has
> seen this. I have a page that uses the Form component but when I call the
> page I get a ClassNotFoundException for org.slf4j.Logger. Now I know that
> the class is on the classpath as I have Struts app running in the same
> container and Calling Class.forName("org.slf4j.Logger", true,
> this.getClass().getClassLoader()) in a struts action yields a class but the
> toClass method in
> org.apache.tapestry5.internal.services.InternalClassTransformationImpl
> throws a ClassNotFoundException.
>
> If I change the code in that class to use the parent of the parent class
> loader then the class is found.
>
> Any ideas? Is this a bug, is there some way to make Tapestry's class loader
> aware of the Class?
>
> Cheers
>
> Russell
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>