开发者

Where to put external libs in Glassfish

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.


The only directory that is part of the classpath is the domain1\lib\classes directory. Putting your jars there will add them to the classpath.

You can also put in your ear file under the lib directory (formerly APP-INF\lib). That is the place to put your shared jars.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