You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by charithsoori <ch...@gmail.com> on 2011/07/09 01:40:16 UTC

JNA class path with tomcat

Hi,
I am trying to run a web application which is which using JNA . My
application work fins as standalone and when it configured as a web app
tomcat it giving  error "

java.lang.NoClassDefFoundError:
com/stibocatalog/hunspell/HunspellLibrary " . It seems native library
not loading. How I can solve this problem

"

-- 
*

*

Best Regards
CharithSoOri

Re: JNA class path with tomcat

Posted by Pid <pi...@pidster.com>.
On 09/07/2011 00:40, charithsoori wrote:
> Hi,
> I am trying to run a web application which is which using JNA . My
> application work fins as standalone and when it configured as a web app
> tomcat it giving  error "
> 
> java.lang.NoClassDefFoundError:
> com/stibocatalog/hunspell/HunspellLibrary " . It seems native library
> not loading. How I can solve this problem
> 
> "

try again, after reading:

 http://www.catb.org/~esr/faqs/smart-questions.html


p


Re: JNA class path with tomcat

Posted by André Warnier <aw...@ice-sa.com>.
Bill Miller wrote:
> That is true, but assuming things for library loading will eventually bite you ... big time.

I did not think that I was /assuming/ anything.
The link provided below explains exactly where "Tomcat" is looking for classes and 
libraries, and "." is not part of that (usually).

> 
> FYI: In Windows there is a patch available that can damage this path searching defaults and
> assumptions always bite you. It is always best to specifically set these variables (JVM search paths
> etc...) so there are no assumptions, and it's always better to specify a particular location of a
> library (using an environment variable works best here) if you don't set the JVM/environment so a
> random library doesn't get used by accident. 
> 
> I'm sure everyone's heard of DLL Hell (or .so Hell)... assuming paths that may not be correct in
> 100% of situations are the path to problems.
> 
> Bill
> 
> -----Original Message-----
> From: André Warnier [mailto:aw@ice-sa.com] 
> Sent: July 12, 2011 2:27 PM
> To: Tomcat Users List
> Subject: Re: JNA class path with tomcat
> 
> Bill Miller wrote:
>> The problem is undoubtedly your .dll or .so is not in the correct directory. 
> 
> That's probably true.
> 
> Normally you need to
>> place those files in /tomcat but that assumes that /tomcat is your current directory when you
>> startup. Essentially you need to ensure that you are starting tomcat from the base directory that
>> also contains your native code, then everything will work fine.
>>
> 
> But that is probably hogwash.
> 
> The JVM which runs Tomcat has a series of paths where it will look for classes and 
> libraries; to which Tomcat itself adds its own series of paths; to which the webapp 
> classloader adds its own.  The library should be in one of those, depending what its 
> "scope" is.
> 
> See here for the real explanation: 
> http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


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


RE: JNA class path with tomcat

Posted by Bill Miller <mi...@gmail.com>.
That is true, but assuming things for library loading will eventually bite you ... big time.

FYI: In Windows there is a patch available that can damage this path searching defaults and
assumptions always bite you. It is always best to specifically set these variables (JVM search paths
etc...) so there are no assumptions, and it's always better to specify a particular location of a
library (using an environment variable works best here) if you don't set the JVM/environment so a
random library doesn't get used by accident. 

I'm sure everyone's heard of DLL Hell (or .so Hell)... assuming paths that may not be correct in
100% of situations are the path to problems.

Bill

-----Original Message-----
From: André Warnier [mailto:aw@ice-sa.com] 
Sent: July 12, 2011 2:27 PM
To: Tomcat Users List
Subject: Re: JNA class path with tomcat

Bill Miller wrote:
> The problem is undoubtedly your .dll or .so is not in the correct directory. 

That's probably true.

Normally you need to
> place those files in /tomcat but that assumes that /tomcat is your current directory when you
> startup. Essentially you need to ensure that you are starting tomcat from the base directory that
> also contains your native code, then everything will work fine.
> 

But that is probably hogwash.

The JVM which runs Tomcat has a series of paths where it will look for classes and 
libraries; to which Tomcat itself adds its own series of paths; to which the webapp 
classloader adds its own.  The library should be in one of those, depending what its 
"scope" is.

See here for the real explanation: 
http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html



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


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


Re: JNA class path with tomcat

Posted by André Warnier <aw...@ice-sa.com>.
Bill Miller wrote:
> The problem is undoubtedly your .dll or .so is not in the correct directory. 

That's probably true.

Normally you need to
> place those files in /tomcat but that assumes that /tomcat is your current directory when you
> startup. Essentially you need to ensure that you are starting tomcat from the base directory that
> also contains your native code, then everything will work fine.
> 

But that is probably hogwash.

The JVM which runs Tomcat has a series of paths where it will look for classes and 
libraries; to which Tomcat itself adds its own series of paths; to which the webapp 
classloader adds its own.  The library should be in one of those, depending what its 
"scope" is.

See here for the real explanation: 
http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html



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


RE: JNA class path with tomcat

Posted by Bill Miller <mi...@gmail.com>.
The problem is undoubtedly your .dll or .so is not in the correct directory. Normally you need to
place those files in /tomcat but that assumes that /tomcat is your current directory when you
startup. Essentially you need to ensure that you are starting tomcat from the base directory that
also contains your native code, then everything will work fine.

You may also want to ensure you're specifying the native files directly to ensure you're not leaving
a security opening for someone to hack your application (and your client's computer). Also wrapping
the load library call in a catch Throwable can be very helpful if you log the exception (one of the
few times a catch Throwable is not a bad thing).


Bill
-----Original Message-----
From: charithsoori [mailto:charithsoori@gmail.com] 
Sent: July 8, 2011 7:40 PM
To: users@tomcat.apache.org
Subject: JNA class path with tomcat

Hi,
I am trying to run a web application which is which using JNA . My
application work fins as standalone and when it configured as a web app
tomcat it giving  error "

java.lang.NoClassDefFoundError:
com/stibocatalog/hunspell/HunspellLibrary " . It seems native library
not loading. How I can solve this problem

"

-- 
*

*

Best Regards
CharithSoOri


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