You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tomás Tormo <tt...@indenova.com> on 2007/09/10 09:26:31 UTC

How to change the CLASSPATH in tomcat 5.028 for a concrete webservice

Hello

 I would like to change the classpath for a concrete webservice in 
Tomcat 5.028 because the webservice has to use a concrete folder in 
order to work. This folder should be in the CLASSPATH in order to make 
the webservice work properly and because the webservice can't find it, 
it doesn't work.

I've tried a lot of ways to solve it: I tried to launch tomcat with the 
classpath modified from the shell itself(making it point to the folder), 
tried to export the classpath from startup.sh script, tried to export 
the classpath from catalina.sh script, tried to modify the CATALINA_OPTS 
variable, tried to put the folder in both lib and classes folders of the 
webservice folder... but nothing worked.

could you please help me? Anyway i'll continue researching by myself.

thank you very much


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


RE: *SPAM* Re: How to change the CLASSPATH in tomcat 5.028 for aconcrete webservice

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: David Smith [mailto:dns4@cornell.edu] 
> Subject: Re: *SPAM* Re: How to change the CLASSPATH in tomcat 
> 5.028 for aconcrete webservice
> 
> I still think setting CLASSPATH should be an absolutely last resort.

Strongly agree, and even trying to do so is likely a complete waste of
time.

There shouldn't be any need for the native library to be in the same
location as the .jar (or .class) file that refers to it; the compiled
Java code should be placed in WEB-INF/lib or WEB-INF/classes, and the
location of the native code given on he LD_LIBRARY_PATH environment
variable.

 - 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 start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: *SPAM* Re: How to change the CLASSPATH in tomcat 5.028 for a concrete webservice

Posted by David Smith <dn...@cornell.edu>.
Can you post a) the working classpath from the command line and b) the 
stack trace you get when it's launched as a webservice?

One other thought that comes to mind is you might want to check all your 
environment variables as a user and as a webservice -- see if the 
installation created something that's not in the profile tomcat is 
running under.

I still think setting CLASSPATH should be an absolutely last resort.

--David

