JBoss-provided libraries in Maven-managed Java EE app

南笙酒味 提交于 2019-12-23 19:47:07

问题


It's actually pretty unlikely for me, but it seems that there is no direct answer over the net about importing JBoss-provided dependencies into Maven-managed Java EE application to be deployed within it.

AFAIK there are 2 things somehow related to the problem, that is jboss-as-client artifact for external (in sense of JVM) JBoss clients and jboss-as-component-matrix artifact with huge <dependencyManagement> block defining version of the libraries that JBoss uses. The latter artifact is pretty useful since I can use Maven's import scope to have all version properly set up. The one that is missing (AFAIK) i something like jboss-as-client but for deployed Java EE application. Something, that I can depend on with provided scope and have all stuff in the classpath, including platform-related APIs (like EJB or JMS) and AS-specific stuff (like EJB-ext or jboss-messaging) and possibly some other stuff from lib, lib/endorsed and (mainly) common/lib directories. I know that probably a better practice (and religion-compatible) would be to be explicit with dependencies used in modules but the way I'm asking about is much more pragmatic for me (sorry), at least for Java EE applications that really use many standard APIs.

I'm really curious about your way of dealing with such challange. I'm using 5.1.0.GA version of the AS.


回答1:


You have to provide your own (infrastructure) maven project which just packages all the mentioned dependencies and all your JBoss projects depend on this infrastructure project with scope provided.

But shouldn't you compile just against the specification jars instead of the concrete implementation?
Like

<dependency>
    <groupId>org.jboss.spec</groupId>
    <artifactId>jboss-javaee-6.0</artifactId>
    <version>1.0.0.Final</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>

Jump to the first occurrence of "Java EE 6 API" on http://arquillian.org/guides/getting_started/.




回答2:


You won't like this answer, but as the libraries are provided at run-time by JBoss, other than using a provided scope, it is not really your affair. The classes of any unstated transitive dependency will be loaded by a different class loader (presumably), and live nicely together with the application classes.

For the not so nice coupled classes, what @MichalKalinowski said is true.



来源:https://stackoverflow.com/questions/9839689/jboss-provided-libraries-in-maven-managed-java-ee-app

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