You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Kevin Jones <ke...@develop.com> on 2000/03/16 12:38:51 UTC

Cocoon producers and Tomcat

if I'm using Cocoon from within Tomcat (the latest 3.1 build). If I add a
producer to the cocoon.properties file I get the following

java.lang.RuntimeException: Error creating
kevinj.develop.util.WeatherProducer: class is not found

I've put the class (package and all) under WEB-INF/classes, so the question
is, where does Cocoon expect to find the producer class (or am I missing
something else?) ?

Kevin Jones
DevelopMentor
www.develop.com



Re: Cocoon producers and Tomcat

Posted by Stefano Mazzocchi <st...@apache.org>.
Darryl Stoflet wrote:
> 
> Stephano,

Stefano, please
 
>         I sent in a report to bugzilla that I thought addressed this and
> offered a remedy. If cocoon is in the classpath (as it is in the
> howto installation guides) it will be loaded by the system class
> loader, which knows nothing about the web-inf/classes or web-inf/lib
> directories. Thus when cocoon trys to load classes or any resource not
> in the system classpath it will fail, as the example below does
> when a producer is placed in the web-inf/classes directory.
> The 2 solutions are to either place all resources and classes in the
> system classpath including cocoon, or put cocoon in a web-inf directory
> and then it will be able to see the resources and classes in that
> contexts web-inf/classes and web-inf/lib directory as well as the system
> classpath. If you opt to enable placing cocoon in web-inf/classes
> you must also refrain from the usage of ClassLoader.getSystemResource()
> as it will use the system classloader. Instead use
> getClass().getClassLoader().getResource.

Already patched this but it doesn't work. I suspect a bug in the
JServ/Tomcat classloader implementation even if this seems very strange.

I'll play around more with it today.
 
> /Darryl Stoflet
> 
> Stefano Mazzocchi wrote:
> >
> > Kevin Jones wrote:
> > >
> > > if I'm using Cocoon from within Tomcat (the latest 3.1 build). If I add a
> > > producer to the cocoon.properties file I get the following
> > >
> > > java.lang.RuntimeException: Error creating
> > > kevinj.develop.util.WeatherProducer: class is not found
> > >
> > > I've put the class (package and all) under WEB-INF/classes, so the question
> > > is, where does Cocoon expect to find the producer class (or am I missing
> > > something else?) ?
> >
> > I am currently trying to address the classloading/resourceloading
> > problems in Cocoon 1.7.1-dev to make it possible to use it in Tomcat or
> > under a specific jserv servlet zone.
> >
> > The problem is that classloader behavior is a real pain in the ass,
> > expecially between 1.1 and 1.2 java versions.
> >
> > But today I'll install tomcat 3.1b and see what happens.
> >
> > --
> > Stefano Mazzocchi      One must still have chaos in oneself to be
> >                           able to give birth to a dancing star.
> > <st...@apache.org>                             Friedrich Nietzsche
> > --------------------------------------------------------------------
> >  Come to the first official Apache Software Foundation Conference!
> > ------------------------- http://ApacheCon.Com ---------------------
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 
> --
> Darryl Stoflet
> http://dstoflet.calweb.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



RE: Cocoon producers and Tomcat

Posted by Kevin Jones <ke...@develop.com>.
I was one of the people who posted the fix for the Tomcat web-inf/lib bug
about two weeks ago so I know all about that :-) The version of Tomcat I'm
using is the overnight March 16th build (which that fix should be in), and I
can't get Cocoon loaded from the lib directory!

I'll check my versions and try it again!

Kevin Jones
DevelopMentor
www.develop.com