Tomás Tormo wrote:
> Hi David
>
>   I'm using tomcat 5.028 in Ubuntu 6.10 . I've written a java 
> applicattion wich uses a wrapper to communicate with an applicattion 
> written in C, wich is the "core" of my applicattion. Both the wrapper 
> and the core are third party applicattions, and because of that i 
> don't have the source code, I just have the API.
>
> The third party sent me an example application wich uses the core. 
> And, as I could see in the script wich lauches the application, this 
> folder should be added to the classpath in order to be able to be 
> located by the wrapper applicattion. The documentation of the wrapper 
> just says that this folder has to exist with an specific name.
>
> My problem is that my applicattion works fine launched from shell (it 
> founds the folder and uses the core perfectly) but it doesn't work as 
> a webservice. It is not able to find the resource folder (let's call 
> it "cfg"). As I can see in the catalina log, the application tries to 
> load the resources (via ClassLoader I guess) and then launches an 
> exception saying that is not able to find it. The client  gets a 
> HTTPErrorCode0.
>
> I think I've tried everything to make it find the folder, but I wasn't 
> successful. do you have any idea?
>
> thank you very  much
>
> David Smith escribió:
>> I wold STRONLY recommend you DO NOT touch the CLASSPATH env 
>> variable.  It's just a horrible idea.  What is it about your 
>> webservice that requires the alteration of CLASSPATH?  Can you 
>> describe that a bit more?  The standard classloader structure works 
>> very well in virtually all other cases.
>>
>> --David
>>
>> Tomás Tormo wrote:
>>> Hi again
>>>
>>>  I've tried to set the classpath in catalina.sh in order to have my 
>>> own classpath set when tomcat starts up ( I show it in catalina.sh 
>>> as well and it looks good). But my problem is that when I show it in 
>>> my webservice (using 
>>> System.out.println(System.getProperty("java.class.path"))) it is 
>>> changed again (it only points to a few jar files in /bin folder) and 
>>> therefore my webservice can't work properly. Shouldn't it be pinting 
>>> to my my /webapp/webservice/WEB-INF/lib folder as well? Does anybody 
>>> know how to fix this problem?
>>>
>>> Hakan: I've tried the solution you gave me (create a setenv.sh 
>>> script called from startup.sh) but tomcat don't start up!
>>>
>>> Thank you very much for your future answers :p
>>>
>>> Tomás Tormo escribió:
>>>> Hi Hakan
>>>>
>>>> First of all thank you for your fast answer ;).
>>>>
>>>> Do you mean to create an script called setenv.sh wich will set the 
>>>> CLASSPATH (by export CLASSPATH.. etc)? This script should be called 
>>>> by a modified startup.sh?
>>>>
>>>> By they way, I printed the CLASSPATH in my webservice (using 
>>>> System.out.println(System.getProperty("java.class.path")); ) and it 
>>>> says that my CLASSPATH is only pointing to a few jars in the bin 
>>>> folder, not even to my /lib folder in my webservice folder (I hope 
>>>> I explained myself well, I'm not using war files). Shouldn't it be 
>>>> pointing to my /webapp/webservice/WEB-INF/lib folder as well?
>>>>
>>>> Thank you!!
>>>>
>>>> Greetings!!
>>>>
>>>>
>>>>
>>>> Hakan Koseoglu escribió:
>>>>> Hi Tomás,
>>>>> Tomás Tormo said the following on 09/10/2007 08:26 AM:
>>>>>> I would like to change the classpath for a concrete webservice in 
>>>>>> Tomcat 5.028 because the webservice has to use a concrete folder 
>>>>>> in order to work. This folder should be in the CLASSPATH in order 
>>>>>> to make the webservice work properly and because the webservice 
>>>>>> can't find it, it doesn't work.
>>>>> With Tomcat 5, creating a setenv.sh solves the problem for me. It 
>>>>> gets called if you start the Tomcat using startup.sh.
>>>>>
>>>>> Any variable you define there will be used, including the 
>>>>> classpath. We use it to point to the libraries which we don't put 
>>>>> into common/lib nor war files.
>>>>>
>>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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


Re: *SPAM* Re: How to change the CLASSPATH in tomcat 5.028 for a concrete webservice

Posted by Bill Barker <wb...@wilshire.com>.
"Tom�s Tormo" <tt...@indenova.com> wrote in message 
news:46E510E0.7050506@indenova.com...
> Hi David
>
>   I'm using tomcat 5.028 in Ubuntu 6.10 . I've written a java applicattion 
> wich uses a wrapper to communicate with an applicattion written in C, wich 
> is the "core" of my applicattion. Both the wrapper and the core are third 
> party applicattions, and because of that i don't have the source code, I 
> just have the API.
>
> The third party sent me an example application wich uses the core. And, as 
> I could see in the script wich lauches the application, this folder should 
> be added to the classpath in order to be able to be located by the wrapper 
> applicattion. The documentation of the wrapper just says that this folder 
> has to exist with an specific name.
>
> My problem is that my applicattion works fine launched from shell (it 
> founds the folder and uses the core perfectly) but it doesn't work as a 
> webservice. It is not able to find the resource folder (let's call it 
> "cfg"). As I can see in the catalina log, the application tries to load 
> the resources (via ClassLoader I guess) and then launches an exception 
> saying that is not able to find it. The client  gets a HTTPErrorCode0.
>
> I think I've tried everything to make it find the folder, but I wasn't 
> successful. do you have any idea?
>

I agree with David and Chuck:  Setting the CLASSPATH is evil.  If you 
*really* need to do this, then put the third-party jar in shared/lib and 
edit conf/catalina.properties to add your external directory to the 
classpath.

> thank you very  much
>
> David Smith escribi�:
>> I wold STRONLY recommend you DO NOT touch the CLASSPATH env variable. 
>> It's just a horrible idea.  What is it about your webservice that 
>> requires the alteration of CLASSPATH?  Can you describe that a bit more? 
>> The standard classloader structure works very well in virtually all other 
>> cases.
>>
>> --David
>>
>> Tom�s Tormo wrote:
>>> Hi again
>>>
>>>  I've tried to set the classpath in catalina.sh in order to have my own 
>>> classpath set when tomcat starts up ( I show it in catalina.sh as well 
>>> and it looks good). But my problem is that when I show it in my 
>>> webservice (using 
>>> System.out.println(System.getProperty("java.class.path"))) it is changed 
>>> again (it only points to a few jar files in /bin folder) and therefore 
>>> my webservice can't work properly. Shouldn't it be pinting to my my 
>>> /webapp/webservice/WEB-INF/lib folder as well? Does anybody know how to 
>>> fix this problem?
>>>
>>> Hakan: I've tried the solution you gave me (create a setenv.sh script 
>>> called from startup.sh) but tomcat don't start up!
>>>
>>> Thank you very much for your future answers :p
>>>
>>> Tom�s Tormo escribi�:
>>>> Hi Hakan
>>>>
>>>> First of all thank you for your fast answer ;).
>>>>
>>>> Do you mean to create an script called setenv.sh wich will set the 
>>>> CLASSPATH (by export CLASSPATH.. etc)? This script should be called by 
>>>> a modified startup.sh?
>>>>
>>>> By they way, I printed the CLASSPATH in my webservice (using 
>>>> System.out.println(System.getProperty("java.class.path")); ) and it 
>>>> says that my CLASSPATH is only pointing to a few jars in the bin 
>>>> folder, not even to my /lib folder in my webservice folder (I hope I 
>>>> explained myself well, I'm not using war files). Shouldn't it be 
>>>> pointing to my /webapp/webservice/WEB-INF/lib folder as well?
>>>>
>>>> Thank you!!
>>>>
>>>> Greetings!!
>>>>
>>>>
>>>>
>>>> Hakan Koseoglu escribi�:
>>>>> Hi Tom�s,
>>>>> Tom�s Tormo said the following on 09/10/2007 08:26 AM:
>>>>>> I would like to change the classpath for a concrete webservice in 
>>>>>> Tomcat 5.028 because the webservice has to use a concrete folder in 
>>>>>> order to work. This folder should be in the CLASSPATH in order to 
>>>>>> make the webservice work properly and because the webservice can't 
>>>>>> find it, it doesn't work.
>>>>> With Tomcat 5, creating a setenv.sh solves the problem for me. It gets 
>>>>> called if you start the Tomcat using startup.sh.
>>>>>
>>>>> Any variable you define there will be used, including the classpath. 
>>>>> We use it to point to the libraries which we don't put into common/lib 
>>>>> nor war files.
>>>>>
>>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 




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


Re: *SPAM* Re: How to change the CLASSPATH in tomcat 5.028 for a concrete webservice

Posted by Tomás Tormo <tt...@indenova.com>.
Hi David

   I'm using tomcat 5.028 in Ubuntu 6.10 . I've written a java 
applicattion wich uses a wrapper to communicate with an applicattion 
written in C, wich is the "core" of my applicattion. Both the wrapper 
and the core are third party applicattions, and because of that i don't 
have the source code, I just have the API.

The third party sent me an example application wich uses the core. And, 
as I could see in the script wich lauches the application, this folder 
should be added to the classpath in order to be able to be located by 
the wrapper applicattion. The documentation of the wrapper just says 
that this folder has to exist with an specific name.

My problem is that my applicattion works fine launched from shell (it 
founds the folder and uses the core perfectly) but it doesn't work as a 
webservice. It is not able to find the resource folder (let's call it 
"cfg"). As I can see in the catalina log, the application tries to load 
the resources (via ClassLoader I guess) and then launches an exception 
saying that is not able to find it. The client  gets a HTTPErrorCode0.

I think I've tried everything to make it find the folder, but I wasn't 
successful. do you have any idea?

thank you very  much

David Smith escribió:
> I wold STRONLY recommend you DO NOT touch the CLASSPATH env variable.  
> It's just a horrible idea.  What is it about your webservice that 
> requires the alteration of CLASSPATH?  Can you describe that a bit 
> more?  The standard classloader structure works very well in virtually 
> all other cases.
>
> --David
>
> Tomás Tormo wrote:
>> Hi again
>>
>>  I've tried to set the classpath in catalina.sh in order to have my 
>> own classpath set when tomcat starts up ( I show it in catalina.sh as 
>> well and it looks good). But my problem is that when I show it in my 
>> webservice (using 
>> System.out.println(System.getProperty("java.class.path"))) it is 
>> changed again (it only points to a few jar files in /bin folder) and 
>> therefore my webservice can't work properly. Shouldn't it be pinting 
>> to my my /webapp/webservice/WEB-INF/lib folder as well? Does anybody 
>> know how to fix this problem?
>>
>> Hakan: I've tried the solution you gave me (create a setenv.sh script 
>> called from startup.sh) but tomcat don't start up!
>>
>> Thank you very much for your future answers :p
>>
>> Tomás Tormo escribió:
>>> Hi Hakan
>>>
>>> First of all thank you for your fast answer ;).
>>>
>>> Do you mean to create an script called setenv.sh wich will set the 
>>> CLASSPATH (by export CLASSPATH.. etc)? This script should be called 
>>> by a modified startup.sh?
>>>
>>> By they way, I printed the CLASSPATH in my webservice (using 
>>> System.out.println(System.getProperty("java.class.path")); ) and it 
>>> says that my CLASSPATH is only pointing to a few jars in the bin 
>>> folder, not even to my /lib folder in my webservice folder (I hope I 
>>> explained myself well, I'm not using war files). Shouldn't it be 
>>> pointing to my /webapp/webservice/WEB-INF/lib folder as well?
>>>
>>> Thank you!!
>>>
>>> Greetings!!
>>>
>>>
>>>
>>> Hakan Koseoglu escribió:
>>>> Hi Tomás,
>>>> Tomás Tormo said the following on 09/10/2007 08:26 AM:
>>>>> I would like to change the classpath for a concrete webservice in 
>>>>> Tomcat 5.028 because the webservice has to use a concrete folder 
>>>>> in order to work. This folder should be in the CLASSPATH in order 
>>>>> to make the webservice work properly and because the webservice 
>>>>> can't find it, it doesn't work.
>>>> With Tomcat 5, creating a setenv.sh solves the problem for me. It 
>>>> gets called if you start the Tomcat using startup.sh.
>>>>
>>>> Any variable you define there will be used, including the 
>>>> classpath. We use it to point to the libraries which we don't put 
>>>> into common/lib nor war files.
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: How to change the CLASSPATH in tomcat 5.028 for a concrete webservice

Posted by David Smith <dn...@cornell.edu>.
I wold STRONLY recommend you DO NOT touch the CLASSPATH env variable.  
It's just a horrible idea.  What is it about your webservice that 
requires the alteration of CLASSPATH?  Can you describe that a bit 
more?  The standard classloader structure works very well in virtually 
all other cases.

--David

Tomás Tormo wrote:
> Hi again
>
>  I've tried to set the classpath in catalina.sh in order to have my 
> own classpath set when tomcat starts up ( I show it in catalina.sh as 
> well and it looks good). But my problem is that when I show it in my 
> webservice (using 
> System.out.println(System.getProperty("java.class.path"))) it is 
> changed again (it only points to a few jar files in /bin folder) and 
> therefore my webservice can't work properly. Shouldn't it be pinting 
> to my my /webapp/webservice/WEB-INF/lib folder as well? Does anybody 
> know how to fix this problem?
>
> Hakan: I've tried the solution you gave me (create a setenv.sh script 
> called from startup.sh) but tomcat don't start up!
>
> Thank you very much for your future answers :p
>
> Tomás Tormo escribió:
>> Hi Hakan
>>
>> First of all thank you for your fast answer ;).
>>
>> Do you mean to create an script called setenv.sh wich will set the 
>> CLASSPATH (by export CLASSPATH.. etc)? This script should be called 
>> by a modified startup.sh?
>>
>> By they way, I printed the CLASSPATH in my webservice (using 
>> System.out.println(System.getProperty("java.class.path")); ) and it 
>> says that my CLASSPATH is only pointing to a few jars in the bin 
>> folder, not even to my /lib folder in my webservice folder (I hope I 
>> explained myself well, I'm not using war files). Shouldn't it be 
>> pointing to my /webapp/webservice/WEB-INF/lib folder as well?
>>
>> Thank you!!
>>
>> Greetings!!
>>
>>
>>
>> Hakan Koseoglu escribió:
>>> Hi Tomás,
>>> Tomás Tormo said the following on 09/10/2007 08:26 AM:
>>>> I would like to change the classpath for a concrete webservice in 
>>>> Tomcat 5.028 because the webservice has to use a concrete folder in 
>>>> order to work. This folder should be in the CLASSPATH in order to 
>>>> make the webservice work properly and because the webservice can't 
>>>> find it, it doesn't work.
>>> With Tomcat 5, creating a setenv.sh solves the problem for me. It 
>>> gets called if you start the Tomcat using startup.sh.
>>>
>>> Any variable you define there will be used, including the classpath. 
>>> We use it to point to the libraries which we don't put into 
>>> common/lib nor war files.
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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


Re: How to change the CLASSPATH in tomcat 5.028 for a concrete webservice

Posted by Tomás Tormo <tt...@indenova.com>.
Hi again

  I've tried to set the classpath in catalina.sh in order to have my own 
classpath set when tomcat starts up ( I show it in catalina.sh as well 
and it looks good). But my problem is that when I show it in my 
webservice (using 
System.out.println(System.getProperty("java.class.path"))) it is changed 
again (it only points to a few jar files in /bin folder) and therefore 
my webservice can't work properly. Shouldn't it be pinting to my my 
/webapp/webservice/WEB-INF/lib folder as well? Does anybody know how to 
fix this problem?

Hakan: I've tried the solution you gave me (create a setenv.sh script 
called from startup.sh) but tomcat don't start up!

