You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jeroen ter Voorde <j....@home.nl> on 2002/06/24 10:50:19 UTC

Servlet initializing twice

Hi,

I read this problem was fixed in the latest tomcat versions. But i still got
the problem with 4.0.4.
It seems it has something to do with the classloader I'm using a singleton
server class which also gets initialized
twice making me think there are two instances of the same class. With
previous excalibur jars moving all jars from WEB-INF/lib to
tomcat/common/lib fixed the problem.
The latest excalibur jars broke the above solution so my problem is back
again :(

Any ideas?

Thanks,
    Jeroen


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Servlet initializing twice

Posted by Jeroen ter Voorde <j....@home.nl>.
>
> ----- Original Message -----
> From: "Vadim Gritsenko" <va...@verizon.net>
> To: <co...@xml.apache.org>
> Sent: Monday, June 24, 2002 2:48 PM
> Subject: RE: Servlet initializing twice
>
>
> > > From: Jeroen ter Voorde [mailto:j.tervoorde@home.nl]
> > >
> > > Hi,
> > >
> > > I read this problem was fixed in the latest tomcat versions. But i
> > still got
> > > the problem with 4.0.4.
> > > It seems it has something to do with the classloader I'm using a
> > singleton
> > > server class which also gets initialized
> > > twice making me think there are two instances of the same class. With
> >
> > You have some classloading issues, but not the issue in subject of your
> > mail. If you would have multiple servlet initializations, Cocoon will
> > try to initialize twice, including HSQLDB which binds to the port and
> > second instance fails to do so. In tomcat 4.0.4, this does not happen,
> > and this issue is solved.
> >
> >
> > > previous excalibur jars moving all jars from WEB-INF/lib to
> > > tomcat/common/lib fixed the problem.
> > > The latest excalibur jars broke the above solution so my problem is
> > back
> > > again :(
> > >
> > > Any ideas?
> >
> > Make your class Avalon component or make a wrapper around your class.
> > Then Cocoon will be able to manage lifecycle of your class.
> >
> > Vadim
> >
>
> I just made a testcomponent which only prints a line to the console.
> I added the component to cocoon.xconf. I also removed the parent component
> manager from web.xml
> The component is initialized twice and the classes itself are also loaded
> twice.
> I tested this using com.myorg.MyClass.class.hashCode() which prints two
> different values.
>
> I'm not really into the classloader stuff but i understand a class will
> never be loaded twice by
> the same classloader. I didn't configure the classloader with cocoon in
> web.xml.
>

Update:

Now copied all jars to tomcat/lib. Components are still initialized twice
but classes are only
loaded once so the singleton stuff works. Removing the <load-on-startup> tag
from web.xml fixed
the initialization problem but is not really an option for me.

At least my biggest problem is solved.

Jeroen

>
>
> >
> > > Thanks,
> > >     Jeroen
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> > For additional commands, email: cocoon-dev-help@xml.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Servlet initializing twice

Posted by Jeroen ter Voorde <j....@home.nl>.
----- Original Message -----
From: "Vadim Gritsenko" <va...@verizon.net>
To: <co...@xml.apache.org>
Sent: Monday, June 24, 2002 2:48 PM
Subject: RE: Servlet initializing twice


> > From: Jeroen ter Voorde [mailto:j.tervoorde@home.nl]
> >
> > Hi,
> >
> > I read this problem was fixed in the latest tomcat versions. But i
> still got
> > the problem with 4.0.4.
> > It seems it has something to do with the classloader I'm using a
> singleton
> > server class which also gets initialized
> > twice making me think there are two instances of the same class. With
>
> You have some classloading issues, but not the issue in subject of your
> mail. If you would have multiple servlet initializations, Cocoon will
> try to initialize twice, including HSQLDB which binds to the port and
> second instance fails to do so. In tomcat 4.0.4, this does not happen,
> and this issue is solved.
>
>
> > previous excalibur jars moving all jars from WEB-INF/lib to
> > tomcat/common/lib fixed the problem.
> > The latest excalibur jars broke the above solution so my problem is
> back
> > again :(
> >
> > Any ideas?
>
> Make your class Avalon component or make a wrapper around your class.
> Then Cocoon will be able to manage lifecycle of your class.
>
> Vadim
>

I just made a testcomponent which only prints a line to the console.
I added the component to cocoon.xconf. I also removed the parent component
manager from web.xml
The component is initialized twice and the classes itself are also loaded
twice.
I tested this using com.myorg.MyClass.class.hashCode() which prints two
different values.

I'm not really into the classloader stuff but i understand a class will
never be loaded twice by
the same classloader. I didn't configure the classloader with cocoon in
web.xml.



>
> > Thanks,
> >     Jeroen
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


RE: Servlet initializing twice

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Jeroen ter Voorde [mailto:j.tervoorde@home.nl]
> 
> Hi,
> 
> I read this problem was fixed in the latest tomcat versions. But i
still got
> the problem with 4.0.4.
> It seems it has something to do with the classloader I'm using a
singleton
> server class which also gets initialized
> twice making me think there are two instances of the same class. With

You have some classloading issues, but not the issue in subject of your
mail. If you would have multiple servlet initializations, Cocoon will
try to initialize twice, including HSQLDB which binds to the port and
second instance fails to do so. In tomcat 4.0.4, this does not happen,
and this issue is solved.


> previous excalibur jars moving all jars from WEB-INF/lib to
> tomcat/common/lib fixed the problem.
> The latest excalibur jars broke the above solution so my problem is
back
> again :(
> 
> Any ideas?

Make your class Avalon component or make a wrapper around your class.
Then Cocoon will be able to manage lifecycle of your class.

Vadim


> Thanks,
>     Jeroen


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org