.dll已经加载到另一个类加载器中? [英] .dll already loaded in another classloader?

查看:91
本文介绍了.dll已经加载到另一个类加载器中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Tomcat 3.2.1下运行的Web应用程序,需要在其中进行JNI调用 为了访问旧版C ++代码中的数据和方法.加载了一个servlet 在 作为init方法一部分的webapp启动会导致数据集 特定于该Webapp实例以加载到C ++数据中 结构.

I have a webapp running under Tomcat 3.2.1 that needs to make JNI calls in order to access data and methods in legacy C++ code. A servlet is loaded on startup of the webapp that, as part of its init method, causes a data set specific to that webapp instance to be loaded into the C++ data structures.

此servlet的此Java代码包含以下内容:

This Java code for this servlet contains the following:

static
{
    try {
        System.loadLibrary("JCoreImpl");
        System.out.println("JCoreImpl loaded");
        m_bLibraryLoaded = true;
    } catch (UnsatisfiedLinkError e) {
        m_bLibraryLoaded = false;
        System.out.println("JCoreImpl NOT loaded " + e);
    }
}

如果只有一个Web应用程序,则一切正常(我们将其称为 "webapps/aaa").

Things work fine if there is only one webapp (let's call it "webapps/aaa").

如果我有另一个与webapps/aaa相同的webapp("webapps/bbb") 除了C ++数据结构中使用的数据集外,然后是webapps/aaa 启动正常,但是启动webapps/bbb时出现错误 说明

If I have a second webapp ("webapps/bbb") that is identical to webapps/aaa except for the data set used in the C++ data structures, then webapps/aaa starts up just fine, but when webapps/bbb is started I get an error stating that:

JCoreImpl NOT loaded java.lang.UnsatisfiedLinkError: Native Library
E:\WebStation\binDebug\JCoreImpl.dll already loaded in another classloader

我需要为我的每个人都有一个本机库的单独实例 webapps,因为每个实例都需要包含唯一的数据 特定的webapp.我搜索了邮件档案并阅读了 Craig McLanahan撰写的电子邮件,解释了类加载器的层次结构.但是我 有 无法找到特定于加载唯一实例的任何内容 每个Web应用程序的本机库.

I need to have a separate instance of the native library for each of my webapps as each instance needs to contain data that is unique to that particular webapp. I have searched through the mail archives and read emails by Craig McLanahan explaining the classloader hierarchy. But I have not been able to find anything specific to loading a unique instance of a native library for each webapp.

推荐答案

您不能两次加载同一个本机库.

You can't load the same native library twice.

将类放在<tomcat>/lib/下的jar文件中,它将在所有战争中共享.

Put the class in a jar file under <tomcat>/lib/, it will be shared over all wars.

这篇关于.dll已经加载到另一个类加载器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