Re: Two Services trying to load a System library in same JVM
Gregg Wonderly <[email protected]> Tue, 8 Jul 2008 10:57:21 -0500
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <[email protected]> |
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 -------------------------------------------------------------------------- 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]