如何在 Windows 上正确使用 JNI 和 Java EE (Servlet)?
我试图了解从 Servlet 使用 JNI 的正确方法是什么。
据我了解,存在几个问题:
- 如果本机 DLL 崩溃,它将导致整个应用程序服务器崩溃
- 如果 DLL 由加载的一个类加载,则另一个类加载器将无法加载和使用它。
我搜索了互联网并找到了几个可能的解决方案
- 创建独立的启用 JMS 的应用程序并在 Servlet 中使用 JMS 与其进行通信。
- 运行独立服务器,加载 JNI 并通过 RMI 与其对话
- 使用 Java 连接器架构
我希望获得有关此主题的任何信息,这种情况下的最佳实践是什么?
PS我不确定这是否重要,但是需要使用本机DLL的应用程序运行在JBoss上。
I am trying to understand what is the correct way of usage JNI from Servlet.
As I understand there are several problems:
- If native DLL crashes, it will bring down whole app server
- If DLL is loaded by one class loaded, than another class loader won't be able to load and use it.
I searched internet and found couple of possible solution
- Create standalone JMS enabled application and use JMS in Servlet to communicate with it.
- Run standalone server, load in it JNI and talk to it through RMI
- Use Java Connector architecture
I would appreciate any information on this subject, what is best practice in this case?
P.S. I am not sure whether it's important, but the application which needs to use native DLL runs on JBoss.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我绝对不会在 Java EE 应用服务器中运行基于 JNI 的工具。您关于使用 JMS 的建议是一个很好的建议。您可以围绕基于消息的 Bean 创建一个服务,以响应外部服务分派的消息:
http: //oreilly.com/catalog/entjbeans3/chapter/ch13.html
以下是有关消息驱动 bean 的 Oracle Java EE 文档的链接:
http://download.oracle.com/javaee/5/tutorial/doc /bnbpk.html
我建议让两个 JBoss 服务器通过 JMS 相互通信比编写 JCA 适配器更容易,而且 JMS 消息驱动 Bean 是一种更简洁的接口。 JCA 似乎根本没有发展——似乎没有任何很棒的实现教程(这只是我的看法)。
I would absolutely not run a JNI-based tool in a Java EE app server. Your suggestion for using JMS is a good one. You could create a service around message based Beans to respond to messages dispatched by your external service:
http://oreilly.com/catalog/entjbeans3/chapter/ch13.html
Here is the link to the Oracle Java EE documentation on Message-driven beans:
http://download.oracle.com/javaee/5/tutorial/doc/bnbpk.html
I would suggest getting two JBoss servers to talk to one another over JMS is easier than writing a JCA adapter, and that JMS message-driven beans are a cleaner interface. JCA doesn't seem to be evolving at all - there doesn't seem to be any great implementation tutorials (that's just my perception).