RE: using my own LifecycleListener

2010-02-24 Thread STEINER Stephan
As above, you're using the wrong Listener type.  LifecycleListener is
an 
interface from org.apache.catalina and is not part of the Servlet Spec.

  You need:

  javax.servlet.ServletContextListener

Thanks, that did the trick. Glad I got that answer before going
completely mad ;)

Stephan


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: using my own LifecycleListener

2010-02-24 Thread Pid

On 24/02/2010 09:14, STEINER Stephan wrote:

As above, you're using the wrong Listener type.  LifecycleListener is

an

interface from org.apache.catalina and is not part of the Servlet Spec.



  You need:



  javax.servlet.ServletContextListener


Thanks, that did the trick. Glad I got that answer before going
completely mad ;)


Yep.  We're all mad as a box of frogs here, what with our reading of the 
docs and specs and so on.  Cuh-uh-razy.  Beep beep.



p


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



using my own LifecycleListener

2010-02-23 Thread STEINER Stephan
Hi

 

I need to launch an initialization procedure as soon as my web
application is deployed on Tomcat (working on a 6.0.20). 

 

As per the documentation, I can define a LifecycleListener in my
context.xml file for the webapp in question. However, the documentation
says that it needs to be packed as a jar and be copied to
$CATALINA_HOME/lib. And that's where I have my catch 22.. my
implementation of LicecycleListener needs access to objects defined in
the webapp - so I figure I have to deploy basically the entire solution
to $CATALINA_HOME/lib (which can be problematic if you run different
webapps making use of different versions of the same lib), then go hack
the build file so that it won't package my libs with the webapp anymore.

 

Am I misunderstanding something here? Shouldn't there be a deployment
way where I can keep the webapp self-contained? Or how can I get my
LifeCycleListener which I have to deploy outside my webapp to gain
access to the set of classes and libs that are part of the webapp?

In other words.. if mynamespace.MyLifeCycleListener is located in
$CATALINA_HOME/lib/CustomMyLifeCycleListener.jar, how will it have
access to libs and classes located in
$CATALINA_HOME/webapps/MyebApp/WEB-INF/lib (or
/WEB-INF/classes/mynamespace)? 

 

 

After writing these lines I figured I'd go ahead and test a little.. so
I created two libs

 

The Launcher Lib (launcherlib.jar) to be placed in $CATALINA_HOME/lib

The webapp lib (webapp-lib.jar) (which is used by both the launcher lib
and the webapp lib)

And the webapp itself (webapp.war)

 

Netbeans automatically adds a copy of the webapp lib to it. 

So I first copied the launcher lib including the launcher lib's own lib
dir (containing catalina.jar and webapp-lib.jar) to the tomcat lib
directory.

Then I deployed the webapp.. and it worked out just fine.

 

In the launcher app I initialize a singleton object in the webapp lib,
and then dump the fact that the initialization has been done to the
console (system.out.println). Looking at the Tomcat logs I see that this
is being done properly each time the webapp is being started.

 

However, if I get the same singleton object from the webapp and query
its initialization state, it tells me it is not initialized.. so
indicating that the two instances of the webapp lib run completely
separate.

 

So I went ahead and changed the manifest file of the launcher lib to
reference the deployed webapp lib jar file and removed the reference to
catalina.jar (it's in the same directory so it shouldn't matter).
Stopped and restarted the webapp.. the launcher lib still does its thing
just fine, but then accessing the webapp it still tells me the singleton
is not initialized.. so it's not a matter of where to put the files, but
even though the launcher lib is referenced in the context of the webapp,
it seems to run under a separate context and that's a problem - I need
the LifeCycleListener to initialize something that can then be used by
the webapp (I figure that's the main point to have a LifeCycleListener
for a specific webapp).. so how can I get the launcher lib and the
webapp to share their state?

 

Regards

Stephan



Re: using my own LifecycleListener

2010-02-23 Thread Pid

