如何处理Java中的冲突依赖关系(EE) [英] How to handle conflicting dependencies in Java (EE)

查看:351
本文介绍了如何处理Java中的冲突依赖关系(EE)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Java EE 6平台上开发一个企业应用程序。 IDE是NetBeans 7.2,应用程序服务器是GlassFish 3.1.2.2。
$ b 业务逻辑必须使用一个库(HBase-RDF是特定的)来处理一些任务在其核心。最初的HBase-RDF代码依赖于很多包,我相信他们的新版本已经被Glassfish使用。例如,我可以看到javax.xml,javax.activation,com.sun.jersey和已经包含在jar文件中的类似包。



尽管我以前开发过不在过去的平凡Java EE应用程序中,我遇到了无数令人头疼的事情,这些应用程序可能与此有关,也可能与此无关。从我在网上读过的东西,包括几十个stackoverflow问题和bug跟踪系统,我想我可以摆脱一些头疼的问题,如果我可以将原始库(HBase-RDF)与其所有依赖关系打包为一个完整的jar文件,并防止它们被直接包含在项目中。



我的第一个问题是,我对这个问题的原因是否正确?这可能是我的问题的根源吗?我想答案是肯定的,因为我已经通过从类路径中移除JAXB和Xerces jar来解决了我的一个问题,幸运的是我必须使用的Hbase-RDF的这些部分不会使用它们。



第二个问题是,如果我对上一个问题是正确的,我该怎么做?我如何限制这些库只能被一个库(Hbase-RDF)使用?






注意:它可能是有用的说,构建过程没有任何问题,但我面临着部署和运行项目的两个主要问题。首先,应用程序成功部署在与netbeans一起安装的本地Glassfish实例上,但相同的.ear包无法在另一个相同版本的实例上部署,并且server.log文件不包含任何有助于查找问题原因的内容。该错误与非常相似,但提议解决方案不起作用。第二个问题与这个非常相似,再次,我已经尝试过所有提出的解决方案,但没有运气有趣的是,Web模块中的Web服务成功调用EJB,但JSF facelet index.html无法运行。 解决方案

我不确定您的问题是关于构建过程还是部署。

因为部署,如果您有一个依赖不同版本的库的库,您已经部署了这个如果不使用 OSGi (不能同时使用相同的类加载器,则不能使用这两个库的版本)。

您是否尝试彻底删除依赖项并且只能使用更新的版本。

如果您唯一的依赖关系是 JAXB xml 你可能很幸运的java包。

I'm developing an enterprise application on Java EE 6 platform. The IDE is NetBeans 7.2 and the application server is GlassFish 3.1.2.2.

The business logic has to use a library (HBase-RDF to be specific) to handle some tasks in its core. The original HBase-RDF code depends on many packages of which I believe their newer versions are already used by Glassfish. For instance, I can see javax.xml, javax.activation, com.sun.jersey and similar packages already included in the jar files.

Although I had previously developed not-so-trivial Java EE applications in the past, I have faced countless headaches developing the application which may or may not be related to this. From what I had read on the web, including dozens of stackoverflow questions and bug tracking systems, I guess I may be able to get rid of some of those headaches if I can package the original library (HBase-RDF) with all its dependencies as a whole jar file and prevent them being included directly in the project.

My first question is, am I right about the cause of the problems? Can this be the source of my problems? I guess the answer would be yes, because I have already solved one of my problems by removing JAXB and Xerces jars from the classpath and fortunately those portions of the Hbase-RDF I have to work with does not engage them.

And the second question is, in case that I'm right about the previous question, how can I do this? How can I restrict these libraries to be used only by one library (Hbase-RDF)?


NOTE: It may be useful to say that the build process finishes without any problems, but I face two major problems deploying and running the project. First, the application deploys successfully on my local Glassfish instance which is installed alongside netbeans, but the same .ear package fails to deploy on another same-version instance and the server.log file does not contain anything helpful for finding the cause of the problem. The error is very similar to this but the proposed solutions don't work. The second problem is very similar to this and again, I have tried every single proposed solution with no luck. It's interesting to see that the web service inside the web module calls the EJB successfully, but the JSF facelet index.html fails to run.

解决方案

I am not really sure if your concern is about the build process or the deployment.
Because for deployment, if you have a library that is dependent on a different version of a library you already deploy this is impossible to work without resorting to OSGi (can not have both versions of the library with the same classloader).
Have you tried completely removing the dependent libraries and only use the newer versions.
If your only dependencies are for JAXB and the xml package of java you might be lucky

这篇关于如何处理Java中的冲突依赖关系(EE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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