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

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

问题描述

我使用Netbeans 7创建了一个JSF2项目,并成功将其部署在Glassfish 3.1上。
虽然ear文件增长很大(6.5mb),但它大部分都是由外部jar文件(如apache commons,solrj,primefaces和pdfrenderer等)组成的,它们被复制到相应的war / ejb文件中。 / p>

我的问题是:如何避免这种情况,并使我的ear文件变小 - 它应该只包含我创建的内容,外部库只应该在服务器。



我在网上搜索了这个答案,我发现的唯一的东西是将外部jar文件放在'domains / domain1 / lib'或'domains / domain1 / lib / ext'放在glassfish安装目录中,并取消选中Netbeans项目库设置中的'Package'标签,但目前为止这些标签都没有工作(我总是得到ClassNotFoundExceptions)。



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



更新:好的,我发现这只发生在Netbeans附带的本地Glassfish安装上一台运行64位Windows 7的笔记本电脑)。在我的远程Linux机器上,它按预期工作,即我能够将所有外部库放入'domains / domain1 / lib'中 - 我的ear文件现在只有〜700k :)
我会在我的Mac上试试这个在另一个Windows 7的盒子上,以查看这是否是一个操作系统相关的问题或别的东西。

解决方案

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


C:\ Users \'username` \.netbeans\7.0\config\GF3\domain1\lib




按预期工作,JAR在


下C:\程序文件\glassfish -3.1 \glassfish\domain\domain1\lib


似乎被忽略 strong>由类加载器。


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.

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?

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.

解决方案

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\`username`\.netbeans\7.0\config\GF3\domain1\lib

to work as expectd, jars under

C:\Program Files\glassfish-3.1\glassfish\domain\domain1\lib

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

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

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