Re: Two Services trying to load a System library in same JVM

Francisco Albasini Mourão <[email protected]> Tue, 8 Jul 2008 18:41:23 +0100
Newsgroups gmane.comp.java.sun.jini
Message-ID <[email protected]>
Thanx for the note Greg! But that is not the issue here.

-----Original Message-----
From: Greg Trasuk [mailto:[email protected]] 
Sent: terça-feira, 8 de Julho de 2008 17:50
To: [email protected]
Subject: Re: Two Services trying to load a System library in same JVM

On Tue, 2008-07-08 at 11:57, Gregg Wonderly wrote:
> Francisco Mourao wrote:
> > Hi there,
> > I have a monitor application that launches in the same JVM two instances of
> > the same service each one monitoring a serial port. Namely, Monitor1 and
> > Monitor2 are two instances of same service MonitorService with entries
> > name=M1 and name=M2 respectively.
> > 
> > The problem is that MonitorService tries to load a system library with
> > System.loadLibrary(...). The first instance to be initialized loads
> > successfully but when the second service tries to load the library an
> > exception is thrown saying that the library is already loaded. 
> > 
> > This must be a very common problem I suppose. So I think there must be some
> > work around for this. Or not? 
> > 
> > I didn't want to launch a VM for each instance of MonitorService... i can
> > have up to  20 instances...
> 
> The easiest thing to do is build a new start.jar that includes a class-path 
> reference to the serial comms library's jar.  Then, it will be loaded once, from 
> the system classloader, instead of from each services preferred classloader.
> 
> I am assuming you are using com.sun.jini.start to start your services.
> 
> Gregg Wonderly

I assume you're using Sun's comm implementation?  It makes the (rather
bad) assumption that there's only one instance of the adapter, that will
be loaded in one classloader.  The drivers at http://serialio.com don't
make this assumption.  Well worth the (if I remember correctly) $50
price.  They will also run happily under Tomcat, which the Sun drivers
won't.

Cheers,

Greg.
-- 
Greg Trasuk, President
StratusCom Manufacturing Systems Inc. - We use information technology to
solve business problems on your plant floor.
http://stratuscom.com

--------------------------------------------------------------------------
Getting Started:     http://www.jini.org/wiki/Category:Getting_Started
Community Web Site:  http://jini.org
jini-users Archive:  http://archives.java.sun.com/archives/jini-users.html
Unsubscribing:       email "signoff JINI-USERS"  to [email protected]

--------------------------------------------------------------------------
Getting Started:     http://www.jini.org/wiki/Category:Getting_Started
Community Web Site:  http://jini.org
jini-users Archive:  http://archives.java.sun.com/archives/jini-users.html
Unsubscribing:       email "signoff JINI-USERS"  to [email protected]