> -----Original Message-----
> From: Darryl Stoflet [mailto:dstoflet@calweb.com]
> Sent: 17 March 2000 13:16
> To: cocoon-users@xml.apache.org
> Subject: Re: Cocoon producers and Tomcat
>
>
> Kevin,
>
> 	Tomcat -had- a bug where it wouldn't load jars from the
> web-inf/lib directory so unless you want to rebuild from the latest source
> you should not place jars there. Initially, I had placed an unjarred
> cocoon in my contexts web-inf/classes but this will fail because
> cocoon uses ClassLoader.getSystemResource() which will try to load
> resources from the system classpath (which web-inf/classes is not
> a part of). So the only solution to your problem at this time is
> to place cocoon and your producer in the classpath. However be aware
> that since your producer will be loaded by the system classloader
> you should not attempt to load resources using any of the classloader
> getResourceXXX variants unless you place that resource on the classpath.
> Instead, to refer to resources (relative to your context) you will
> need to build a path as the ProducerFromFile/Utils does e.g.,
> URL resource = ((ServletContext)
> context).getResource(request.getServletPath());
>
> /Darryl Stoflet
>
> Kevin Jones wrote:
> >
> > OK I understand that, but if I put cocoon in the WEB-INF/lib
> directory it
> > doesn't get loaded, so do I expand the jar into
> WEB-INF/classes, or can I
> > put Cocoon into the tomcat\lib directory (I'm guessing that the
> answer to
> > the second part is no),
> >
> > Kevin Jones
> > DevelopMentor
> > www.develop.com
> >
> > > -----Original Message-----
> > > From: Darryl Stoflet [mailto:dstoflet@calweb.com]
> > > Sent: 17 March 2000 00:18
> > > To: cocoon-users@xml.apache.org
> > > Subject: Re: Cocoon producers and Tomcat
> > >
> > >
> > > Stephano,
> > >
> > >       I sent in a report to bugzilla that I thought addressed this and
> > > offered a remedy. If cocoon is in the classpath (as it is in the
> > > howto installation guides) it will be loaded by the system class
> > > loader, which knows nothing about the web-inf/classes or web-inf/lib
> > > directories. Thus when cocoon trys to load classes or any resource not
> > > in the system classpath it will fail, as the example below does
> > > when a producer is placed in the web-inf/classes directory.
> > > The 2 solutions are to either place all resources and classes in the
> > > system classpath including cocoon, or put cocoon in a web-inf
> directory
> > > and then it will be able to see the resources and classes in that
> > > contexts web-inf/classes and web-inf/lib directory as well as
> the system
> > > classpath. If you opt to enable placing cocoon in web-inf/classes
> > > you must also refrain from the usage of
> ClassLoader.getSystemResource()
> > > as it will use the system classloader. Instead use
> > > getClass().getClassLoader().getResource.
> > >
> > > /Darryl Stoflet
> > >
> > >
> > >
> > > Stefano Mazzocchi wrote:
> > > >
> > > > Kevin Jones wrote:
> > > > >
> > > > > if I'm using Cocoon from within Tomcat (the latest 3.1
> > > build). If I add a
> > > > > producer to the cocoon.properties file I get the following
> > > > >
> > > > > java.lang.RuntimeException: Error creating
> > > > > kevinj.develop.util.WeatherProducer: class is not found
> > > > >
> > > > > I've put the class (package and all) under WEB-INF/classes,
> > > so the question
> > > > > is, where does Cocoon expect to find the producer class (or
> > > am I missing
> > > > > something else?) ?
> > > >
> > > > I am currently trying to address the classloading/resourceloading
> > > > problems in Cocoon 1.7.1-dev to make it possible to use it
> in Tomcat or
> > > > under a specific jserv servlet zone.
> > > >
> > > > The problem is that classloader behavior is a real pain in the ass,
> > > > expecially between 1.1 and 1.2 java versions.
> > > >
> > > > But today I'll install tomcat 3.1b and see what happens.
> > > >
> > > > --
> > > > Stefano Mazzocchi      One must still have chaos in oneself to be
> > > >                           able to give birth to a dancing star.
> > > > <st...@apache.org>                             Friedrich Nietzsche
> > > > --------------------------------------------------------------------
> > > >  Come to the first official Apache Software Foundation Conference!
> > > > ------------------------- http://ApacheCon.Com ---------------------
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > > > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> > >
> > > --
> > > Darryl Stoflet
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Cocoon producers and Tomcat

Posted by Darryl Stoflet <ds...@calweb.com>.
Kevin,

	Tomcat -had- a bug where it wouldn't load jars from the 
web-inf/lib directory so unless you want to rebuild from the latest source
you should not place jars there. Initially, I had placed an unjarred
cocoon in my contexts web-inf/classes but this will fail because 
cocoon uses ClassLoader.getSystemResource() which will try to load
resources from the system classpath (which web-inf/classes is not
a part of). So the only solution to your problem at this time is
to place cocoon and your producer in the classpath. However be aware 
that since your producer will be loaded by the system classloader
you should not attempt to load resources using any of the classloader
getResourceXXX variants unless you place that resource on the classpath.
Instead, to refer to resources (relative to your context) you will
need to build a path as the ProducerFromFile/Utils does e.g.,
URL resource = ((ServletContext) context).getResource(request.getServletPath());

/Darryl Stoflet

