在 Glassfish 中放置外部库的位置 [英] Where to put external libs in Glassfish

查看:28
本文介绍了在 Glassfish 中放置外部库的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Netbeans 7 创建了一个 JSF2 项目,并成功地将它部署到 Glassfish 3.1 上.不过,ear 文件已经变得相当大(6.5mb),其中大部分由外部 jar 文件(如 apache commons、solrj、primefaces 和 pdfrenderer 等)组成,这些文件被复制到相应的 war/ejb 文件中.

I have created a JSF2 project with Netbeans 7 and successfully deployed it on Glassfish 3.1. The ear file has grown quite big (6.5mb) though, most of it consists of external jar files (like apache commons, solrj, primefaces and pdfrenderer etc.) which are copied into the respective war/ejb files.

我的问题是:我怎样才能避免这种情况并使我的耳朵文件更小——它应该只包含我创建的东西,外部库应该只在服务器上部署一次.

My question is: how can I avoid that and make my ear file smaller - it should only contain the stuff that I created, the external libs should only be deployed once on the server.

我在网上搜索了有关此问题的答案,唯一发现的是将外部 jar 文件放在 glassfish 安装目录中的域/域1/lib"或域/域1/lib/ext"下,并取消选中"Netbeans 项目库设置中的 Package' 标志,但到目前为止这些都不起作用(我总是得到 ClassNotFoundExceptions).

I searched the web for answers on this and the only thing I found was putting the external jar files under 'domains/domain1/lib' or 'domains/domain1/lib/ext' in the glassfish installation directory and unchecking the 'Package' flag in the Netbeans project library settings, but none of this worked so far (I always get ClassNotFoundExceptions).

我是否必须做其他事情,在某处调整类路径设置,或者我该如何实现?有人有解决办法吗?

Do I have to do something else, adapt a classpath setting somewhere or how can I achieve this? Does anyone have a solution?

更新: 好吧,我发现这种情况只发生在我本地安装了 Netbeans 的 Glassfish 上(它是一台运行 64 位 Windows 7 的笔记本电脑).在我的远程 Linux 机器上,它按预期工作,即我能够将所有外部库放入 'domains/domain1/lib' - 我的耳朵文件现在只有 ~700k :)我将在我的 Mac 和另一个 Windows 7 机器上尝试此操作,看看这是操作系统相关问题还是其他问题.

Update: Ok I found out that this is only happening on my local Glassfish install that comes with Netbeans (its a laptop with 64bit Windows 7 running on it). On my remote Linux box it works as expected, i.e. I was able to put all external libs into 'domains/domain1/lib' - my ear file is only ~700k now :) I will try this on my Mac and on another Windows 7 box too, to see if this is a OS related issue or something else.

推荐答案

我想我现在可以自己回答这个问题了:domain1/lib 似乎是放置所有这些 jar 文件的正确位置.至少它在我尝试过的 2 个 Linux 机器和我的 Mac 上完美运行.我还发现了为什么它在我的 Windows 7 笔记本电脑上无法正常工作.如果您使用 Netbeans 附带的 Glassfish 安装,域路径是用户特定的,这意味着您必须将 jar 文件放在

I think I can answer the question myself now: domain1/lib seems to be the right place to put all those jar files. At least it works perfectly on the 2 Linux boxes I tried and on my Mac. I also found out why it didnt work the same on my Windows 7 laptop. The domain path is user specific if you use the Glassfish install that comes with Netbeans, that means you have to put the jar files under

C:Users`用户名`.netbeans7.0configGF3domain1lib

按预期工作,

C:Program Filesglassfish-3.1glassfishdomaindomain1lib

C:Program Filesglassfish-3.1glassfishdomaindomain1lib

另一方面似乎被类加载器忽略.

on the other hand seem to be ignored by the classloader.

这篇关于在 Glassfish 中放置外部库的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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