This thing with LifecycleListener seems nice. I have made an implementation
of the LifecycleListener interface but I cant start tomcat. It complains
that it cant find my class. The  implementation is in the same jar file as
the servlets, and starting the servlets is not a problem. Does this file
need to be in some other classpath?

This is the error I get:
ERROR reading /var/tomcat4/conf/server.xml
At Line 36 /Server/Service/Engine/Host/Context/Listener/
className=se.ehorizon.voipzon.provision.servlets.ContextListener debug=9

Catalina.start: java.lang.ClassNotFoundException:
se.ehorizon.voipzon.provision.servlets.ContextListener
java.lang.ClassNotFoundException:
se.ehorizon.voipzon.provision.servlets.ContextListener
        at
org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader
.java:1127)
        at
org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader
.java:992)


And this is my settings for the context (from server.xml)
<Host name="provadm" debug="0" appBase="webapps" unpackWARs="true">
  <Context path="/" docBase="/var/ehorizon/servlet/provisioning" debug="0"
reloadable="true">
    <Parameter name="config_file"
value="/etc/ehorizon/provisioning/provision.xml" override="false"/>
    <Listener
className="se.ehorizon.voipzon.provision.servlets.ContextListener"
debug="9">
  </Context>
</Host>

Regards,

Andreas

-----Original Message-----
From: Reynir H�bner [mailto:[EMAIL PROTECTED]
Sent: den 7 mars 2003 11:54
To: Tomcat Users List
Subject: RE: Share Java resources between two (or more) servlets


Hi,

See intermixed.


> -----Original Message-----
> From: Andreas Bystr�m [mailto:[EMAIL PROTECTED]
> Sent: 7. mars 2003 10:20
> To: Tomcat Users
> Subject: Share Java resources between two (or more) servlets
>
>
> Hi all!
>
> I'm writing an application that uses (for now) 4 different
> servlets. I would like all these servlets to share some java
> singelton object. Is this possible? Do all servlets share the
> same jvm instance and thereby uses the same singelton object?

Sure no problem as long as the singleton object is in the same classloader
scope it should not be a problem.
Each application is loaded with sepperate classloaders, so as long as the
servlets are in the same application and the singleton is in it's classpath
too it works.

>
> I have one servlet that is set to load-on-startup, this
> servlet will create the java object (db connections and other
> stuff) that I want all servlets to share later on. This
> servlet is not used anymore, it hust listens for shutdown and
> will not receive any requests. Is this how you should solve a
> initialization problem or is there some other way?

Use a ServletContextListener to startup such objects, rather than the
load-on-startup method of servlets.
It has some benefits doing it that way, like, you can do some cleanup (if
needed) when the context is destroyed.

> When I run my application I start this servlet  (servlet1) as
> above. But when I then invoke another servlet, servlet2,
> (that is not set to
> load-on-startup) there is a strange behavior. Using my traces
> I can read that it first invokes init on servlet1 again and
> then init on servlet2. If I then sends a first reuquest to
> servlet3 it just does init on servlet3. If I instead had sent
> the first request to 3 before the first request to servlet2
> it is the same behavior but vice versa. when the request
> comes to servlet3 it does init on first 1 nd then 3. The
> request to servlet 2 now just incokes init on servlet2. Have
> anyone a clue of you it can be like this?

Not really...
How are you "sending the requests" ?
-reynir

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to