Kevin Jones wrote:
> 
> OK I understand that, but if I put cocoon in the WEB-INF/lib directory it
> doesn't get loaded, so do I expand the jar into WEB-INF/classes, or can I
> put Cocoon into the tomcat\lib directory (I'm guessing that the answer to
> the second part is no),
> 
> Kevin Jones
> DevelopMentor
> www.develop.com
> 
> > -----Original Message-----
> > From: Darryl Stoflet [mailto:dstoflet@calweb.com]
> > Sent: 17 March 2000 00:18
> > To: cocoon-users@xml.apache.org
> > Subject: Re: Cocoon producers and Tomcat
> >
> >
> > Stephano,
> >
> >       I sent in a report to bugzilla that I thought addressed this and
> > offered a remedy. If cocoon is in the classpath (as it is in the
> > howto installation guides) it will be loaded by the system class
> > loader, which knows nothing about the web-inf/classes or web-inf/lib
> > directories. Thus when cocoon trys to load classes or any resource not
> > in the system classpath it will fail, as the example below does
> > when a producer is placed in the web-inf/classes directory.
> > The 2 solutions are to either place all resources and classes in the
> > system classpath including cocoon, or put cocoon in a web-inf directory
> > and then it will be able to see the resources and classes in that
> > contexts web-inf/classes and web-inf/lib directory as well as the system
> > classpath. If you opt to enable placing cocoon in web-inf/classes
> > you must also refrain from the usage of ClassLoader.getSystemResource()
> > as it will use the system classloader. Instead use
> > getClass().getClassLoader().getResource.
> >
> > /Darryl Stoflet
> >
> >
> >
> > Stefano Mazzocchi wrote:
> > >
> > > Kevin Jones wrote:
> > > >
> > > > if I'm using Cocoon from within Tomcat (the latest 3.1
> > build). If I add a
> > > > producer to the cocoon.properties file I get the following
> > > >
> > > > java.lang.RuntimeException: Error creating
> > > > kevinj.develop.util.WeatherProducer: class is not found
> > > >
> > > > I've put the class (package and all) under WEB-INF/classes,
> > so the question
> > > > is, where does Cocoon expect to find the producer class (or
> > am I missing
> > > > something else?) ?
> > >
> > > I am currently trying to address the classloading/resourceloading
> > > problems in Cocoon 1.7.1-dev to make it possible to use it in Tomcat or
> > > under a specific jserv servlet zone.
> > >
> > > The problem is that classloader behavior is a real pain in the ass,
> > > expecially between 1.1 and 1.2 java versions.
> > >
> > > But today I'll install tomcat 3.1b and see what happens.
> > >
> > > --
> > > Stefano Mazzocchi      One must still have chaos in oneself to be
> > >                           able to give birth to a dancing star.
> > > <st...@apache.org>                             Friedrich Nietzsche
> > > --------------------------------------------------------------------
> > >  Come to the first official Apache Software Foundation Conference!
> > > ------------------------- http://ApacheCon.Com ---------------------
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
> > --
> > Darryl Stoflet
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

RE: Cocoon producers and Tomcat

Posted by Kevin Jones <ke...@develop.com>.
OK I understand that, but if I put cocoon in the WEB-INF/lib directory it
doesn't get loaded, so do I expand the jar into WEB-INF/classes, or can I
put Cocoon into the tomcat\lib directory (I'm guessing that the answer to
the second part is no),

Kevin Jones
DevelopMentor
www.develop.com

> -----Original Message-----
> From: Darryl Stoflet [mailto:dstoflet@calweb.com]
> Sent: 17 March 2000 00:18
> To: cocoon-users@xml.apache.org
> Subject: Re: Cocoon producers and Tomcat
>
>
> Stephano,
>
> 	I sent in a report to bugzilla that I thought addressed this and
> offered a remedy. If cocoon is in the classpath (as it is in the
> howto installation guides) it will be loaded by the system class
> loader, which knows nothing about the web-inf/classes or web-inf/lib
> directories. Thus when cocoon trys to load classes or any resource not
> in the system classpath it will fail, as the example below does
> when a producer is placed in the web-inf/classes directory.
> The 2 solutions are to either place all resources and classes in the
> system classpath including cocoon, or put cocoon in a web-inf directory
> and then it will be able to see the resources and classes in that
> contexts web-inf/classes and web-inf/lib directory as well as the system
> classpath. If you opt to enable placing cocoon in web-inf/classes
> you must also refrain from the usage of ClassLoader.getSystemResource()
> as it will use the system classloader. Instead use
> getClass().getClassLoader().getResource.
>
> /Darryl Stoflet
>
>
>
> Stefano Mazzocchi wrote:
> >
> > Kevin Jones wrote:
> > >
> > > if I'm using Cocoon from within Tomcat (the latest 3.1
> build). If I add a
> > > producer to the cocoon.properties file I get the following
> > >
> > > java.lang.RuntimeException: Error creating
> > > kevinj.develop.util.WeatherProducer: class is not found
> > >
> > > I've put the class (package and all) under WEB-INF/classes,
> so the question
> > > is, where does Cocoon expect to find the producer class (or
> am I missing
> > > something else?) ?
> >
> > I am currently trying to address the classloading/resourceloading
> > problems in Cocoon 1.7.1-dev to make it possible to use it in Tomcat or
> > under a specific jserv servlet zone.
> >
> > The problem is that classloader behavior is a real pain in the ass,
> > expecially between 1.1 and 1.2 java versions.
> >
> > But today I'll install tomcat 3.1b and see what happens.
> >
> > --
> > Stefano Mazzocchi      One must still have chaos in oneself to be
> >                           able to give birth to a dancing star.
> > <st...@apache.org>                             Friedrich Nietzsche
> > --------------------------------------------------------------------
> >  Come to the first official Apache Software Foundation Conference!
> > ------------------------- http://ApacheCon.Com ---------------------
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
> --
> Darryl Stoflet
> http://dstoflet.calweb.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Cocoon producers and Tomcat

