jar file location - ear file or server lib folder?

痞子三分冷 提交于 2020-01-07 03:21:13

问题


When deploying an application to JBoss server, for a JAR like ojdbc14.jar (Oracle JDBC), is it better to include this jar in the ear file of the deployment, or should it be deployed to JBoss's server/default/lib folder?

The argument I've been given is that the application needs to support global transactions, hence the datasource must be defined at the application server level (e.g. copied to server/default/lib folder) so it can talk to other app servers, and for that to happen you need the drivers at the app server level.

I'd like to hear what is the correct approach here. Thanks.


回答1:


I believe this is the correct approach.

You will typically define your datasource outside of your application (outside of your EAR/WAR) using the appropriate configuration files depending upon the application server you are using. Whereas on JBoss, you usually add your configuration to XML files, with WebLogic, you can create a datasource directly using the Admin console.

Given that this datasource will be created on server startup, the necessary libraries (in your case, ojdbc14.jar) must be available on the classpath of the application server.

I have also come across licensing issues where the use of a 3rd party library prevents you from bundling it within your application.

Also, defining your datasource outside of your application means you do not have to perform a rebuild when the datasource configuration needs to change.




回答2:


So many time I have done that...

I will always put the jar inside the server/default/lib folder if it has something to have about JDBC.

Because your database driver is loaded one time as soon as the server is started, and not each time you deploy/undeploy the webapplication your are working on.

Your datasources will be availiable for any others sub-projects too, and it will be a great advantage when you have a specific project for integration testing purpose.



来源:https://stackoverflow.com/questions/12318071/jar-file-location-ear-file-or-server-lib-folder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!