On 23/02/2010 18:00, STEINER Stephan wrote:

Hi

I need to launch an initialization procedure as soon as my web
application is deployed on Tomcat (working on a 6.0.20).

As per the documentation, I can define a LifecycleListener in my
context.xml file for the webapp in question. However, the documentation
says that it needs to be packed as a jar and be copied to
$CATALINA_HOME/lib. And that's where I have my catch 22.. my
implementation of LicecycleListener needs access to objects defined in
the webapp - so I figure I have to deploy basically the entire solution
to $CATALINA_HOME/lib (which can be problematic if you run different
webapps making use of different versions of the same lib), then go hack
the build file so that it won't package my libs with the webapp anymore.



Am I misunderstanding something here?


Yes.

 Shouldn't there be a deployment

way where I can keep the webapp self-contained? Or how can I get my
LifeCycleListener which I have to deploy outside my webapp to gain
access to the set of classes and libs that are part of the webapp?


You can't.


In other words.. if mynamespace.MyLifeCycleListener is located in
$CATALINA_HOME/lib/CustomMyLifeCycleListener.jar, how will it have
access to libs and classes located in
$CATALINA_HOME/webapps/MyebApp/WEB-INF/lib (or
/WEB-INF/classes/mynamespace)?


It won't.


After writing these lines I figured I'd go ahead and test a little.. so
I created two libs

The Launcher Lib (launcherlib.jar) to be placed in $CATALINA_HOME/lib

The webapp lib (webapp-lib.jar) (which is used by both the launcher lib
and the webapp lib)

And the webapp itself (webapp.war)

Netbeans automatically adds a copy of the webapp lib to it.

So I first copied the launcher lib including the launcher lib's own lib
dir (containing catalina.jar and webapp-lib.jar) to the tomcat lib
directory.

Then I deployed the webapp.. and it worked out just fine.


Really? ...


In the launcher app I initialize a singleton object in the webapp lib,
and then dump the fact that the initialization has been done to the
console (system.out.println). Looking at the Tomcat logs I see that this
is being done properly each time the webapp is being started.

However, if I get the same singleton object from the webapp and query
its initialization state, it tells me it is not initialized.. so
indicating that the two instances of the webapp lib run completely
separate.


... no, not fine.


So I went ahead and changed the manifest file of the launcher lib to
reference the deployed webapp lib jar file and removed the reference to
catalina.jar (it's in the same directory so it shouldn't matter).


Madness.


Stopped and restarted the webapp.. the launcher lib still does its thing
just fine, but then accessing the webapp it still tells me the singleton
is not initialized.. so it's not a matter of where to put the files, but
even though the launcher lib is referenced in the context of the webapp,
it seems to run under a separate context and that's a problem - I need
the LifeCycleListener to initialize something that can then be used by
the webapp (I figure that's the main point to have a LifeCycleListener
for a specific webapp).. so how can I get the launcher lib and the
webapp to share their state?


As above, you're using the wrong Listener type.  LifecycleListener is an 
interface from org.apache.catalina and is not part of the Servlet Spec. 
 You need:


 javax.servlet.ServletContextListener



p

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: using my own LifecycleListener

2010-02-23 Thread Caldarale, Charles R
 From: Pid [mailto:p...@pidster.com]
 Subject: Re: using my own LifecycleListener
 
   You need:
   javax.servlet.ServletContextListener

Which is declared in your webapp's WEB-INF/web.xml file, not the Context 
element.

The servlet spec is required reading before you ever touch any servlet 
container.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: using my own LifecycleListener

2010-02-23 Thread Jon Brisbin

On Feb 23, 2010, at 12:32 PM, Caldarale, Charles R wrote:

 The servlet spec is required reading before you ever touch any servlet 
 container.

Oops. Guess I missed that memo.

Crap.

Now I'm going to have to resign! I'm living a lie.

;)

Jon Brisbin
Portal Webmaster
NPC International, Inc.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org