Posted by Darryl Stoflet <ds...@calweb.com>.
Stephano,

	I sent in a report to bugzilla that I thought addressed this and
offered a remedy. If cocoon is in the classpath (as it is in the
howto installation guides) it will be loaded by the system class
loader, which knows nothing about the web-inf/classes or web-inf/lib
directories. Thus when cocoon trys to load classes or any resource not
in the system classpath it will fail, as the example below does
when a producer is placed in the web-inf/classes directory. 
The 2 solutions are to either place all resources and classes in the
system classpath including cocoon, or put cocoon in a web-inf directory
and then it will be able to see the resources and classes in that 
contexts web-inf/classes and web-inf/lib directory as well as the system
classpath. If you opt to enable placing cocoon in web-inf/classes
you must also refrain from the usage of ClassLoader.getSystemResource()
as it will use the system classloader. Instead use
getClass().getClassLoader().getResource.

/Darryl Stoflet



Stefano Mazzocchi wrote:
> 
> Kevin Jones wrote:
> >
> > if I'm using Cocoon from within Tomcat (the latest 3.1 build). If I add a
> > producer to the cocoon.properties file I get the following
> >
> > java.lang.RuntimeException: Error creating
> > kevinj.develop.util.WeatherProducer: class is not found
> >
> > I've put the class (package and all) under WEB-INF/classes, so the question
> > is, where does Cocoon expect to find the producer class (or am I missing
> > something else?) ?
> 
> I am currently trying to address the classloading/resourceloading
> problems in Cocoon 1.7.1-dev to make it possible to use it in Tomcat or
> under a specific jserv servlet zone.
> 
> The problem is that classloader behavior is a real pain in the ass,
> expecially between 1.1 and 1.2 java versions.
> 
> But today I'll install tomcat 3.1b and see what happens.
> 
> --
> Stefano Mazzocchi      One must still have chaos in oneself to be
>                           able to give birth to a dancing star.
> <st...@apache.org>                             Friedrich Nietzsche
> --------------------------------------------------------------------
>  Come to the first official Apache Software Foundation Conference!
> ------------------------- http://ApacheCon.Com ---------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

-- 
Darryl Stoflet
http://dstoflet.calweb.com

Re: Cocoon producers and Tomcat

Posted by Stefano Mazzocchi <st...@apache.org>.
Kevin Jones wrote:
> 
> if I'm using Cocoon from within Tomcat (the latest 3.1 build). If I add a
> producer to the cocoon.properties file I get the following
> 
> java.lang.RuntimeException: Error creating
> kevinj.develop.util.WeatherProducer: class is not found
> 
> I've put the class (package and all) under WEB-INF/classes, so the question
> is, where does Cocoon expect to find the producer class (or am I missing
> something else?) ?

I am currently trying to address the classloading/resourceloading
problems in Cocoon 1.7.1-dev to make it possible to use it in Tomcat or
under a specific jserv servlet zone.

The problem is that classloader behavior is a real pain in the ass,
expecially between 1.1 and 1.2 java versions.

But today I'll install tomcat 3.1b and see what happens.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Come to the first official Apache Software Foundation Conference!  
------------------------- http://ApacheCon.Com ---------------------



Re: Cocoon producers and Tomcat

Posted by Stefano Mazzocchi <st...@apache.org>.
Kevin Jones wrote:
> 
> if I'm using Cocoon from within Tomcat (the latest 3.1 build). If I add a
> producer to the cocoon.properties file I get the following
> 
> java.lang.RuntimeException: Error creating
> kevinj.develop.util.WeatherProducer: class is not found
> 
> I've put the class (package and all) under WEB-INF/classes, so the question
> is, where does Cocoon expect to find the producer class (or am I missing
> something else?) ?

After some investigation it seems a bug in Tomcat's classloader since in
JServ works perfectly.

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Come to the first official Apache Software Foundation Conference!  
------------------------- http://ApacheCon.Com ---------------------