[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] Hot deploy context that uses JNI
|
I figured it out. Here's the solution in case anyone else is running
into the same problem:
I had to move all of the scalaqlite classes into a package,
org.srhea.scalaqlite, and then load both that package and scala, on
which it depends, via the system class loader. The relevant lines
from my contexts/foo.xml file are:
<Set name="systemClasses">
<Array type="java.lang.String">
<Item>java.</Item>
<Item>javax.</Item>
<Item>org.mortbay.</Item>
<Item>org.xml.</Item>
<Item>org.w3c.</Item>
<Item>org.apache.commons.logging.</Item>
<Item>org.apache.log4j.</Item>
<Item>org.srhea.scalaqlite.</Item>
<Item>scala.</Item>
</Array>
</Set>
The last two items are the important ones. The rest are just the
defaults defined in
modules/jetty/src/main/java/org/mortbay/jetty/webapp/WebAppContext.java
Sean
On Thu, Nov 18, 2010 at 8:29 AM, Sean Rhea <sean.c.rhea@xxxxxxxxx> wrote:
> Hello,
>
> I can see from the archives that this question has come up before, but
> I can't find an answer to it. Apologies if I missed one.
>
> I'm trying to hot deploy a web context that uses a JNI library. I'm
> using jetty-6.1.26, but I can switch versions if necessary. The
> library is scalaqlite [1]. The first time I start jetty, the library
> loads fine and works. But if I touch contexts/foo.xml, reloading the
> app, the next access causes an exception:
>
> java.lang.UnsatisfiedLinkError: Native Library
> /home/srhea/src/foo/lib/libscalaqlite.so already loaded in another
> classloader
>
> libscalaqlite.so contains the JNI implementation of the Sqlite3C
> class, which is written in Java.
>
> I've tried a number of things to fix this. Setting
>
> <Set name="parentLoaderPriority">true</Set>
>
> in jetty.xml causes the JVM (1.6.0_22-b04, although 1.5.0_22-b03
> crashes as well) to crash with this error:
>
> # A fatal error has been detected by the Java Runtime Environment:
> # SIGSEGV (0xb) at pc=0x6ef1adcc, pid=10998, tid=1852078992
>
> I also tried calling setSystemClasses to include Sqlite3C [2], but
> that caused another JVM crash:
>
> *** glibc detected *** /home/srhea/src/jdk1.6.0_22/bin/java:
> munmap_chunk(): invalid pointer: 0x6e310b44 ***
>
> Am I missing something obvious? Or do people just not do this sort of thing?
>
> Also, if you'd like me to put together a small webapp that
> demonstrates the problem, just let me know. It shouldn't take long.
>
> Thanks in advance for any help you can provide,
> Sean
>
> 1. https://github.com/srhea/scalaqlite
> 2. The full command in my jetty.xml was:
>
> <Set name="systemClasses">
> <Array type="java.lang.String">
> <Item>java.</Item>
> <Item>javax.servlet.</Item>
> <Item>javax.xml.</Item>
> <Item>org.mortbay.</Item>
> <Item>org.xml.</Item>
> <Item>org.w3c.</Item>
> <Item>org.apache.commons.logging.</Item>
> <Item>org.apache.log4j.</Item>
> <Item>Sqlite3C</Item>
> </Array>
> </Set>
>
> --
> "I refuse to accept the idea that the ‘isness’ of man’s present nature
> makes him morally incapable of reaching up for the eternal ‘oughtness’
> that forever confronts him." --MLK
>
--
"I refuse to accept the idea that the ‘isness’ of man’s present nature
makes him morally incapable of reaching up for the eternal ‘oughtness’
that forever confronts him." --MLK