在尝试定义模块时,Maven不会将EJB识别为项目的依赖项 [英] Maven doesn't recognize EJB as dependency of project when trying to define module

查看:166
本文介绍了在尝试定义模块时,Maven不会将EJB识别为项目的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我将我的本地Glassfish服务器升级到3.1.1,准备将我公司的服务器升级到同一版本。我试图将我的web服务项目转换为与新服务器配合使用,并且遇到了障碍。

在我耳朵的pom文件中,我以前同时拥有webapp和列为依赖项的ejb。在webapp的pom中,我也列出了ejb作为依赖项。尝试将此配置部署到Glassfish 3.1.1时,收到此错误:
$ b


部署期间发生错误:部署应用程序时出现异常[ ear]:无法解析引用Local ejb-ref name = name,Local 3.x interface = interface,ejb-link = null,lookup =,mappedName =,jndi-name =,refType = Session,因为应用程序中有2个ejbs与界面接口。一些可能的原因:1. EJB bean类被封装在一个ear库库中(或者通过任何其他的库机制,使得库对所有组件模块可见),这使得所有组件模块间接包含这个bean类。 2. EJB bean类打包在引用EJB的组件模块中,直接或通过Manifest,WEB-INF / lib间接引用。 EJB bean类应该只打包在声明的ejb模块中,而不是引用模块。引用模块应该只包含EJB接口..请参阅server.log fo .... msg.seeServerLog


基本上我相信它是因为我把EJB列为两个不同领域的依赖项,Glassfish 3.1.1并不知道要寻找哪个依赖关系。这在2.1.1中不是问题。因此,我删除了耳朵中的依赖关系,因为它仍然是耳朵有效绒球的一部分。

然而,现在当耳朵产生应用程序时。 XML文件,它省略了文件中的所有ejb信息。我现在可以部署应用程序了,但是当我尝试运行任何东西时,我得到了有关ejbs的NameNotFoundExceptions。



我试图手动将ejb模块添加到耳筒与标签,但是当我尝试构建项目时,我收到错误消息:

lockquote

工件[ejb]不是依赖于项目。

尽管事实是,当我看到有效的耳朵时,我可以看到ejb被列为依赖项。



如何正确生成application.xml文件,同时仍符合Glassfish 3.1.1的更严格的规则集?



<如果您需要更多信息,请告知我们,并感谢您的帮助!

解决方案

答案最终变得非常简单,并且我为自己踢了一下。在webapp的pom文件中,我只需将范围行添加到ejb依赖项中即可:

 < dependency> 
< groupId> com.groupId< / groupId>
< artifactId> webservice-service-ejbs< / artifactId>
< version> $ {project.version}< / version>
< type> ejb< / type>
< scope>提供< / scope>
< /依赖关系>

有了这个,我可以将ejb依赖关系保留在ear pom中,正确生成application.xml和glassfish 3.1.1没有混淆,认为有多个ejb类具有相同的名称。



编辑:这是ejb依赖关系在耳朵中的样子

 < dependency> 
< groupId> com.groupId< / groupId>
< artifactId> webservice-service-ejbs< / artifactId>
< type> ejb< / type>
< /依赖关系>

感谢那些帮助我的人。


Today I upgraded my local Glassfish server to 3.1.1 in preparation for my company's upgrading of the servers to the same version. I am attempting to convert my web service project to play nice with the new server, and have hit a road block.

In my ear's pom file, I previously had both the webapp and the ejb listed as dependencies. In the webapp's pom, I had the ejb listed as a dependency as well. When attempting to deploy this configuration to Glassfish 3.1.1, I received this error:

Error occurred during deployment: Exception while deploying the app [ear] : Cannot resolve reference Local ejb-ref name=name,Local 3.x interface =interface,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session because there are 2 ejbs in the application with interface interface. Some of the possible causes: 1. The EJB bean class was packaged in an ear lib library (or through any other library mechanism which makes the library visible to all component modules), this makes all the component modules include this bean class indirectly. 2. The EJB bean class was packaged in a component module which references the EJB, either directly or indirectly through Manifest, WEB-INF/lib. The EJB bean class should only be packaged in the declaring ejb module and not the referencing modules. The referencing modules should only include EJB interfaces.. Please see server.log fo .... msg.seeServerLog

Essentially I believe it is saying that because I have the EJB listed as a dependency in two different areas, Glassfish 3.1.1 doesn't know which dependency to look to. This wasn't an issue in 2.1.1. Because of this, I removed the dependency in the ear, seeing as it would still be part of the ear's effective pom.

However, now when the ear generates the application.xml file, it omits all the ejb information from the file. I can deploy the application just fine now, but when I try to run anything I get NameNotFoundExceptions regarding the ejbs.

I attempted to add the ejb modules to the ear pom manually with the tag, but when I try to build the project I get the error message:

Artifact[ejb] is not a dependency of the project.

This despite the fact that when I look at the effective pom for the ear I can see the ejb listed as a dependency.

How can I generate the application.xml file properly while still conforming to Glassfish 3.1.1's more rigid ruleset?

Let me know if you need any more information, and thanks for the help!

解决方案

The answer ended up being pretty simple, and I'm kicking myself a bit for it. In the webapp's pom file, I just had to add the scope line to the ejb dependency:

<dependency>
    <groupId>com.groupId</groupId>
    <artifactId>webservice-service-ejbs</artifactId>
    <version>${project.version}</version>
    <type>ejb</type>
    <scope>provided</scope>
</dependency>

With this, I could keep the ejb dependency in the ear pom, application.xml generated properly and glassfish 3.1.1 didn't get confused thinking there were multiple ejb classes with the same name.

EDIT: Here's what the ejb dependency looks like in the ear pom

<dependency>
    <groupId>com.groupId</groupId>
    <artifactId>webservice-service-ejbs</artifactId>
    <type>ejb</type>
</dependency>

Thanks to those who helped me out.

这篇关于在尝试定义模块时,Maven不会将EJB识别为项目的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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