Thank you very much for your future answers :p

Tomás Tormo escribió:
> Hi Hakan
>
> First of all thank you for your fast answer ;).
>
> Do you mean to create an script called setenv.sh wich will set the 
> CLASSPATH (by export CLASSPATH.. etc)? This script should be called by 
> a modified startup.sh?
>
> By they way, I printed the CLASSPATH in my webservice (using 
> System.out.println(System.getProperty("java.class.path")); ) and it 
> says that my CLASSPATH is only pointing to a few jars in the bin 
> folder, not even to my /lib folder in my webservice folder (I hope I 
> explained myself well, I'm not using war files). Shouldn't it be 
> pointing to my /webapp/webservice/WEB-INF/lib folder as well?
>
> Thank you!!
>
> Greetings!!
>
>
>
> Hakan Koseoglu escribió:
>> Hi Tomás,
>> Tomás Tormo said the following on 09/10/2007 08:26 AM:
>>> I would like to change the classpath for a concrete webservice in 
>>> Tomcat 5.028 because the webservice has to use a concrete folder in 
>>> order to work. This folder should be in the CLASSPATH in order to 
>>> make the webservice work properly and because the webservice can't 
>>> find it, it doesn't work.
>> With Tomcat 5, creating a setenv.sh solves the problem for me. It 
>> gets called if you start the Tomcat using startup.sh.
>>
>> Any variable you define there will be used, including the classpath. 
>> We use it to point to the libraries which we don't put into 
>> common/lib nor war files.
>>
>>
>

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