wrapperClass usage

View: New views
7 Messages — Rating Filter:   Alert me  

wrapperClass usage

by goober_nut :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm trying to define my own wrapper, but I'm running into some issues.
Basically it appears the wrapper never gets called.

What I've done so far is create a very simple servlet which prints hello
to the browser and I've written a wrapper class named MyWrapper which
extends StandardWrapper. The MyWrapper class just has a constructor
which is supposed to print out to the logs "I'm in the wrapper."  Also,
in this project, I edited the context.xml file to read <Context
wrapperClass="MyWrapper.java"/> and started up the Tomcat server.

When I loaded up the hello servlet, I don't see the message "I'm in the
wrapper.", but I do see the page with hello on it.

I've also edited the context.xml file to read <Context
wrapperClass="FakeClass.java"/> to see if I'd see a message anywhere
showing me that it's trying to instantiate the wrapperClass for me but
couldn't. I don't see that either.

Can anyone tell me what I'm doing wrong?

Thanks,
   Brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: wrapperClass usage

by markt-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Brian E. Nicely wrote:
> What I've done so far is create a very simple servlet which prints hello
> to the browser and I've written a wrapper class named MyWrapper which
> extends StandardWrapper. The MyWrapper class just has a constructor
> which is supposed to print out to the logs "I'm in the wrapper."  Also,
> in this project, I edited the context.xml file to read <Context
> wrapperClass="MyWrapper.java"/> and started up the Tomcat server.

That should be wrapperClass="must.include.the.package.MyWrapper"

> Can anyone tell me what I'm doing wrong?

I assume the compiled class has been JAR'd and placed in the
CATALINA_HOME/lib directory.

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: wrapperClass usage

by goober_nut :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>> What I've done so far is create a very simple servlet which prints hello
>> to the browser and I've written a wrapper class named MyWrapper which
>> extends StandardWrapper. The MyWrapper class just has a constructor
>> which is supposed to print out to the logs "I'm in the wrapper."  Also,
>> in this project, I edited the context.xml file to read <Context
>> wrapperClass="MyWrapper.java"/> and started up the Tomcat server.

>That should be wrapperClass="must.include.the.package.MyWrapper"

Yes, I'm sorry, I did put my package name in there so it does look like wrapperClass="my.class.MyWrapper".
It does read though "my.class.MyWrapper.java", does that make a difference?

>> Can anyone tell me what I'm doing wrong?

>I assume the compiled class has been JAR'd and placed in the
>CATALINA_HOME/lib directory.

I don't have a $CATALINA_HOME/lib, I do have $CATALINA_HOME/common/lib, is that where it's supposed to go?

I did jar my MyWrapper's whole package up and put it in the /common/lib folder and restarted Tomcat. I tried it with both MyWrapper.java and MyWrapper and neither of them are printing for me.

>Mark

Re: wrapperClass usage

by Christopher Schultz-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Brian,

goober_nut wrote:
| Yes, I'm sorry, I did put my package name in there so it does look like
| wrapperClass="my.class.MyWrapper".
| It does read though "my.class.MyWrapper.java", does that make a
difference?

Yes, the class name does not include ".java" -- you should remove it.

|>> Can anyone tell me what I'm doing wrong?
|
|> I assume the compiled class has been JAR'd and placed in the
|> CATALINA_HOME/lib directory.
|
| I don't have a $CATALINA_HOME/lib, I do have $CATALINA_HOME/common/lib, is
| that where it's supposed to go?

You never said which version of TC you are using. For TC 6, it should go
in lib... for TC 5.5 it should go in shared/lib or server/lib. I
recommend the latter.

| I did jar my MyWrapper's whole package up and put it in the /common/lib
| folder and restarted Tomcat. I tried it with both MyWrapper.java and
| MyWrapper and neither of them are printing for me.

You probably have your JAR in the wrong place.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgstL0ACgkQ9CaO5/Lv0PCOZgCZAT2iiym4sikPF5nniP9V/RCX
XicAn0RKyADXrnLb9H5coPJ39WxL9iAA
=+L+U
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: wrapperClass usage

by goober_nut :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

| Yes, I'm sorry, I did put my package name in there so it does look like
| wrapperClass="my.class.MyWrapper".
| It does read though "my.class.MyWrapper.java", does that make a
difference?

Yes, the class name does not include ".java" -- you should remove it.

|>> Can anyone tell me what I'm doing wrong?
|
|> I assume the compiled class has been JAR'd and placed in the
|> CATALINA_HOME/lib directory.
|
| I don't have a $CATALINA_HOME/lib, I do have $CATALINA_HOME/common/lib, is
| that where it's supposed to go?

You never said which version of TC you are using. For TC 6, it should go
in lib... for TC 5.5 it should go in shared/lib or server/lib. I
recommend the latter.

| I did jar my MyWrapper's whole package up and put it in the /common/lib
| folder and restarted Tomcat. I tried it with both MyWrapper.java and
| MyWrapper and neither of them are printing for me.

You probably have your JAR in the wrong place.

Chris and Mark,

    Thank you both for your help. It's working now. I do have one more question now though since I got that to work.

    Is it possible to package up your own wrapper inside a war file which you can deploy to other Tomcat servers without putting it in Tomcat 5.5 - shared/lib or server/lib or Tomcat 6 lib/?

-Brian

Re: wrapperClass usage

by Christopher Schultz-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Brian,

goober_nut wrote:
| Is it possible to package up your own wrapper inside a war file which
| you can deploy to other Tomcat servers without putting it in Tomcat 5.5 -
| shared/lib or server/lib or Tomcat 6 lib/?

That depends on exactly which ClassLoader Tomcat uses to instantiate
your wrapper class. Given that placing your JAR in common/lib did not
work, I would imagine that putting it into your WAR file wouldn't work,
either.

Sorry, you're going to have to install your JAR file into any Tomcat
server where you want to use this wrapper.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgtvuUACgkQ9CaO5/Lv0PCmmwCfaWxurBcFLvKILwWGGhfNCiY9
PCUAoK1FVebfU9LojwbJbAbu5CBDsoCb
=J5En
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: wrapperClass usage

by Juha Laiho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

goober_nut wrote:
>     Is it possible to package up your own wrapper inside a war file which
> you can deploy to other Tomcat servers without putting it in Tomcat 5.5 -
> shared/lib or server/lib or Tomcat 6 lib/?

Not for deployment as a war file; I'm pretty certain that the class is not
being searched for in the webapp classpath, but in the system classpath
(however the claim that it does get loaded from shared/lib but not from
common/lib does contradict this).

What you could do is to declare a new directory in catalina.properties server
classpath for holding your own extensions to Tomcat. Whether this helps of
just makes the mess worse depends a lot on your situation.
--
..Juha

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...